diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/CSharpIdentifier.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/CSharpIdentifier.cs new file mode 100644 index 0000000000..a7571910d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/CSharpIdentifier.cs @@ -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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ExtensionInitializer.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ExtensionInitializer.cs new file mode 100644 index 0000000000..51f16b552f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ExtensionInitializer.cs @@ -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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/IInjectTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/IInjectTargetExtension.cs new file mode 100644 index 0000000000..781932ba8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/IInjectTargetExtension.cs @@ -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); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/IViewComponentTagHelperTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/IViewComponentTagHelperTargetExtension.cs new file mode 100644 index 0000000000..45a0d581a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/IViewComponentTagHelperTargetExtension.cs @@ -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); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectDirective.cs new file mode 100644 index 0000000000..f5ea583121 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectDirective.cs @@ -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(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("", "<" + 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 Directives { get; } = new List(); + + 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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectIntermediateNode.cs new file mode 100644 index 0000000000..8325c2b7a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectIntermediateNode.cs @@ -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(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(); + if (extension == null) + { + ReportMissingCodeTargetExtension(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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectTargetExtension.cs new file mode 100644 index 0000000000..d64023ade7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/InjectTargetExtension.cs @@ -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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/LegacySectionTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/LegacySectionTargetExtension.cs new file mode 100644 index 0000000000..52698cdfe8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/LegacySectionTargetExtension.cs @@ -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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj new file mode 100644 index 0000000000..f949a8e8ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj @@ -0,0 +1,22 @@ + + + + ASP.NET Core design time hosting infrastructure for the Razor view engine. + netstandard2.0 + $(PackageTags);aspnetcoremvc + false + false + + + + + Shared\CodeWriterExtensions.cs + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ModelDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ModelDirective.cs new file mode 100644 index 0000000000..c16f46153f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ModelDirective.cs @@ -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("", "<" + modelType + ">"); + visitor.Class.BaseType = baseType; + } + } + + private class Visitor : IntermediateNodeWalker + { + public NamespaceDeclarationIntermediateNode Namespace { get; private set; } + + public ClassDeclarationIntermediateNode Class { get; private set; } + + public IList ModelDirectives { get; } = new List(); + + 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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ModelExpressionPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ModelExpressionPass.cs new file mode 100644 index 0000000000..c943afe5bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ModelExpressionPass.cs @@ -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 TagHelpers { get; } = new List(); + + 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); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/MvcImportProjectFeature.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..fa8a40fedb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/MvcImportProjectFeature.cs @@ -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 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(); + } + + var imports = new List(); + 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 imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List 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 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/MvcViewDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/MvcViewDocumentClassifierPass.cs new file mode 100644 index 0000000000..b4a5c930f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/MvcViewDocumentClassifierPass.cs @@ -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"; + @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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8233c62607 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Properties/AssemblyInfo.cs @@ -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")] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/RazorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/RazorExtensions.cs new file mode 100644 index 0000000000..6fe73b57ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/RazorExtensions.cs @@ -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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/RazorExtensionsDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/RazorExtensionsDiagnosticFactory.cs new file mode 100644 index 0000000000..af883af3d4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/RazorExtensionsDiagnosticFactory.cs @@ -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; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Resources.resx new file mode 100644 index 0000000000..6754c87c52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/Resources.resx @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Value cannot be null or empty. + + + Inject a service from the application's service container into a property. + + + The name of the property. + + + PropertyName + + + The type of the service to inject. + + + TypeName + + + Specify the view or page model for the page. + + + The model type. + + + TypeName + + + The 'inherits' keyword is not allowed when a '{0}' keyword is used. + + + A property name must be specified when using the '{0}' statement. Format for a '{0}' statement is '@{0} <Type Name> <Property Name>'. + + + The '{0}' keyword must be followed by a type name on the same line. + + + Only one '{0}' statement is allowed in a file. + + + Invalid tag helper property '{0}.{1}'. Dictionary values must not be of type '{2}'. + + + The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor cshtml file. + + + Runtime code generation for Mvc 1.x is not supported. + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/TagHelperDescriptorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/TagHelperDescriptorExtensions.cs new file mode 100644 index 0000000000..b455fc7423 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/TagHelperDescriptorExtensions.cs @@ -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 + { + /// + /// Indicates whether a represents a view component. + /// + /// The to check. + /// Whether a represents a view component. + 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; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentResources.resx new file mode 100644 index 0000000000..d6aad4ff3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentResources.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + View component '{0}' must have exactly one public method named '{1}' or '{2}'. + + + Method '{0}' of view component '{1}' should be declared to return {2}&lt;T&gt;. + + + Could not find an '{0}' or '{1}' method for the view component '{2}'. + + + Method '{0}' of view component '{1}' cannot return a {2}. + + + Method '{0}' of view component '{1}' should be declared to return a value. + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperConventions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperConventions.cs new file mode 100644 index 0000000000..f02d874dc5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperConventions.cs @@ -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"; + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs new file mode 100644 index 0000000000..795786f5b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs @@ -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 PrimitiveDisplayTypeNameLookups = new Dictionary(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() + .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. + 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. + 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 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 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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..318994ec0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorProvider.cs @@ -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(); + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperIntermediateNode.cs new file mode 100644 index 0000000000..b1399ffbea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperIntermediateNode.cs @@ -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(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(); + if (extension == null) + { + ReportMissingCodeTargetExtension(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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperMetadata.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperMetadata.cs new file mode 100644 index 0000000000..1718829c39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperMetadata.cs @@ -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 + { + /// + /// The key in a containing + /// the short name of a view component. + /// + public static readonly string Name = "MVC.ViewComponent.Name"; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperPass.cs new file mode 100644 index 0000000000..ba9938a123 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperPass.cs @@ -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(); + 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 _tagHelpers; + + public Context(NamespaceDeclarationIntermediateNode @namespace, ClassDeclarationIntermediateNode @class) + { + Namespace = @namespace; + Class = @class; + + _tagHelpers = new Dictionary(); + } + + public ClassDeclarationIntermediateNode Class { get; } + + public NamespaceDeclarationIntermediateNode Namespace { get; } + + + public IEnumerable 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"; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperTargetExtension.cs new file mode 100644 index 0000000000..eb426d0607 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperTargetExtension.cs @@ -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() + { + { 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(")]"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs new file mode 100644 index 0000000000..450e4e1557 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs @@ -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 _results; + + public ViewComponentTypeVisitor( + INamedTypeSymbol viewComponentAttribute, + INamedTypeSymbol nonViewComponentAttribute, + List 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypes.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypes.cs new file mode 100644 index 0000000000..e9d8f598f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypes.cs @@ -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"; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/InjectDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/InjectDirectiveTest.cs new file mode 100644 index 0000000000..63560c0f1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/InjectDirectiveTest.cs @@ -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(@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(@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 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(@class.Children[1]); + Assert.Equal("PropertyType", node.TypeName); + Assert.Equal("PropertyName", node.MemberName); + } + + [Fact] + public void InjectDirectivePass_Execute_ExpandsTModel_WithModelTypeFirst() + { + // Arrange + var codeDocument = CreateDocument(@" +@model ModelType +@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(@class.Children[1]); + Assert.Equal("PropertyType", node.TypeName); + Assert.Equal("PropertyName", node.MemberName); + } + + [Fact] + public void InjectDirectivePass_Execute_ExpandsTModel_WithModelType() + { + // Arrange + var codeDocument = CreateDocument(@" +@inject PropertyType 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(@class.Children[1]); + Assert.Equal("PropertyType", 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()); + 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; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/InjectTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/InjectTargetExtensionTest.cs new file mode 100644 index 0000000000..ec314d03f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/InjectTargetExtensionTest.cs @@ -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", + 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 PropertyName { get; private set; }" + Environment.NewLine + Environment.NewLine + + "#line default" + Environment.NewLine + + "#line hidden" + Environment.NewLine + + "#nullable disable" + Environment.NewLine, + context.CodeWriter.GenerateCode()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/IntegrationTests/CodeGenerationIntegrationTest.cs new file mode 100644 index 0000000000..bb605fed72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -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 +{ + 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 : 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 : RazorPage +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} + +public class MyModel +{ + +}"); + + AddProjectItemFromText(@"@inherits MyBasePageForViews"); + + 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 +{ + 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 +{ + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/LegacySectionTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/LegacySectionTargetExtensionTest.cs new file mode 100644 index 0000000000..edf09ff60a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/LegacySectionTargetExtensionTest.cs @@ -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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj new file mode 100644 index 0000000000..63812740f1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test.csproj @@ -0,0 +1,39 @@ + + + + $(StandardTestTfms) + true + $(DefaultItemExcludes);TestFiles\** + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs new file mode 100644 index 0000000000..7a4c811dbd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelDirectiveTest.cs @@ -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 +@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_DifferentOrdering() + { + // Arrange + var codeDocument = CreateDocument(@" +@model Type1 +@inherits BaseType +@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", @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 +"); + + 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_DesignTime_AddsTModelUsingDirective() + { + // Arrange + var codeDocument = CreateDocument(@" +@inherits BaseType +"); + + 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", @class.BaseType); + + var @namespace = FindNamespaceNode(irDocument); + var usingNode = Assert.IsType(@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 +@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", @class.BaseType); + + var @namespace = FindNamespaceNode(irDocument); + var usingNode = Assert.IsType(@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); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs new file mode 100644 index 0000000000..30f27ffcbb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ModelExpressionPassTest.cs @@ -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 +

"); + + 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().Single(); + + var token = Assert.IsType(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

"); + + 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().Single(); + + var expression = Assert.IsType(Assert.Single(setProperty.Children)); + Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Bar)", GetCSharpContent(expression)); + + var originalNode = Assert.IsType(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

"); + + 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().Single(); + + var expression = Assert.IsType(Assert.Single(setProperty.Children)); + Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => Bar)", GetCSharpContent(expression)); + + var originalNode = Assert.IsType(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; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcImportProjectFeatureTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..e53046ed5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcImportProjectFeatureTest.cs @@ -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(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + 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(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(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(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)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcShim.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcShim.cs new file mode 100644 index 0000000000..a50560e593 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcShim.cs @@ -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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs new file mode 100644 index 0000000000..a0a3825267 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/MvcViewDocumentClassifierPassTest.cs @@ -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", 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", 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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3337ebeac2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/SourceMappingsSerializer.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/SourceMappingsSerializer.cs new file mode 100644 index 0000000000..c081118d86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/SourceMappingsSerializer.cs @@ -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("|"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TagHelperDescriptorExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TagHelperDescriptorExtensionsTest.cs new file mode 100644 index 0000000000..f080719b5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TagHelperDescriptorExtensionsTest.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml new file mode 100644 index 0000000000..a20b20dae8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml @@ -0,0 +1,8 @@ +

+ Hello world + @string.Format("{0}", "Hello") +
+@{ + var cls = "foo"; +} +

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs new file mode 100644 index 0000000000..d39b64c26d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -0,0 +1,71 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt new file mode 100644 index 0000000000..eb3470593e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 -

+ 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 -
+ 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 -

+ IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt new file mode 100644 index 0000000000..372b49cb6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -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] ) +| }| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs new file mode 100644 index 0000000000..b8ce28e05f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs @@ -0,0 +1,92 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4120ddad9d4353ed260e0585fe71080d78ff8ab3" +// +#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 + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(0, 4, true); + WriteLiteral("

+ 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 -
+ 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 -

+ IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml new file mode 100644 index 0000000000..ecc90de2d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml @@ -0,0 +1,8 @@ +@* These test files validate that end-to-end, incomplete directives don't throw. *@ + +@model +@model + +@inject +@inject +@inject MyService diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs new file mode 100644 index 0000000000..de980049d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -0,0 +1,64 @@ +// +#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 + { + #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 __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..3542c13c86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -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. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt new file mode 100644 index 0000000000..304921a812 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 + 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 + HtmlContent - (150:7,25 [2] IncompleteDirectives.cshtml) + IntermediateToken - (150:7,25 [2] IncompleteDirectives.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt new file mode 100644 index 0000000000..a978e8d898 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -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| +Generated Location: (1156:35,0 [17] ) +|MyService| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs new file mode 100644 index 0000000000..e9170ae11c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -0,0 +1,51 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "844eb91b909a14b78feddd5e6866563b5a75e021" +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt new file mode 100644 index 0000000000..72a8fa589b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -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. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt new file mode 100644 index 0000000000..8bb3264f43 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -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 - + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml new file mode 100644 index 0000000000..38efd570da --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml @@ -0,0 +1,2 @@ +@inherits MyBasePageForViews +@model MyModel diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..c5e699c2cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -0,0 +1,56 @@ +// +#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 + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" +MyBasePageForViews __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt new file mode 100644 index 0000000000..cc189604db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..b5fd5c933d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) +|MyBasePageForViews| +Generated Location: (740:19,0 [26] ) +|MyBasePageForViews| + +Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) +|MyModel| +Generated Location: (976:27,0 [7] ) +|MyModel| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs new file mode 100644 index 0000000000..af9db74379 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs @@ -0,0 +1,33 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "91cf923452a86b2906083cb0236d6d5b3bc528ef" +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt new file mode 100644 index 0000000000..b18e254c9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt @@ -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 - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml new file mode 100644 index 0000000000..c735e2e429 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml @@ -0,0 +1 @@ +@model MyModel diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..c8e66ffaaf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..db2a73f64d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..9ee5bceaa0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) +|MyModel| +Generated Location: (752:19,0 [7] ) +|MyModel| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..5ede728cf8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs @@ -0,0 +1,33 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cf2e52e7d1326775fe4ece983a7f8ee1f62235a0" +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..0f47fce86b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt @@ -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 - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml new file mode 100644 index 0000000000..0aa749dd3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml @@ -0,0 +1 @@ +@inject MyApp MyPropertyName diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml new file mode 100644 index 0000000000..d699f1e754 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml @@ -0,0 +1,3 @@ +@model MyModel +@inject MyApp MyPropertyName +@inject MyService Html diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..4d4d684cda --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -0,0 +1,82 @@ +// +#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 + { + #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 __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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt new file mode 100644 index 0000000000..8ff03ba4e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..dd6970fdb8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -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| +Generated Location: (1422:43,0 [17] ) +|MyService| + +Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|Html| +Generated Location: (1669:51,22 [4] ) +|Html| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs new file mode 100644 index 0000000000..c3846121e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs @@ -0,0 +1,35 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a039b7091118c718dc3023b6ac58d9645cb58e59" +// +#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 + { + #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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt new file mode 100644 index 0000000000..2e1c3deb3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt @@ -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 - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml new file mode 100644 index 0000000000..8cd61913e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml @@ -0,0 +1,5 @@ +@model MyModel +@inject MyApp MyPropertyName; +@inject MyService Html; +@inject MyApp MyPropertyName2 ; +@inject MyService Html2 ; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs new file mode 100644 index 0000000000..15e13c4def --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -0,0 +1,118 @@ +// +#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 + { + #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 __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 __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 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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt new file mode 100644 index 0000000000..2b470e7180 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt new file mode 100644 index 0000000000..8c1b0b9336 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -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| +Generated Location: (1442:43,0 [17] ) +|MyService| + +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| +Generated Location: (2343:75,0 [17] ) +|MyService| + +Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|Html2| +Generated Location: (2594:83,22 [5] ) +|Html2| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs new file mode 100644 index 0000000000..4dd7659e08 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs @@ -0,0 +1,39 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5010aab35d235175dab517f8018e41aee9a2ac7f" +// +#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 + { + #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 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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt new file mode 100644 index 0000000000..b624d6b15c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt @@ -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 - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs new file mode 100644 index 0000000000..ec04e2bf8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -0,0 +1,58 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt new file mode 100644 index 0000000000..2fed4fbe5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt new file mode 100644 index 0000000000..27b118c2ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -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| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs new file mode 100644 index 0000000000..941237e909 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs @@ -0,0 +1,35 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c711078454f5b0e8d2cb77d9cb7fa88cca32b884" +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt new file mode 100644 index 0000000000..32a3c51ac7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt @@ -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 - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml new file mode 100644 index 0000000000..6dfb72bc31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml @@ -0,0 +1 @@ +@namespace Test. \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs new file mode 100644 index 0000000000..d99c176c52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -0,0 +1,40 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..c3add1daa9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -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. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt new file mode 100644 index 0000000000..f34fe8f4a0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs new file mode 100644 index 0000000000..d292eeebcc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs @@ -0,0 +1,36 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "de132bd3e2a46a0d2ec953a168427c01e5829cde" +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt new file mode 100644 index 0000000000..cfbf688e18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt @@ -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. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt new file mode 100644 index 0000000000..fb0bab7833 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt @@ -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 - + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml new file mode 100644 index 0000000000..4b73b2dc53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml @@ -0,0 +1 @@ +@model System.Collections.IEnumerable diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml new file mode 100644 index 0000000000..c488b1e443 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml @@ -0,0 +1,6 @@ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..f0fe1ad8e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -0,0 +1,76 @@ +// +#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 + { + #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(); +#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(); +#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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..1ecd121c63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -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 - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..d4fc8a447a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -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| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..8fb69e52ed --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs @@ -0,0 +1,104 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0906a816db301fe624bbe5a96c4b3013071ea492" +// +#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 + { + #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(); + __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(); + __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..b336b645b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt @@ -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 - + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs new file mode 100644 index 0000000000..c01f69d243 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#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_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" +System.Collections.IEnumerable __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt new file mode 100644 index 0000000000..c18b0cd554 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -0,0 +1,36 @@ +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_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 [30] Model.cshtml) - System.Collections.IEnumerable + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt new file mode 100644 index 0000000000..7d84cf754d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) +|System.Collections.IEnumerable| +Generated Location: (769:19,0 [30] ) +|System.Collections.IEnumerable| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs new file mode 100644 index 0000000000..cd4f57b409 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs @@ -0,0 +1,33 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "31c5b047a450ac9f6dc4116626667d26bfb657ba" +// +#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_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt new file mode 100644 index 0000000000..3f8d705381 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt @@ -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_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml new file mode 100644 index 0000000000..350f93b776 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml @@ -0,0 +1,2 @@ +@model ThisShouldBeGenerated +@model System.Collections.IEnumerable diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs new file mode 100644 index 0000000000..2ff817c2ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -0,0 +1,56 @@ +// +#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_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml" +ThisShouldBeGenerated __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml" +System.Collections.IEnumerable __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..2fe8233c66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt new file mode 100644 index 0000000000..a1ef9941e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -0,0 +1,39 @@ +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_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 [21] MultipleModels.cshtml) - ThisShouldBeGenerated + DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable + 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 + MalformedDirective - (30:1,0 [39] MultipleModels.cshtml) - model + DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt new file mode 100644 index 0000000000..8853f2b5d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) +|ThisShouldBeGenerated| +Generated Location: (778:19,0 [21] ) +|ThisShouldBeGenerated| + +Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) +|System.Collections.IEnumerable| +Generated Location: (1006:27,0 [30] ) +|System.Collections.IEnumerable| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml new file mode 100644 index 0000000000..7438788ff4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml @@ -0,0 +1,14 @@ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + +@{ + Layout = "_SectionTestLayout.cshtml"; +} + +

Some body
+ +@section Section1 { +
This is in Section 1
+ +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs new file mode 100644 index 0000000000..a720d28d50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -0,0 +1,86 @@ +// +#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_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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/Sections.cshtml" +DateTime __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object __typeHelper = "InputTestTagHelper, AppCode"; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object Section1 = 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() + { +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml"; + +#line default +#line hidden + DefineSection("Section1", async(__razor_section_writer) => { + __InputTestTagHelper = CreateTagHelper(); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt new file mode 100644 index 0000000000..35c27f4abb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -0,0 +1,73 @@ +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_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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] Sections.cshtml) - DateTime + DirectiveToken - (33:2,14 [29] Sections.cshtml) - "InputTestTagHelper, AppCode" + DirectiveToken - (152:10,9 [8] Sections.cshtml) - Section1 + 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] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + HtmlContent - (62:2,43 [4] Sections.cshtml) + IntermediateToken - (62:2,43 [4] Sections.cshtml) - Html - \n\n + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n + Section - - Section1 + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt new file mode 100644 index 0000000000..ba25b7bb6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|DateTime| +Generated Location: (1227:25,0 [8] ) +|DateTime| + +Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|"InputTestTagHelper, AppCode"| +Generated Location: (1473:33,37 [29] ) +|"InputTestTagHelper, AppCode"| + +Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Section1| +Generated Location: (1703:41,22 [8] ) +|Section1| + +Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +| + Layout = "_SectionTestLayout.cshtml"; +| +Generated Location: (2169:56,2 [46] ) +| + Layout = "_SectionTestLayout.cshtml"; +| + +Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Date| +Generated Location: (2594:64,102 [4] ) +|Date| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml new file mode 100644 index 0000000000..0430ccfc69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml @@ -0,0 +1,6 @@ +@addTagHelper "*, AppCode" +@{ + var foo = "Hello"; +} + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..90293d54ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -0,0 +1,90 @@ +// +#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_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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::AllTagHelper __AllTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" +global::System.Object __typeHelper = "*, 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() + { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + + var foo = "Hello"; + +#line default +#line hidden + __AllTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + __o = foo; + +#line default +#line hidden + __TestViewComponentTagHelper.firstName = string.Empty; + __AllTagHelper.Bar = " World"; + 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 Html { get; private set; } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")] + public class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper + { + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.String firstName { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync("Test", new { firstName }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..328b11876d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -0,0 +1,57 @@ +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_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (14:0,14 [12] ViewComponentTagHelper.cshtml) - "*, 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 - (26:0,26 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (26:0,26 [2] ViewComponentTagHelper.cshtml) - Html - \n + CSharpCode - (30:1,2 [26] ViewComponentTagHelper.cshtml) + IntermediateToken - (30:1,2 [26] ViewComponentTagHelper.cshtml) - CSharp - \n var foo = "Hello";\n + HtmlContent - (59:4,0 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (59:4,0 [2] ViewComponentTagHelper.cshtml) - Html - \n + TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - AllTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper + DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) + IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo + DefaultTagHelperProperty - (93:5,32 [6] ViewComponentTagHelper.cshtml) - bar - string AllTagHelper.Bar - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (93:5,32 [6] ViewComponentTagHelper.cshtml) + IntermediateToken - (93:5,32 [6] ViewComponentTagHelper.cshtml) - Html - World + DefaultTagHelperExecute - + Inject - + Inject - + Inject - + Inject - + Inject - + ViewComponentTagHelper - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..1af3082e0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +|"*, AppCode"| +Generated Location: (1465:26,37 [12] ) +|"*, AppCode"| + +Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +| + var foo = "Hello"; +| +Generated Location: (1942:41,2 [26] ) +| + var foo = "Hello"; +| + +Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +|foo| +Generated Location: (2393:49,22 [3] ) +|foo| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..2c85bf513c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs @@ -0,0 +1,110 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6a0ad3c59f3a87877c36928472f0508bd40cdd8c" +// +#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_ViewComponentTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bar", " World", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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::AllTagHelper __AllTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + + var foo = "Hello"; + +#line default +#line hidden + BeginContext(59, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(61, 50, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("vc:test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __AllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__AllTagHelper); + __TestViewComponentTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestViewComponentTagHelper); + BeginWriteTagHelperAttribute(); +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + WriteLiteral(foo); + +#line default +#line hidden + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestViewComponentTagHelper.firstName = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("first-name", __TestViewComponentTagHelper.firstName, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __AllTagHelper.Bar = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + 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 Html { get; private set; } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")] +public class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.String firstName { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync("Test", new { firstName }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } +} + + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..a1678711eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt @@ -0,0 +1,43 @@ +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_ViewComponentTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - bar - World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (30:1,2 [26] ViewComponentTagHelper.cshtml) + IntermediateToken - (30:1,2 [26] ViewComponentTagHelper.cshtml) - CSharp - \n var foo = "Hello";\n + CSharpCode - + IntermediateToken - - CSharp - BeginContext(59, 2, true); + HtmlContent - (59:4,0 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (59:4,0 [2] ViewComponentTagHelper.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(61, 50, false); + TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - AllTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml.__Generated__TestViewComponentTagHelper + DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) + IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo + PreallocatedTagHelperProperty - (93:5,32 [6] ViewComponentTagHelper.cshtml) - __tagHelperAttribute_0 - bar - Bar + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")]\npublic class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper\n{\n private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null;\n public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper)\n {\n _helper = helper;\n }\n [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute]\n public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; }\n public System.String firstName { get; set; }\n public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output)\n {\n (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext);\n var content = await _helper.InvokeAsync("Test", new { firstName });\n output.TagName = null;\n output.Content.SetHtmlContent(content);\n }\n}\n diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml new file mode 100644 index 0000000000..f4e110d289 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml @@ -0,0 +1 @@ +@inject IHtmlHelper Helper \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..363ff66ca5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -0,0 +1,58 @@ +// +#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__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" +IHtmlHelper __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" +global::System.Object Helper = 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 IHtmlHelper Helper { 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..f75113d4b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -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__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 [19] _ViewImports.cshtml) - IHtmlHelper + DirectiveToken - (28:0,28 [6] _ViewImports.cshtml) - Helper + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..6b845596b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) +|IHtmlHelper| +Generated Location: (760:19,0 [19] ) +|IHtmlHelper| + +Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) +|Helper| +Generated Location: (1006:27,22 [6] ) +|Helper| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..2400a20b50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs @@ -0,0 +1,35 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e57bbc3e746e8b13b4c33d8df0e022bd397d8caa" +// +#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__ViewImports_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 IHtmlHelper Helper { 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..3703d64a46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt @@ -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__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs new file mode 100644 index 0000000000..491a2faaab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -0,0 +1,343 @@ +// 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.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + public class ViewComponentTagHelperDescriptorFactoryTest + { + private static readonly Assembly _assembly = typeof(ViewComponentTagHelperDescriptorFactoryTest).GetTypeInfo().Assembly; + + [Fact] + public void CreateDescriptor_UnderstandsStringParameters() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(StringParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__StringParameterViewComponentTagHelper", + typeof(StringParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__StringParameterViewComponentTagHelper") + .DisplayName("StringParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:string-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "StringParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_UnderstandsVariousParameterTypes() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(VariousParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__VariousParameterViewComponentTagHelper", + typeof(VariousParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__VariousParameterViewComponentTagHelper") + .DisplayName("VariousParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:various-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("test-enum")) + .RequireAttributeDescriptor(attribute => attribute.Name("test-string")) + .RequireAttributeDescriptor(attribute => attribute.Name("baz"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("test-enum") + .PropertyName("testEnum") + .TypeName(typeof(VariousParameterViewComponent).FullName + "." + nameof(VariousParameterViewComponent.TestEnum)) + .AsEnum() + .DisplayName(typeof(VariousParameterViewComponent).FullName + "." + nameof(VariousParameterViewComponent.TestEnum) + " VariousParameterViewComponentTagHelper.testEnum")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("test-string") + .PropertyName("testString") + .TypeName(typeof(string).FullName) + .DisplayName("string VariousParameterViewComponentTagHelper.testString")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("baz") + .PropertyName("baz") + .TypeName(typeof(int).FullName) + .DisplayName("int VariousParameterViewComponentTagHelper.baz")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "VariousParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_UnderstandsGenericParameters() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(GenericParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__GenericParameterViewComponentTagHelper", + typeof(GenericParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__GenericParameterViewComponentTagHelper") + .DisplayName("GenericParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:generic-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("Foo") + .TypeName("System.Collections.Generic.List") + .DisplayName("System.Collections.Generic.List GenericParameterViewComponentTagHelper.Foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("Bar") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionaryAttribute("bar-", typeof(int).FullName) + .DisplayName("System.Collections.Generic.Dictionary GenericParameterViewComponentTagHelper.Bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "GenericParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(ViewComponentWithoutInvokeMethod).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_UnderstandsGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Empty(descriptor.GetAllDiagnostics()); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_UnderstandsNonGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithNonGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Empty(descriptor.GetAllDiagnostics()); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_DoesNotUnderstandVoid() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithString).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AsyncMethod_ShouldReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_DoesNotUnderstandString() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithString).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AsyncMethod_ShouldReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandVoid() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithVoid).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_ShouldReturnValue.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandNonGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithNonGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_CannotReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_CannotReturnTask.Id, diagnostic.Id); + } + } + + public class StringParameterViewComponent + { + public string Invoke(string foo, string bar) => null; + } + + public class VariousParameterViewComponent + { + public string Invoke(TestEnum testEnum, string testString, int baz = 5) => null; + + public enum TestEnum + { + A = 1, + B = 2, + C = 3 + } + } + + public class GenericParameterViewComponent + { + public string Invoke(List Foo, Dictionary Bar) => null; + } + + public class ViewComponentWithoutInvokeMethod + { + } + + public class AsyncViewComponentWithGenericTask + { + public Task InvokeAsync() => null; + } + + public class AsyncViewComponentWithNonGenericTask + { + public Task InvokeAsync() => null; + } + + public class AsyncViewComponentWithVoid + { + public void InvokeAsync() { } + } + + public class AsyncViewComponentWithString + { + public string InvokeAsync() => null; + } + + public class SyncViewComponentWithVoid + { + public void Invoke() { } + } + + public class SyncViewComponentWithNonGenericTask + { + public Task Invoke() => null; + } + + public class SyncViewComponentWithGenericTask + { + public Task Invoke() => null; + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..862b97d715 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs @@ -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.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + // This is just a basic integration test. There are detailed tests for the VCTH visitor and descriptor factory. + public class ViewComponentTagHelperDescriptorProviderTest + { + [Fact] + public void DescriptorProvider_FindsVCTH() + { + // Arrange + var code = @" + public class StringParameterViewComponent + { + public string Invoke(string foo, string bar) => null; + } +"; + + var compilation = MvcShim.BaseCompilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(code)); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ViewComponentTagHelperDescriptorProvider() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__StringParameterViewComponentTagHelper", + TestCompilation.AssemblyName) + .TypeName("__Generated__StringParameterViewComponentTagHelper") + .DisplayName("StringParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:string-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "StringParameter") + .Build(); + + // Act + provider.Execute(context); + + // Assert + Assert.Single(context.Results, d => TagHelperDescriptorComparer.Default.Equals(d, expectedDescriptor)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs new file mode 100644 index 0000000000..befa9d011c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperPassTest.cs @@ -0,0 +1,275 @@ +// 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.Linq; +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 ViewComponentTagHelperPassTest + { + [Fact] + public void ViewComponentTagHelperPass_Execute_IgnoresRegularTagHelper() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly") + .TypeName("TestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build() + }; + + var engine = CreateEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = engine, + }; + + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var @class = FindClassNode(irDocument); + Assert.Equal(3, @class.Children.Count); // No class node created for a VCTH + for (var i = 0; i < @class.Children.Count; i++) + { + Assert.IsNotType(@class.Children[i]); + } + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("Foo")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var engine = CreateEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = engine, + }; + + var irDocument = CreateIRDocument(engine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(vcthFullName, Assert.IsType(tagHelper.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(tagHelper.Children[2]).PropertyName); + + + var @class = FindClassNode(irDocument); + Assert.Equal(4, @class.Children.Count); + + Assert.IsType(@class.Children.Last()); + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper_WithIndexer() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .PropertyName("Tags") + .AsDictionaryAttribute("foo-", "System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var engine = CreateEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = engine, + }; + + var irDocument = CreateIRDocument(engine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(vcthFullName, Assert.IsType(tagHelper.Children[1]).TypeName); + Assert.IsType(tagHelper.Children[2]); + + var @class = FindClassNode(irDocument); + Assert.Equal(4, @class.Children.Count); + + Assert.IsType(@class.Children[3]); + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper_Nested() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper *, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("PTestTagHelper", "TestAssembly") + .TypeName("PTestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .PropertyName("Foo") + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .PropertyName("Foo") + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var engine = CreateEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = engine, + }; + + var irDocument = CreateIRDocument(engine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var outerTagHelper = FindTagHelperNode(irDocument); + Assert.Equal("PTestTagHelper", Assert.IsType(outerTagHelper.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(outerTagHelper.Children[2]).PropertyName); + + var vcth = FindTagHelperNode(outerTagHelper.Children[0]); + Assert.Equal(vcthFullName, Assert.IsType(vcth.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(vcth.Children[2]).PropertyName); + + + var @class = FindClassNode(irDocument); + Assert.Equal(5, @class.Children.Count); + + Assert.IsType(@class.Children.Last()); + } + + 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 MvcViewDocumentClassifierPass()); + + 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; + } + } + + // We also expect the default tag helper pass to run first. + var documentNode = codeDocument.GetDocumentIntermediateNode(); + + var defaultTagHelperPass = engine.Features.OfType().Single(); + defaultTagHelperPass.Execute(codeDocument, documentNode); + + return codeDocument.GetDocumentIntermediateNode(); + } + + private ClassDeclarationIntermediateNode FindClassNode(IntermediateNode node) + { + var visitor = new ClassDeclarationNodeVisitor(); + visitor.Visit(node); + return visitor.Node; + } + + private TagHelperIntermediateNode FindTagHelperNode(IntermediateNode node) + { + var visitor = new TagHelperNodeVisitor(); + visitor.Visit(node); + return visitor.Node; + } + + private class ClassDeclarationNodeVisitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode Node { get; set; } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + Node = node; + } + } + + private class TagHelperNodeVisitor : IntermediateNodeWalker + { + public TagHelperIntermediateNode Node { get; set; } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + Node = node; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperTargetExtensionTest.cs new file mode 100644 index 0000000000..2e3c476a36 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperTargetExtensionTest.cs @@ -0,0 +1,120 @@ +// 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.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + public class ViewComponentTagHelperTargetExtensionTest + { + [Fact] + public void WriteViewComponentTagHelper_GeneratesViewComponentTagHelper() + { + // Arrange + var tagHelper = TagHelperDescriptorBuilder + .Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("Foo")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build(); + + var extension = new ViewComponentTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new ViewComponentTagHelperIntermediateNode() + { + ClassName = "__Generated__TagCloudViewComponentTagHelper", + TagHelper = tagHelper + }; + + // Act + extension.WriteViewComponentTagHelper(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(""tagcloud"")] +public class __Generated__TagCloudViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TagCloudViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Int32 Foo { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync(""TagCloud"", new { Foo }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteViewComponentTagHelper_GeneratesViewComponentTagHelper_WithIndexer() + { + // Arrange + var tagHelper = TagHelperDescriptorBuilder + .Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .PropertyName("Tags") + .AsDictionaryAttribute("foo-", "System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build(); + + var extension = new ViewComponentTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new ViewComponentTagHelperIntermediateNode() + { + ClassName = "__Generated__TagCloudViewComponentTagHelper", + TagHelper = tagHelper + }; + + // Act + extension.WriteViewComponentTagHelper(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(""tagcloud"")] +public class __Generated__TagCloudViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TagCloudViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Collections.Generic.Dictionary Tags { get; set; } + = new System.Collections.Generic.Dictionary(); + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync(""TagCloud"", new { Tags }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTypeVisitorTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTypeVisitorTest.cs new file mode 100644 index 0000000000..96d879756c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTypeVisitorTest.cs @@ -0,0 +1,202 @@ +// 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.Reflection; +using Microsoft.CodeAnalysis; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X +{ + public class ViewComponentTypeVisitorTest + { + private static readonly Assembly _assembly = typeof(ViewComponentTypeVisitorTest).GetTypeInfo().Assembly; + + private static Compilation Compilation { get; } = TestCompilation.Create(_assembly); + + // In practice MVC will provide a marker attribute for ViewComponents. To prevent a circular reference between MVC and Razor + // we can use a test class as a marker. + private static INamedTypeSymbol TestViewComponentAttributeSymbol { get; } = Compilation.GetTypeByMetadataName(typeof(TestViewComponentAttribute).FullName); + private static INamedTypeSymbol TestNonViewComponentAttributeSymbol { get; } = Compilation.GetTypeByMetadataName(typeof(TestNonViewComponentAttribute).FullName); + + [Fact] + public void IsViewComponent_PlainViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_PlainViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_DecoratedViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_DecoratedVC).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_InheritedViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_InheritedVC).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_AbstractViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_AbstractViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_GenericViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_GenericViewComponent<>).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_InternalViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InternalViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_DecoratedNonViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_DecoratedViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_InheritedNonViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InheritedViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + public abstract class Invalid_AbstractViewComponent + { + } + + public class Invalid_GenericViewComponent + { + } + + internal class Invalid_InternalViewComponent + { + } + + public class Valid_PlainViewComponent + { + } + + [TestViewComponent] + public class Valid_DecoratedVC + { + } + + public class Valid_InheritedVC : Valid_DecoratedVC + { + } + + [TestNonViewComponent] + public class Invalid_DecoratedViewComponent + { + } + + [TestViewComponent] + public class Invalid_InheritedViewComponent : Invalid_DecoratedViewComponent + { + } + + public class TestViewComponentAttribute : Attribute + { + } + + public class TestNonViewComponentAttribute : Attribute + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/xunit.runner.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/xunit.runner.json new file mode 100644 index 0000000000..fcf172c8fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "methodDisplay": "method", + "shadowCopy": false +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/AssemblyAttributeInjectionPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/AssemblyAttributeInjectionPass.cs new file mode 100644 index 0000000000..021c61c368 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/AssemblyAttributeInjectionPass.cs @@ -0,0 +1,102 @@ +// 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.Diagnostics; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class AssemblyAttributeInjectionPass : IntermediateNodePassBase, IRazorOptimizationPass + { + private const string RazorViewAttribute = "global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute"; + private const string RazorPageAttribute = "global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute"; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.Options.DesignTime) + { + return; + } + + var @namespace = documentNode.FindPrimaryNamespace(); + if (@namespace == null || string.IsNullOrEmpty(@namespace.Content)) + { + // No namespace node or it's incomplete. Skip. + return; + } + + var @class = documentNode.FindPrimaryClass(); + if (@class == null || string.IsNullOrEmpty(@class.ClassName)) + { + // No class node or it's incomplete. Skip. + return; + } + + var generatedTypeName = $"{@namespace.Content}.{@class.ClassName}"; + + // The MVC attributes require a relative path to be specified so that we can make a view engine path. + // We can't use a rooted path because we don't know what the project root is. + // + // If we can't sanitize the path, we'll just set it to null and let is blow up at runtime - we don't + // want to create noise if this code has to run in some unanticipated scenario. + var escapedPath = MakeVerbatimStringLiteral(ConvertToViewEnginePath(codeDocument.Source.RelativePath)); + + string attribute; + if (documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind) + { + attribute = $"[assembly:{RazorViewAttribute}({escapedPath}, typeof({generatedTypeName}))]"; + } + else if (documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind && + PageDirective.TryGetPageDirective(documentNode, out var pageDirective)) + { + var escapedRoutePrefix = MakeVerbatimStringLiteral(pageDirective.RouteTemplate); + attribute = $"[assembly:{RazorPageAttribute}({escapedPath}, typeof({generatedTypeName}), {escapedRoutePrefix})]"; + } + else + { + return; + } + + var index = documentNode.Children.IndexOf(@namespace); + Debug.Assert(index >= 0); + + var pageAttribute = new CSharpCodeIntermediateNode(); + pageAttribute.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = attribute, + }); + + documentNode.Children.Insert(index, pageAttribute); + } + + private static string MakeVerbatimStringLiteral(string value) + { + if (value == null) + { + return "null"; + } + + value = value.Replace("\"", "\"\""); + return $"@\"{value}\""; + } + + private static string ConvertToViewEnginePath(string relativePath) + { + if (string.IsNullOrEmpty(relativePath)) + { + return null; + } + + // Checking for both / and \ because a \ will become a /. + if (!relativePath.StartsWith("/") && !relativePath.StartsWith("\\")) + { + relativePath = "/" + relativePath; + } + + relativePath = relativePath.Replace('\\', '/'); + return relativePath; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/CSharpIdentifier.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/CSharpIdentifier.cs new file mode 100644 index 0000000000..28e08063e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/CSharpIdentifier.cs @@ -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.Version2_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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ExtensionInitializer.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ExtensionInitializer.cs new file mode 100644 index 0000000000..03d05f7f9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ExtensionInitializer.cs @@ -0,0 +1,15 @@ +// 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; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + internal class ExtensionInitializer : RazorExtensionInitializer + { + public override void Initialize(RazorProjectEngineBuilder builder) + { + RazorExtensions.Register(builder); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/IInjectTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/IInjectTargetExtension.cs new file mode 100644 index 0000000000..c334e23c2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/IInjectTargetExtension.cs @@ -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.Version2_X +{ + public interface IInjectTargetExtension : ICodeTargetExtension + { + void WriteInjectProperty(CodeRenderingContext context, InjectIntermediateNode node); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/IViewComponentTagHelperTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/IViewComponentTagHelperTargetExtension.cs new file mode 100644 index 0000000000..f3e07a2b75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/IViewComponentTagHelperTargetExtension.cs @@ -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.Version2_X +{ + public interface IViewComponentTagHelperTargetExtension : ICodeTargetExtension + { + void WriteViewComponentTagHelper(CodeRenderingContext context, ViewComponentTagHelperIntermediateNode node); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectDirective.cs new file mode 100644 index 0000000000..9442aaf641 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectDirective.cs @@ -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.Version2_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(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("", "<" + 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 Directives { get; } = new List(); + + 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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectIntermediateNode.cs new file mode 100644 index 0000000000..4e3603f40d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectIntermediateNode.cs @@ -0,0 +1,58 @@ +// 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; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_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(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(); + if (extension == null) + { + ReportMissingCodeTargetExtension(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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectTargetExtension.cs new file mode 100644 index 0000000000..d2723ba99d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InjectTargetExtension.cs @@ -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.Version2_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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InstrumentationPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InstrumentationPass.cs new file mode 100644 index 0000000000..f82ed32e45 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/InstrumentationPass.cs @@ -0,0 +1,125 @@ +// 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.Globalization; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class InstrumentationPass : IntermediateNodePassBase, IRazorOptimizationPass + { + public override int Order => DefaultFeatureOrder; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.Options.DesignTime) + { + return; + } + + var walker = new Visitor(); + walker.VisitDocument(documentNode); + + for (var i = 0; i < walker.Items.Count; i++) + { + var node = walker.Items[i]; + + AddInstrumentation(node); + } + } + + private static void AddInstrumentation(InstrumentationItem item) + { + var beginContextMethodName = "BeginContext"; // ORIGINAL: BeginContextMethodName + var endContextMethodName = "EndContext"; // ORIGINAL: EndContextMethodName + + var beginNode = new CSharpCodeIntermediateNode(); + beginNode.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = string.Format("{0}({1}, {2}, {3});", + beginContextMethodName, + item.Source.AbsoluteIndex.ToString(CultureInfo.InvariantCulture), + item.Source.Length.ToString(CultureInfo.InvariantCulture), + item.IsLiteral ? "true" : "false") + }); + + var endNode = new CSharpCodeIntermediateNode(); + endNode.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = string.Format("{0}();", endContextMethodName) + }); + + var nodeIndex = item.Parent.Children.IndexOf(item.Node); + item.Parent.Children.Insert(nodeIndex, beginNode); + item.Parent.Children.Insert(nodeIndex + 2, endNode); + } + + private struct InstrumentationItem + { + public InstrumentationItem(IntermediateNode node, IntermediateNode parent, bool isLiteral, SourceSpan source) + { + Node = node; + Parent = parent; + IsLiteral = isLiteral; + Source = source; + } + + public IntermediateNode Node { get; } + + public IntermediateNode Parent { get; } + + public bool IsLiteral { get; } + + public SourceSpan Source { get; } + } + + private class Visitor : IntermediateNodeWalker + { + public List Items { get; } = new List(); + + public override void VisitHtml(HtmlContentIntermediateNode node) + { + if (node.Source != null) + { + Items.Add(new InstrumentationItem(node, Parent, isLiteral: true, source: node.Source.Value)); + } + + VisitDefault(node); + } + + public override void VisitCSharpExpression(CSharpExpressionIntermediateNode node) + { + if (node.Source != null) + { + Items.Add(new InstrumentationItem(node, Parent, isLiteral: false, source: node.Source.Value)); + } + + VisitDefault(node); + } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + if (node.Source != null) + { + Items.Add(new InstrumentationItem(node, Parent, isLiteral: false, source: node.Source.Value)); + } + + // Inside a tag helper we only want to visit inside of the body (skip all of the attributes and properties). + for (var i = 0; i < node.Children.Count; i++) + { + var child = node.Children[i]; + if (child is TagHelperBodyIntermediateNode || + child is DefaultTagHelperBodyIntermediateNode) + { + VisitDefault(child); + } + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.csproj new file mode 100644 index 0000000000..ce96dad3fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.csproj @@ -0,0 +1,21 @@ + + + + ASP.NET Core design time hosting infrastructure for the Razor view engine. + netstandard2.0 + $(PackageTags);aspnetcoremvc + false + + + + + Shared\CodeWriterExtensions.cs + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ModelDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ModelDirective.cs new file mode 100644 index 0000000000..cf80df5f68 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ModelDirective.cs @@ -0,0 +1,152 @@ +// 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.Version2_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; + } + } + + if (document.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind) + { + return visitor.Class.ClassName; + } + else + { + 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("", "<" + modelType + ">"); + visitor.Class.BaseType = baseType; + } + } + + private class Visitor : IntermediateNodeWalker + { + public NamespaceDeclarationIntermediateNode Namespace { get; private set; } + + public ClassDeclarationIntermediateNode Class { get; private set; } + + public IList ModelDirectives { get; } = new List(); + + 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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ModelExpressionPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ModelExpressionPass.cs new file mode 100644 index 0000000000..ef8e8fb181 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ModelExpressionPass.cs @@ -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.Version2_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 TagHelpers { get; } = new List(); + + 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); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/MvcImportProjectFeature.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..b5a5851922 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/MvcImportProjectFeature.cs @@ -0,0 +1,97 @@ +// 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.Version2_X +{ + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private const string ImportsFileName = "_ViewImports.cshtml"; + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + // Don't add MVC imports for a component - this shouldn't happen for v2, but just in case. + if (FileKinds.IsComponent(projectItem.FileKind)) + { + return Array.Empty(); + } + + var imports = new List(); + 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 imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List 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 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 +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/MvcViewDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/MvcViewDocumentClassifierPass.cs new file mode 100644 index 0000000000..7ec6a1360e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/MvcViewDocumentClassifierPass.cs @@ -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.Version2_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"; + @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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/NamespaceDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/NamespaceDirective.cs new file mode 100644 index 0000000000..de05d354b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/NamespaceDirective.cs @@ -0,0 +1,204 @@ +// 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.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public static class NamespaceDirective + { + private static readonly char[] Separators = new char[] { '\\', '/' }; + + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "namespace", + DirectiveKind.SingleLine, + builder => + { + builder.AddNamespaceToken( + Resources.NamespaceDirective_NamespaceToken_Name, + Resources.NamespaceDirective_NamespaceToken_Description); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.Description = Resources.NamespaceDirective_Description; + }); + + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + } + + // internal for testing + internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass + { + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.DocumentKind != RazorPageDocumentClassifierPass.RazorPageDocumentKind && + documentNode.DocumentKind != MvcViewDocumentClassifierPass.MvcViewDocumentKind) + { + // Not a page. Skip. + return; + } + + var visitor = new Visitor(); + visitor.Visit(documentNode); + + var directive = visitor.LastNamespaceDirective; + if (directive == null) + { + // No namespace set. Skip. + return; + } + + var @namespace = visitor.FirstNamespace; + if (@namespace == null) + { + // No namespace node. Skip. + return; + } + + @namespace.Content = GetNamespace(codeDocument.Source.FilePath, directive); + } + } + + // internal for testing. + // + // This code does a best-effort attempt to compute a namespace 'suffix' - the path difference between + // where the @namespace directive appears and where the current document is on disk. + // + // In the event that these two source either don't have FileNames set or don't follow a coherent hierarchy, + // we will just use the namespace verbatim. + internal static string GetNamespace(string source, DirectiveIntermediateNode directive) + { + var directiveSource = NormalizeDirectory(directive.Source?.FilePath); + + var baseNamespace = directive.Tokens.FirstOrDefault()?.Content; + if (string.IsNullOrEmpty(baseNamespace)) + { + // The namespace directive was incomplete. + return string.Empty; + } + + if (string.IsNullOrEmpty(source) || directiveSource == null) + { + // No sources, can't compute a suffix. + return baseNamespace; + } + + // We're specifically using OrdinalIgnoreCase here because Razor treats all paths as case-insensitive. + if (!source.StartsWith(directiveSource, StringComparison.OrdinalIgnoreCase) || + source.Length <= directiveSource.Length) + { + // The imports are not from the directory hierarchy, can't compute a suffix. + return baseNamespace; + } + + // OK so that this point we know that the 'imports' file containing this directive is in the directory + // hierarchy of this soure file. This is the case where we can append a suffix to the baseNamespace. + // + // Everything so far has just been defensiveness on our part. + + var builder = new StringBuilder(baseNamespace); + + var segments = source.Substring(directiveSource.Length).Split(Separators); + + // Skip the last segment because it's the FileName. + for (var i = 0; i < segments.Length - 1; i++) + { + builder.Append('.'); + builder.Append(CSharpIdentifier.SanitizeClassName(segments[i])); + } + + return builder.ToString(); + } + + // We want to normalize the path of the file containing the '@namespace' directive to just the containing + // directory with a trailing separator. + // + // Not using Path.GetDirectoryName here because it doesn't meet these requirements, and we want to handle + // both 'view engine' style paths and absolute paths. + // + // We also don't normalize the separators here. We expect that all documents are using a consistent style of path. + // + // If we can't normalize the path, we just return null so it will be ignored. + private static string NormalizeDirectory(string path) + { + if (string.IsNullOrEmpty(path)) + { + return null; + } + + var lastSeparator = path.LastIndexOfAny(Separators); + if (lastSeparator == -1) + { + return null; + } + + // Includes the separator + return path.Substring(0, lastSeparator + 1); + } + + private class Visitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode FirstClass { get; private set; } + + public NamespaceDeclarationIntermediateNode FirstNamespace { get; private set; } + + // We want the last one, so get them all and then . + public DirectiveIntermediateNode LastNamespaceDirective { get; private set; } + + public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node) + { + if (FirstNamespace == null) + { + FirstNamespace = node; + } + + base.VisitNamespaceDeclaration(node); + } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + if (FirstClass == null) + { + FirstClass = node; + } + + base.VisitClassDeclaration(node); + } + + public override void VisitDirective(DirectiveIntermediateNode node) + { + if (node.Directive == Directive) + { + LastNamespaceDirective = node; + } + + base.VisitDirective(node); + } + } + + #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(); + } + + builder.AddDirective(Directive); + builder.Features.Add(new Pass()); + } + #endregion + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/PageDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/PageDirective.cs new file mode 100644 index 0000000000..9b483f9b9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/PageDirective.cs @@ -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 System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class PageDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "page", + DirectiveKind.SingleLine, + builder => + { + builder.AddOptionalStringToken(Resources.PageDirective_RouteToken_Name, Resources.PageDirective_RouteToken_Description); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.Description = Resources.PageDirective_Description; + }); + + private PageDirective(string routeTemplate, IntermediateNode directiveNode) + { + RouteTemplate = routeTemplate; + DirectiveNode = directiveNode; + } + + public string RouteTemplate { get; } + + public IntermediateNode DirectiveNode { get; } + + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + return builder; + } + + public static bool TryGetPageDirective(DocumentIntermediateNode documentNode, out PageDirective pageDirective) + { + var visitor = new Visitor(); + for (var i = 0; i < documentNode.Children.Count; i++) + { + visitor.Visit(documentNode.Children[i]); + } + + if (visitor.DirectiveTokens == null) + { + pageDirective = null; + return false; + } + + var tokens = visitor.DirectiveTokens.ToList(); + string routeTemplate = null; + if (tokens.Count > 0) + { + routeTemplate = TrimQuotes(tokens[0].Content); + } + + pageDirective = new PageDirective(routeTemplate, visitor.DirectiveNode); + return true; + } + + private static string TrimQuotes(string content) + { + // Tokens aren't captured if they're malformed. Therefore, this method will + // always be called with a valid token content. + Debug.Assert(content.Length >= 2); + Debug.Assert(content.StartsWith("\"", StringComparison.Ordinal)); + Debug.Assert(content.EndsWith("\"", StringComparison.Ordinal)); + + return content.Substring(1, content.Length - 2); + } + + private class Visitor : IntermediateNodeWalker + { + public IntermediateNode DirectiveNode { get; private set; } + + public IEnumerable DirectiveTokens { get; private set; } + + public override void VisitDirective(DirectiveIntermediateNode node) + { + if (node.Directive == Directive) + { + DirectiveNode = node; + DirectiveTokens = node.Tokens; + } + } + + public override void VisitMalformedDirective(MalformedDirectiveIntermediateNode node) + { + if (DirectiveTokens == null && node.Directive == Directive) + { + DirectiveNode = node; + DirectiveTokens = node.Tokens; + } + } + } + + #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); + return builder; + } + #endregion + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/PagesPropertyInjectionPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/PagesPropertyInjectionPass.cs new file mode 100644 index 0000000000..4010c1903b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/PagesPropertyInjectionPass.cs @@ -0,0 +1,57 @@ +// 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; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class PagesPropertyInjectionPass : IntermediateNodePassBase, IRazorOptimizationPass + { + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.DocumentKind != RazorPageDocumentClassifierPass.RazorPageDocumentKind) + { + return; + } + + var modelType = ModelDirective.GetModelType(documentNode); + var visitor = new Visitor(); + visitor.Visit(documentNode); + + var @class = visitor.Class; + + var viewDataType = $"global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<{modelType}>"; + var vddProperty = new CSharpCodeIntermediateNode(); + vddProperty.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"public {viewDataType} ViewData => ({viewDataType})PageContext?.ViewData;", + }); + @class.Children.Add(vddProperty); + + var modelProperty = new CSharpCodeIntermediateNode(); + modelProperty.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"public {modelType} Model => ViewData.Model;", + }); + @class.Children.Add(modelProperty); + } + + private class Visitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode Class { get; private set; } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + if (Class == null) + { + Class = node; + } + + base.VisitClassDeclaration(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..a7a402e09a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Properties/AssemblyInfo.cs @@ -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 System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X; +using Microsoft.AspNetCore.Razor.Language; + +[assembly: ProvideRazorExtensionInitializer("MVC-2.0", typeof(ExtensionInitializer))] +[assembly: ProvideRazorExtensionInitializer("MVC-2.1", typeof(ExtensionInitializer))] + +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorExtensions.cs new file mode 100644 index 0000000000..afb0e896e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorExtensions.cs @@ -0,0 +1,53 @@ +// 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.Version2_X +{ + public static class RazorExtensions + { + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + FunctionsDirective.Register(builder); + InjectDirective.Register(builder); + ModelDirective.Register(builder); + NamespaceDirective.Register(builder); + PageDirective.Register(builder); + + InheritsDirective.Register(builder); + SectionDirective.Register(builder); + + builder.Features.Add(new DefaultTagHelperDescriptorProvider()); + builder.Features.Add(new ViewComponentTagHelperDescriptorProvider()); + + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); + builder.AddTargetExtension(new TemplateTargetExtension() + { + TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult", + }); + + builder.Features.Add(new ModelExpressionPass()); + builder.Features.Add(new PagesPropertyInjectionPass()); + builder.Features.Add(new ViewComponentTagHelperPass()); + builder.Features.Add(new RazorPageDocumentClassifierPass()); + builder.Features.Add(new MvcViewDocumentClassifierPass()); + builder.Features.Add(new AssemblyAttributeInjectionPass()); + builder.Features.Add(new InstrumentationPass()); + + builder.Features.Add(new MvcImportProjectFeature()); + + // The default C# language version for what this Razor configuration supports. + builder.SetCSharpLanguageVersion(LanguageVersion.CSharp7_3); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorExtensionsDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorExtensionsDiagnosticFactory.cs new file mode 100644 index 0000000000..05a01d38a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorExtensionsDiagnosticFactory.cs @@ -0,0 +1,131 @@ +// 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.Version2_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; + } + + internal static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3905", + () => Resources.PageDirectiveCannotBeImported, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_CannotBeImported(SourceSpan source) + { + var fileName = Path.GetFileName(source.FilePath); + var diagnostic = RazorDiagnostic.Create(PageDirective_CannotBeImported, source, PageDirective.Directive.Directive, fileName); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor PageDirective_MustExistAtTheTopOfFile = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3906", + () => Resources.PageDirectiveMustExistAtTheTopOfFile, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_MustExistAtTheTopOfFile(SourceSpan source) + { + var fileName = Path.GetFileName(source.FilePath); + var diagnostic = RazorDiagnostic.Create(PageDirective_MustExistAtTheTopOfFile, source, PageDirective.Directive.Directive); + + return diagnostic; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorPageDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorPageDocumentClassifierPass.cs new file mode 100644 index 0000000000..b11912ff81 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/RazorPageDocumentClassifierPass.cs @@ -0,0 +1,164 @@ +// 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.Diagnostics; +using System.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class RazorPageDocumentClassifierPass : DocumentClassifierPassBase + { + public static readonly string RazorPageDocumentKind = "mvc.1.0.razor-page"; + public static readonly string RouteTemplateKey = "RouteTemplate"; + + private static readonly RazorProjectEngine LeadingDirectiveParsingEngine = RazorProjectEngine.Create( + RazorConfiguration.Create(RazorLanguageVersion.Version_2_1, "leading-directive-parser", Array.Empty()), + RazorProjectFileSystem.Create("/"), + builder => + { + for (var i = builder.Phases.Count - 1; i >= 0; i--) + { + var phase = builder.Phases[i]; + builder.Phases.RemoveAt(i); + if (phase is IRazorDocumentClassifierPhase) + { + break; + } + } + + RazorExtensions.Register(builder); + builder.Features.Add(new LeadingDirectiveParserOptionsFeature()); + }); + + protected override string DocumentKind => RazorPageDocumentKind; + + protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + return PageDirective.TryGetPageDirective(documentNode, out var pageDirective); + } + + protected override void OnDocumentStructureCreated( + RazorCodeDocument codeDocument, + NamespaceDeclarationIntermediateNode @namespace, + ClassDeclarationIntermediateNode @class, + MethodDeclarationIntermediateNode method) + { + base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); + + @namespace.Content = "AspNetCore"; + + @class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page"; + + 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.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}"; + + var document = codeDocument.GetDocumentIntermediateNode(); + PageDirective.TryGetPageDirective(document, out var pageDirective); + + EnsureValidPageDirective(codeDocument, pageDirective); + + AddRouteTemplateMetadataAttribute(@namespace, @class, pageDirective); + } + + private static void AddRouteTemplateMetadataAttribute(NamespaceDeclarationIntermediateNode @namespace, ClassDeclarationIntermediateNode @class, PageDirective pageDirective) + { + if (string.IsNullOrEmpty(pageDirective.RouteTemplate)) + { + return; + } + + var classIndex = @namespace.Children.IndexOf(@class); + if (classIndex == -1) + { + return; + } + + var metadataAttributeNode = new RazorCompiledItemMetadataAttributeIntermediateNode + { + Key = RouteTemplateKey, + Value = pageDirective.RouteTemplate, + }; + // Metadata attributes need to be inserted right before the class declaration. + @namespace.Children.Insert(classIndex, metadataAttributeNode); + } + + private void EnsureValidPageDirective(RazorCodeDocument codeDocument, PageDirective pageDirective) + { + Debug.Assert(pageDirective != null); + + if (pageDirective.DirectiveNode.IsImported()) + { + pageDirective.DirectiveNode.Diagnostics.Add( + RazorExtensionsDiagnosticFactory.CreatePageDirective_CannotBeImported(pageDirective.DirectiveNode.Source.Value)); + } + else + { + // The document contains a page directive and it is not imported. + // We now want to make sure this page directive exists at the top of the file. + // We are going to do that by re-parsing the document until the very first line that is not Razor comment + // or whitespace. We then make sure the page directive still exists in the re-parsed IR tree. + var leadingDirectiveCodeDocument = RazorCodeDocument.Create(codeDocument.Source); + LeadingDirectiveParsingEngine.Engine.Process(leadingDirectiveCodeDocument); + + var leadingDirectiveDocumentNode = leadingDirectiveCodeDocument.GetDocumentIntermediateNode(); + if (!PageDirective.TryGetPageDirective(leadingDirectiveDocumentNode, out var _)) + { + // The page directive is not the leading directive. Add an error. + pageDirective.DirectiveNode.Diagnostics.Add( + RazorExtensionsDiagnosticFactory.CreatePageDirective_MustExistAtTheTopOfFile(pageDirective.DirectiveNode.Source.Value)); + } + } + } + + private class LeadingDirectiveParserOptionsFeature : RazorEngineFeatureBase, IConfigureRazorParserOptionsFeature + { + public int Order { get; } + + public void Configure(RazorParserOptionsBuilder options) + { + options.ParseLeadingDirectives = true; + } + } + + 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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Resources.resx new file mode 100644 index 0000000000..474537197e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/Resources.resx @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Value cannot be null or empty. + + + Inject a service from the application's service container into a property. + + + The name of the property. + + + PropertyName + + + The type of the service to inject. + + + TypeName + + + Specify the view or page model for the page. + + + The model type. + + + TypeName + + + The 'inherits' keyword is not allowed when a '{0}' keyword is used. + + + A property name must be specified when using the '{0}' statement. Format for a '{0}' statement is '@{0} <Type Name> <Property Name>'. + + + The '{0}' keyword must be followed by a type name on the same line. + + + Only one '{0}' statement is allowed in a file. + + + Invalid tag helper property '{0}.{1}'. Dictionary values must not be of type '{2}'. + + + Specify the base namespace for the page. + + + The namespace for the page. + + + Namespace + + + The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor cshtml file. + + + The '@{0}' directive must precede all other elements defined in a Razor file. + + + Mark the page as a Razor Page. + + + An optional route template for the page. + + + RouteTemplate + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/TagHelperDescriptorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/TagHelperDescriptorExtensions.cs new file mode 100644 index 0000000000..b7bd72ec70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/TagHelperDescriptorExtensions.cs @@ -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.Version2_X +{ + public static class TagHelperDescriptorExtensions + { + /// + /// Indicates whether a represents a view component. + /// + /// The to check. + /// Whether a represents a view component. + 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; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentResources.resx new file mode 100644 index 0000000000..d6aad4ff3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentResources.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + View component '{0}' must have exactly one public method named '{1}' or '{2}'. + + + Method '{0}' of view component '{1}' should be declared to return {2}&lt;T&gt;. + + + Could not find an '{0}' or '{1}' method for the view component '{2}'. + + + Method '{0}' of view component '{1}' cannot return a {2}. + + + Method '{0}' of view component '{1}' should be declared to return a value. + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperConventions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperConventions.cs new file mode 100644 index 0000000000..30e8d1c36f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperConventions.cs @@ -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.Version2_X +{ + public static class ViewComponentTagHelperConventions + { + public static readonly string Kind = "MVC.ViewComponent"; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs new file mode 100644 index 0000000000..ef989c3f7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs @@ -0,0 +1,284 @@ +// 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.Version2_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 PrimitiveDisplayTypeNameLookups = new Dictionary(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 = GetInvokeMethods(type); + + if (methods.Count == 0) + { + diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_CannotFindMethod(type.ToDisplayString(FullNameTypeDisplayFormat)); + method = null; + return false; + } + else if (methods.Count > 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. + 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. + 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 static IReadOnlyList GetInvokeMethods(INamedTypeSymbol type) + { + var methods = new List(); + while (type != null) + { + var currentTypeMethods = type.GetMembers() + .OfType() + .Where(m => + m.DeclaredAccessibility == Accessibility.Public && + !m.IsStatic && + (string.Equals(m.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal) || + string.Equals(m.Name, ViewComponentTypes.SyncMethodName, StringComparison.Ordinal))); + + methods.AddRange(currentTypeMethods); + + type = type.BaseType; + } + + return methods; + } + + private void AddRequiredAttributes(ImmutableArray 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 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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..4806acc806 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorProvider.cs @@ -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.Version2_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(); + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperIntermediateNode.cs new file mode 100644 index 0000000000..a42b88416b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperIntermediateNode.cs @@ -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.Version2_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(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(); + if (extension == null) + { + ReportMissingCodeTargetExtension(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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperMetadata.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperMetadata.cs new file mode 100644 index 0000000000..ad77c7a29e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperMetadata.cs @@ -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.Version2_X +{ + public static class ViewComponentTagHelperMetadata + { + /// + /// The key in a containing + /// the short name of a view component. + /// + public static readonly string Name = "MVC.ViewComponent.Name"; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperPass.cs new file mode 100644 index 0000000000..f5c37eb13b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperPass.cs @@ -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.Version2_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(); + 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 _tagHelpers; + + public Context(NamespaceDeclarationIntermediateNode @namespace, ClassDeclarationIntermediateNode @class) + { + Namespace = @namespace; + Class = @class; + + _tagHelpers = new Dictionary(); + } + + public ClassDeclarationIntermediateNode Class { get; } + + public NamespaceDeclarationIntermediateNode Namespace { get; } + + + public IEnumerable 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"; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperTargetExtension.cs new file mode 100644 index 0000000000..a56e86fdca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperTargetExtension.cs @@ -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.Version2_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() + { + { 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(")]"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs new file mode 100644 index 0000000000..1d7463884c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs @@ -0,0 +1,88 @@ +// 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 Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + internal class ViewComponentTypeVisitor : SymbolVisitor + { + private readonly INamedTypeSymbol _viewComponentAttribute; + private readonly INamedTypeSymbol _nonViewComponentAttribute; + private readonly List _results; + + public ViewComponentTypeVisitor( + INamedTypeSymbol viewComponentAttribute, + INamedTypeSymbol nonViewComponentAttribute, + List 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 (_viewComponentAttribute == null) + { + return false; + } + + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypes.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypes.cs new file mode 100644 index 0000000000..cd7e2771be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypes.cs @@ -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.Version2_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"; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/baseline.netcore.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/baseline.netcore.json new file mode 100644 index 0000000000..87b3d074f3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/baseline.netcore.json @@ -0,0 +1,1180 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.AssemblyAttributeInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IInjectTargetExtension", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.CodeGeneration.ICodeTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectIntermediateNode", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.Intermediate.ExtensionIntermediateNode", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_TypeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TypeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MemberName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MemberName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Children", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Accept", + "Parameters": [ + { + "Name": "visitor", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeVisitor" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteNode", + "Parameters": [ + { + "Name": "target", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeTarget" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectTargetExtension", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IInjectTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IInjectTargetExtension", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InstrumentationPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IViewComponentTagHelperTargetExtension", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.CodeGeneration.ICodeTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteViewComponentTagHelper", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperIntermediateNode" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ModelDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetModelType", + "Parameters": [ + { + "Name": "document", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ModelExpressionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.MvcViewDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MvcViewDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.NamespaceDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.PageDirective", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RouteTemplate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DirectiveNode", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNode", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryGetPageDirective", + "Parameters": [ + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + }, + { + "Name": "pageDirective", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.PageDirective", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.PagesPropertyInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.RazorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.RazorPageDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RazorPageDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RouteTemplateKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.TagHelperDescriptorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "IsViewComponentKind", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetViewComponentName", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.String", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperConventions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Kind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperDescriptorProvider", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Order", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperIntermediateNode", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.Intermediate.ExtensionIntermediateNode", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Children", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClassName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClassName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelper", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelper", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Accept", + "Parameters": [ + { + "Name": "visitor", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeVisitor" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteNode", + "Parameters": [ + { + "Name": "target", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeTarget" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperMetadata", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriterExtensions+CSharpCodeWritingScope", + "Visibility": "Public", + "Kind": "Struct", + "Sealed": true, + "ImplementedInterfaces": [ + "System.IDisposable" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Dispose", + "Parameters": [], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "System.IDisposable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "writer", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter" + }, + { + "Name": "tabSize", + "Type": "System.Int32", + "DefaultValue": "4" + }, + { + "Name": "autoSpace", + "Type": "System.Boolean", + "DefaultValue": "True" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTypes+ViewComponent", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Name\"" + } + ], + "GenericParameters": [] + } + ] +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/baseline.netframework.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/baseline.netframework.json new file mode 100644 index 0000000000..9386496226 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/baseline.netframework.json @@ -0,0 +1,982 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.AssemblyAttributeInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IInjectTargetExtension", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.CodeGeneration.ICodeTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectIntermediateNode", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.Intermediate.ExtensionIntermediateNode", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_TypeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TypeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MemberName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MemberName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Children", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Accept", + "Parameters": [ + { + "Name": "visitor", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeVisitor" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteNode", + "Parameters": [ + { + "Name": "target", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeTarget" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectTargetExtension", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IInjectTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IInjectTargetExtension", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.InstrumentationPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ModelDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetModelType", + "Parameters": [ + { + "Name": "document", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ModelExpressionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.MvcViewDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MvcViewDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.NamespaceDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.PageDirective", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RouteTemplate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DirectiveNode", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNode", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryGetPageDirective", + "Parameters": [ + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + }, + { + "Name": "pageDirective", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.PageDirective", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.PagesPropertyInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.RazorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.RazorPageDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RazorPageDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.TagHelperDescriptorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "IsViewComponentKind", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetViewComponentName", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.String", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperConventions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Kind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperDescriptorProvider", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Order", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperMetadata", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTagHelperPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriterExtensions+CSharpCodeWritingScope", + "Visibility": "Public", + "Kind": "Struct", + "Sealed": true, + "ImplementedInterfaces": [ + "System.IDisposable" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Dispose", + "Parameters": [], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "System.IDisposable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "writer", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter" + }, + { + "Name": "tabSize", + "Type": "System.Int32", + "DefaultValue": "4" + }, + { + "Name": "autoSpace", + "Type": "System.Boolean", + "DefaultValue": "True" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.ViewComponentTypes+ViewComponent", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Name\"" + } + ], + "GenericParameters": [] + } + ] +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs new file mode 100644 index 0000000000..29127a5cd3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/AssemblyAttributeInjectionPassTest.cs @@ -0,0 +1,446 @@ +// 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.Version2_X +{ + public class AssemblyAttributeInjectionPassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_2_1; + + [Fact] + public void Execute_NoOps_IfNamespaceNodeIsMissing() + { + // Arrange + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); + + // Assert + Assert.Empty(irDocument.Children); + } + + [Fact] + public void Execute_NoOps_IfNamespaceNodeHasEmptyContent() + { + // Arrange + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = string.Empty }; + @namespace.Annotations[CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace; + builder.Push(@namespace); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); + + // Assert + Assert.Collection(irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_NoOps_IfClassNameNodeIsMissing() + { + // Arrange + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; + builder.Push(@namespace); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); + + // Assert + Assert.Collection( + irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_NoOps_IfClassNameIsEmpty() + { + // Arrange + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); + + // Assert + Assert.Collection(irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_NoOps_IfDocumentIsNotViewOrPage() + { + // Arrange + var irDocument = new DocumentIntermediateNode + { + DocumentKind = "Default", + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "SomeNamespace" }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument); + + // Assert + Assert.Collection( + irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_NoOps_ForDesignTime() + { + // Arrange + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection( + irDocument.Children, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_AddsRazorViewAttribute_ToViews() + { + // Arrange + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/Views/Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection(irDocument.Children, + node => + { + var csharpCode = Assert.IsType(node); + var token = Assert.IsType(Assert.Single(csharpCode.Children)); + Assert.Equal(TokenKind.CSharp, token.Kind); + Assert.Equal(expectedAttribute, token.Content); + }, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_EscapesViewPathWhenAddingAttributeToViews() + { + // Arrange + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "\\test\\\"Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection(irDocument.Children, + node => + { + var csharpCode = Assert.IsType(node); + var token = Assert.IsType(Assert.Single(csharpCode.Children)); + Assert.Equal(TokenKind.CSharp, token.Kind); + Assert.Equal(expectedAttribute, token.Content); + }, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_AddsRazorPagettribute_ToPage() + { + // Arrange + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@\"/Views/Index.cshtml\", typeof(SomeNamespace.SomeName), null)]"; + var irDocument = new DocumentIntermediateNode + { + DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var pageDirective = new DirectiveIntermediateNode + { + Directive = PageDirective.Directive, + }; + builder.Add(pageDirective); + + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection(irDocument.Children, + node => Assert.Same(pageDirective, node), + node => + { + var csharpCode = Assert.IsType(node); + var token = Assert.IsType(Assert.Single(csharpCode.Children)); + Assert.Equal(TokenKind.CSharp, token.Kind); + Assert.Equal(expectedAttribute, token.Content); + }, + node => Assert.Same(@namespace, node)); + } + + [Fact] + public void Execute_EscapesViewPathAndRouteWhenAddingAttributeToPage() + { + // Arrange + var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; + var irDocument = new DocumentIntermediateNode + { + DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Content = "SomeNamespace", + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + ClassName = "SomeName", + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + + builder.Add(@class); + + var pass = new AssemblyAttributeInjectionPass + { + Engine = CreateProjectEngine().Engine, + }; + + var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "test\\\"Index.cshtml")); + var document = RazorCodeDocument.Create(source); + + // Act + pass.Execute(document, irDocument); + + // Assert + Assert.Collection(irDocument.Children, + node => + { + var csharpCode = Assert.IsType(node); + var token = Assert.IsType(Assert.Single(csharpCode.Children)); + Assert.Equal(TokenKind.CSharp, token.Kind); + Assert.Equal(expectedAttribute, token.Content); + }, + node => Assert.Same(@namespace, node)); + } + + 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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs new file mode 100644 index 0000000000..ff128921c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectDirectiveTest.cs @@ -0,0 +1,225 @@ +// 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.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_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(@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(@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 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(@class.Children[1]); + Assert.Equal("PropertyType", node.TypeName); + Assert.Equal("PropertyName", node.MemberName); + } + + [Fact] + public void InjectDirectivePass_Execute_ExpandsTModel_WithModelTypeFirst() + { + // Arrange + var codeDocument = CreateDocument(@" +@model ModelType +@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(@class.Children[1]); + Assert.Equal("PropertyType", node.TypeName); + Assert.Equal("PropertyName", node.MemberName); + } + + [Fact] + public void InjectDirectivePass_Execute_ExpandsTModel_WithModelType() + { + // Arrange + var codeDocument = CreateDocument(@" +@inject PropertyType 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(@class.Children[1]); + Assert.Equal("PropertyType", 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() + { + return RazorProjectEngine.Create(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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectTargetExtensionTest.cs new file mode 100644 index 0000000000..53e7debcf7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InjectTargetExtensionTest.cs @@ -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.Version2_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", + 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 PropertyName { get; private set; }" + Environment.NewLine + Environment.NewLine + + "#line default" + Environment.NewLine + + "#line hidden" + Environment.NewLine + + "#nullable disable" + Environment.NewLine, + context.CodeWriter.GenerateCode()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InstrumentationPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InstrumentationPassTest.cs new file mode 100644 index 0000000000..e1bd402e26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/InstrumentationPassTest.cs @@ -0,0 +1,348 @@ +// 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; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class InstrumentationPassTest + { + [Fact] + public void InstrumentationPass_NoOps_ForDesignTime() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDesignTimeDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new HtmlContentIntermediateNode()); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.Html, + }); + builder.Pop(); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => IntermediateNodeAssert.Html("Hi", n)); + } + + [Fact] + public void InstrumentationPass_InstrumentsHtml() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + + builder.Push(new HtmlContentIntermediateNode() + { + Source = CreateSource(1), + }); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.Html, + Source = CreateSource(1) + }); + builder.Pop(); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => BeginInstrumentation("1, 1, true", n), + n => IntermediateNodeAssert.Html("Hi", n), + n => EndInstrumentation(n)); + } + + [Fact] + public void InstrumentationPass_SkipsHtml_WithoutLocation() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new HtmlContentIntermediateNode()); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.Html, + }); + builder.Pop(); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => IntermediateNodeAssert.Html("Hi", n)); + } + + [Fact] + public void InstrumentationPass_InstrumentsCSharpExpression() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new CSharpExpressionIntermediateNode() + { + Source = CreateSource(2), + }); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.CSharp, + }); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => BeginInstrumentation("2, 2, false", n), + n => CSharpExpression("Hi", n), + n => EndInstrumentation(n)); + } + + [Fact] + public void InstrumentationPass_SkipsCSharpExpression_WithoutLocation() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new CSharpExpressionIntermediateNode()); + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.CSharp, + }); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => CSharpExpression("Hi", n)); + } + + [Fact] + public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperAttribute() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new TagHelperIntermediateNode()); + + builder.Push(new TagHelperHtmlAttributeIntermediateNode()); + + builder.Push(new CSharpExpressionIntermediateNode() + { + Source = CreateSource(5) + }); + + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.CSharp, + }); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => + { + Assert.IsType(n); + Children( + n, + c => + { + Assert.IsType(c); + Children( + c, + s => CSharpExpression("Hi", s)); + }); + }); + } + + [Fact] + public void InstrumentationPass_SkipsCSharpExpression_InsideTagHelperProperty() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new TagHelperIntermediateNode()); + + builder.Push(new TagHelperPropertyIntermediateNode()); + + builder.Push(new CSharpExpressionIntermediateNode() + { + Source = CreateSource(5) + }); + + builder.Add(new IntermediateToken() + { + Content = "Hi", + Kind = TokenKind.CSharp, + }); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => + { + Assert.IsType(n); + Children( + n, + c => + { + Assert.IsType(c); + Children( + c, + s => CSharpExpression("Hi", s)); + }); + }); + } + + [Fact] + public void InstrumentationPass_InstrumentsTagHelper() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Add(new TagHelperIntermediateNode() + { + Source = CreateSource(3), + }); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => BeginInstrumentation("3, 3, false", n), + n => Assert.IsType(n), + n => EndInstrumentation(n)); + } + + [Fact] + public void InstrumentationPass_SkipsTagHelper_WithoutLocation() + { + // Arrange + var document = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(new TagHelperIntermediateNode()); + + var pass = new InstrumentationPass() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), document); + + // Assert + Children( + document, + n => Assert.IsType(n)); + } + + private SourceSpan CreateSource(int number) + { + // The actual source span doesn't really matter, we just want to see the values used. + return new SourceSpan(new SourceLocation(number, number, number), number); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/IntegrationTests/CodeGenerationIntegrationTest.cs new file mode 100644 index 0000000000..367b72d260 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -0,0 +1,961 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_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_2_0, + "MVC-2.1", + new[] { new AssemblyExtension("MVC-2.1", typeof(ExtensionInitializer).Assembly) }); + } + + protected override CSharpCompilation BaseCompilation => DefaultBaseCompilation; + + protected override RazorConfiguration Configuration { get; } + + #region Runtime + + [Fact] + public void UsingDirectives_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false, throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + + var diagnostics = compiled.Compilation.GetDiagnostics().Where(d => d.Severity >= DiagnosticSeverity.Warning); + Assert.Equal("The using directive for 'System' appeared previously in this namespace", Assert.Single(diagnostics).GetMessage()); + } + + [Fact] + public void InvalidNamespaceAtEOF_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ1014", Assert.Single(diagnotics).Id); + } + + [Fact] + public void IncompleteDirectives_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyService +{ + public string Html { get; set; } +}"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + + // We expect this test to generate a bunch of errors. + Assert.True(compiled.CodeDocument.GetCSharpDocument().Diagnostics.Count > 0); + } + + [Fact] + public void InheritsViewModel_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Razor; + +public class MyBasePageForViews : RazorPage +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} +public class MyModel +{ + +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void InheritsWithViewImports_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.RazorPages; + +public abstract class MyPageModel : Page +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} + +public class MyModel +{ + +}"); + AddProjectItemFromText(@"@inherits MyPageModel"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void MalformedPageDirective_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ1016", Assert.Single(diagnotics).Id); + } + + [Fact] + public void Basic_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void Sections_Runtime() + { + // 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: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void _ViewImports_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void Inject_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyApp +{ + public string MyProperty { get; set; } +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void InjectWithModel_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyModel +{ + +} + +public class MyService +{ + public string Html { get; set; } +} + +public class MyApp +{ + public string MyProperty { get; set; } +}"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void InjectWithSemicolon_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyModel +{ + +} + +public class MyApp +{ + public string MyProperty { get; set; } +} + +public class MyService +{ + public string Html { get; set; } +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void Model_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void ModelExpressionTagHelper_Runtime() + { + // 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: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void RazorPages_Runtime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void RazorPagesWithRouteTemplate_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void RazorPagesWithoutModel_Runtime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void PageWithNamespace_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void ViewWithNamespace_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void ViewComponentTagHelper_Runtime() + { + // 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: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + } + + [Fact] + public void RazorPageWithNoLeadingPageDirective_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ3906", Assert.Single(diagnotics).Id); + } + #endregion + + #region DesignTime + + [Fact] + public void UsingDirectives_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true, throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + + var diagnostics = compiled.Compilation.GetDiagnostics().Where(d => d.Severity >= DiagnosticSeverity.Warning); + Assert.Equal("The using directive for 'System' appeared previously in this namespace", Assert.Single(diagnostics).GetMessage()); + } + + [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("RZ1014", Assert.Single(diagnotics).Id); + } + + [Fact] + public void IncompleteDirectives_DesignTime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyService +{ + 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 : 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.RazorPages; + +public abstract class MyPageModel : Page +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} + +public class MyModel +{ + +}"); + + AddProjectItemFromText(@"@inherits MyPageModel"); + + 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 MalformedPageDirective_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("RZ1016", Assert.Single(diagnotics).Id); + } + + [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 +{ + 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 +{ + 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 RazorPages_DesignTime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + 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 RazorPagesWithRouteTemplate_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 RazorPagesWithoutModel_DesignTime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + 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 PageWithNamespace_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 ViewWithNamespace_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 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); + } + + [Fact] + public void RazorPageWithNoLeadingPageDirective_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("RZ3906", Assert.Single(diagnotics).Id); + } + + #endregion + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/IntegrationTests/InstrumentationPassIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/IntegrationTests/InstrumentationPassIntegrationTest.cs new file mode 100644 index 0000000000..58d6a46df0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/IntegrationTests/InstrumentationPassIntegrationTest.cs @@ -0,0 +1,108 @@ +// 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.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.IntegrationTests +{ + public class InstrumentationPassIntegrationTest : IntegrationTestBase + { + private readonly static CSharpCompilation DefaultBaseCompilation = MvcShim.BaseCompilation.WithAssemblyName("AppCode"); + + public InstrumentationPassIntegrationTest() + : base(generateBaselines: null) + { + Configuration = RazorConfiguration.Create( + RazorLanguageVersion.Version_2_0, + "MVC-2.1", + new[] { new AssemblyExtension("MVC-2.1", typeof(ExtensionInitializer).Assembly) }); + } + + protected override CSharpCompilation BaseCompilation => DefaultBaseCompilation; + + protected override RazorConfiguration Configuration { get; } + + [Fact] + public void BasicTest() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "p", + typeName: "PTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "form", + typeName: "FormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("value") + .PropertyName("FooProp") + .TypeName("System.String"), // Gets preallocated + builder => builder + .Name("date") + .PropertyName("BarProp") + .TypeName("System.DateTime"), // Doesn't get preallocated + }) + }; + + var engine = CreateProjectEngine(b => + { + b.AddTagHelpers(descriptors); + b.Features.Add(new InstrumentationPass()); + + // This test includes templates + b.AddTargetExtension(new TemplateTargetExtension()); + }); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var document = engine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(document.GetDocumentIntermediateNode()); + + var csharpDocument = document.GetCSharpDocument(); + AssertCSharpDocumentMatchesBaseline(csharpDocument); + Assert.Empty(csharpDocument.Diagnostics); + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BoundAttributeDescriptor(attributeBuilder); + } + } + + builder.TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + + var descriptor = builder.Build(); + + return descriptor; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj new file mode 100644 index 0000000000..35ed6aa142 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Test.csproj @@ -0,0 +1,39 @@ + + + + $(StandardTestTfms) + true + $(DefaultItemExcludes);TestFiles\** + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs new file mode 100644 index 0000000000..d01195906b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelDirectiveTest.cs @@ -0,0 +1,343 @@ +// 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.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.Version2_X +{ + public class ModelDirectiveTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_2_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 +@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_DifferentOrdering() + { + // Arrange + var codeDocument = CreateDocument(@" +@model Type1 +@inherits BaseType +@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", @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 +"); + + 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_DesignTime_AddsTModelUsingDirective() + { + // Arrange + var codeDocument = CreateDocument(@" +@inherits BaseType +"); + + 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", @class.BaseType); + + var @namespace = FindNamespaceNode(irDocument); + var usingNode = Assert.IsType(@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 +@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", @class.BaseType); + + var @namespace = FindNamespaceNode(irDocument); + var usingNode = Assert.IsType(@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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs new file mode 100644 index 0000000000..d18984c900 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ModelExpressionPassTest.cs @@ -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.Version2_X +{ + public class ModelExpressionPassTest + { + [Fact] + public void ModelExpressionPass_NonModelExpressionProperty_Ignored() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +

"); + + 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().Single(); + + var token = Assert.IsType(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

"); + + 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().Single(); + + var expression = Assert.IsType(Assert.Single(setProperty.Children)); + Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Bar)", GetCSharpContent(expression)); + + var originalNode = Assert.IsType(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

"); + + 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().Single(); + + var expression = Assert.IsType(Assert.Single(setProperty.Children)); + Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => Bar)", GetCSharpContent(expression)); + + var originalNode = Assert.IsType(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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcImportProjectFeatureTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..13c686adf9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcImportProjectFeatureTest.cs @@ -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.Version2_X +{ + public class MvcImportProjectFeatureTest + { + [Fact] + public void AddDefaultDirectivesImport_AddsSingleDynamicImport() + { + // Arrange + var imports = new List(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + 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(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(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(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)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcShim.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcShim.cs new file mode 100644 index 0000000000..acbdea28f3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcShim.cs @@ -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.Version2_X +{ + internal static class MvcShim + { + public static readonly string AssemblyName = "Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs new file mode 100644 index 0000000000..455ed1ba21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/MvcViewDocumentClassifierPassTest.cs @@ -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.Version2_X +{ + public class MvcViewDocumentClassifierPassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_2_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", 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", 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 projectEngine, RazorCodeDocument codeDocument) + { + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs new file mode 100644 index 0000000000..8e5d76c678 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/NamespaceDirectiveTest.cs @@ -0,0 +1,352 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class NamespaceDirectiveTest + { + [Fact] + public void GetNamespace_IncompleteDirective_UsesEmptyNamespace() + { + // Arrange + var source = "c:\\foo\\bar\\bleh.cshtml"; + var imports = "c:\\foo\\baz\\bleh.cshtml"; + var node = new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan(imports, 0, 0, 0, 0), + }; + + // Act + var @namespace = NamespaceDirective.GetNamespace(source, node); + + // Assert + Assert.Equal(string.Empty, @namespace); + } + + [Fact] + public void GetNamespace_EmptyDirective_UsesEmptyNamespace() + { + // Arrange + var source = "c:\\foo\\bar\\bleh.cshtml"; + var imports = "c:\\foo\\baz\\bleh.cshtml"; + var node = new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan(imports, 0, 0, 0, 0), + }; + node.Children.Add(new DirectiveTokenIntermediateNode() { Content = string.Empty }); + + // Act + var @namespace = NamespaceDirective.GetNamespace(source, node); + + // Assert + Assert.Equal(string.Empty, @namespace); + } + + // When we don't have a relationship between the source file and the imports file + // we will just use the namespace on the node directly. + [Theory] + [InlineData((string)null, (string)null)] + [InlineData("", "")] + [InlineData(null, "/foo/bar")] + [InlineData("/foo/baz", "/foo/bar/bleh")] + [InlineData("/foo.cshtml", "/foo/bar.cshtml")] + [InlineData("c:\\foo.cshtml", "d:\\foo\\bar.cshtml")] + [InlineData("c:\\foo\\bar\\bleh.cshtml", "c:\\foo\\baz\\bleh.cshtml")] + public void GetNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim(string source, string imports) + { + // Arrange + var node = new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan(imports, 0, 0, 0, 0), + }; + + node.Children.Add(new DirectiveTokenIntermediateNode() { Content = "Base" }); + + // Act + var @namespace = NamespaceDirective.GetNamespace(source, node); + + // Assert + Assert.Equal("Base", @namespace); + } + + [Theory] + [InlineData("/foo.cshtml", "/_ViewImports.cshtml", "Base")] + [InlineData("/foo/bar.cshtml", "/_ViewImports.cshtml", "Base.foo")] + [InlineData("/foo/bar/baz.cshtml", "/_ViewImports.cshtml", "Base.foo.bar")] + [InlineData("/foo/bar/baz.cshtml", "/foo/_ViewImports.cshtml", "Base.bar")] + [InlineData("/Foo/bar/baz.cshtml", "/foo/_ViewImports.cshtml", "Base.bar")] + [InlineData("c:\\foo.cshtml", "c:\\_ViewImports.cshtml", "Base")] + [InlineData("c:\\foo\\bar.cshtml", "c:\\_ViewImports.cshtml", "Base.foo")] + [InlineData("c:\\foo\\bar\\baz.cshtml", "c:\\_ViewImports.cshtml", "Base.foo.bar")] + [InlineData("c:\\foo\\bar\\baz.cshtml", "c:\\foo\\_ViewImports.cshtml", "Base.bar")] + [InlineData("c:\\Foo\\bar\\baz.cshtml", "c:\\foo\\_ViewImports.cshtml", "Base.bar")] + public void GetNamespace_ForRelatedFiles_ComputesNamespaceWithSuffix(string source, string imports, string expected) + { + // Arrange + var node = new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan(imports, 0, 0, 0, 0), + }; + + node.Children.Add(new DirectiveTokenIntermediateNode() { Content = "Base" }); + + // Act + var @namespace = NamespaceDirective.GetNamespace(source, node); + + // Assert + Assert.Equal(expected, @namespace); + } + + // This is the case where a _ViewImports sets the namespace. + [Fact] + public void Pass_SetsNamespace_ComputedFromImports() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" }); + builder.Pop(); + + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" }; + builder.Push(@namespace); + + var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" }; + builder.Add(@class); + + document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; + + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("ignored", "/Account/Manage/AddUser.cshtml")); + + var pass = new NamespaceDirective.Pass(); + pass.Engine = Mock.Of(); + + // Act + pass.Execute(codeDocument, document); + + // Assert + Assert.Equal("WebApplication.Account.Manage", @namespace.Content); + Assert.Equal("default", @class.ClassName); + } + + // This is the case where the source file sets the namespace. + [Fact] + public void Pass_SetsNamespace_ComputedFromSource() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + + // This will be ignored. + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "ignored" }); + builder.Pop(); + + // This will be used. + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan("/Account/Manage/AddUser.cshtml", 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account.Manage" }); + builder.Pop(); + + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" }; + builder.Push(@namespace); + + var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" }; + builder.Add(@class); + + document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; + + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("ignored", "/Account/Manage/AddUser.cshtml")); + + var pass = new NamespaceDirective.Pass(); + pass.Engine = Mock.Of(); + + // Act + pass.Execute(codeDocument, document); + + // Assert + Assert.Equal("WebApplication.Account.Manage", @namespace.Content); + Assert.Equal("default", @class.ClassName); + } + + // Handles cases where invalid characters appears in FileNames. Note that we don't sanitize the part of + // the namespace that you put in an import, just the file-based-suffix. Garbage in, garbage out. + [Fact] + public void Pass_SetsNamespace_SanitizesClassAndNamespace() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" }); + builder.Pop(); + + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" }; + builder.Push(@namespace); + + var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" }; + builder.Add(@class); + + document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; + + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("ignored", "/Account/Manage-Info/Add+User.cshtml")); + + var pass = new NamespaceDirective.Pass(); + pass.Engine = Mock.Of(); + + // Act + pass.Execute(codeDocument, document); + + // Assert + Assert.Equal("WebApplication.Account.Manage_Info", @namespace.Content); + Assert.Equal("default", @class.ClassName); + } + + // This is the case where the source file sets the namespace. + [Fact] + public void Pass_SetsNamespace_ComputedFromSource_ForView() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + + // This will be ignored. + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan("/Account/_ViewImports.cshtml", 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "ignored" }); + builder.Pop(); + + // This will be used. + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan("/Account/Manage/AddUser.cshtml", 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account.Manage" }); + builder.Pop(); + + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" }; + builder.Push(@namespace); + + var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" }; + builder.Add(@class); + + document.DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind; + + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("ignored", "/Account/Manage/AddUser.cshtml")); + + var pass = new NamespaceDirective.Pass(); + pass.Engine = Mock.Of(); + + // Act + pass.Execute(codeDocument, document); + + // Assert + Assert.Equal("WebApplication.Account.Manage", @namespace.Content); + Assert.Equal("default", @class.ClassName); + } + + // This handles an error case where we can't determine the relationship between the + // imports and the source. + [Fact] + public void Pass_SetsNamespace_VerbatimFromImports() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan(null, 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" }); + builder.Pop(); + + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" }; + builder.Push(@namespace); + + var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" }; + builder.Add(@class); + + document.DocumentKind = RazorPageDocumentClassifierPass.RazorPageDocumentKind; + + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("ignored", "/Account/Manage/AddUser.cshtml")); + + var pass = new NamespaceDirective.Pass(); + pass.Engine = Mock.Of(); + + // Act + pass.Execute(codeDocument, document); + + // Assert + Assert.Equal("WebApplication.Account", @namespace.Content); + Assert.Equal("default", @class.ClassName); + } + + [Fact] + public void Pass_DoesNothing_ForUnknownDocumentKind() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + + builder.Push(new DirectiveIntermediateNode() + { + Directive = NamespaceDirective.Directive, + Source = new SourceSpan(null, 0, 0, 0, 0), + }); + builder.Add(new DirectiveTokenIntermediateNode() { Content = "WebApplication.Account" }); + builder.Pop(); + + var @namespace = new NamespaceDeclarationIntermediateNode() { Content = "default" }; + builder.Push(@namespace); + + var @class = new ClassDeclarationIntermediateNode() { ClassName = "default" }; + builder.Add(@class); + + document.DocumentKind = null; + + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("ignored", "/Account/Manage/AddUser.cshtml")); + + var pass = new NamespaceDirective.Pass(); + pass.Engine = Mock.Of(); + + // Act + pass.Execute(codeDocument, document); + + // Assert + Assert.Equal("default", @namespace.Content); + Assert.Equal("default", @class.ClassName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs new file mode 100644 index 0000000000..1bdb156298 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/PageDirectiveTest.cs @@ -0,0 +1,148 @@ +// 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.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class PageDirectiveTest + { + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfPageIsMalformed() + { + // Arrange + var content = "@page \"some-route-template\" Invalid"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Equal("some-route-template", pageDirective.RouteTemplate); + Assert.NotNull(pageDirective.DirectiveNode); + } + + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfPageIsImported() + { + // Arrange + var content = "Hello world"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var importDocument = RazorSourceDocument.Create("@page", "imports.cshtml"); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { importDocument }); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Null(pageDirective.RouteTemplate); + } + + [Fact] + public void TryGetPageDirective_ReturnsFalse_IfPageDoesNotHaveDirective() + { + // Arrange + var content = "Hello world"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.False(result); + Assert.Null(pageDirective); + } + + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfPageDoesStartWithDirective() + { + // Arrange + var content = "Hello @page"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Null(pageDirective.RouteTemplate); + Assert.NotNull(pageDirective.DirectiveNode); + } + + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfContentHasDirective() + { + // Arrange + var content = "@page"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Null(pageDirective.RouteTemplate); + } + + [Fact] + public void TryGetPageDirective_ParsesRouteTemplate() + { + // Arrange + var content = "@page \"some-route-template\""; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Equal("some-route-template", pageDirective.RouteTemplate); + } + + private RazorEngine CreateEngine() + { + return RazorProjectEngine.Create(b => + { + PageDirective.Register(b); + }).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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3337ebeac2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs new file mode 100644 index 0000000000..d86e144c78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/RazorPageDocumentClassifierPassTest.cs @@ -0,0 +1,416 @@ +// 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.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class RazorPageDocumentClassifierPassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_2_1; + + [Fact] + public void RazorPageDocumentClassifierPass_LogsErrorForImportedPageDirectives() + { + // Arrange + var sourceSpan = new SourceSpan("import.cshtml", 0, 0, 0, 5); + var expectedDiagnostic = RazorExtensionsDiagnosticFactory.CreatePageDirective_CannotBeImported(sourceSpan); + var importDocument = RazorSourceDocument.Create("@page", "import.cshtml"); + var sourceDocument = RazorSourceDocument.Create("

Hello World

", "main.cshtml"); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { importDocument }); + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var pageDirectives = irDocument.FindDirectiveReferences(PageDirective.Directive); + var directive = Assert.Single(pageDirectives); + var diagnostic = Assert.Single(directive.Node.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RazorPageDocumentClassifierPass_LogsErrorIfDirectiveNotAtTopOfFile() + { + // Arrange + var sourceSpan = new SourceSpan( + "Test.cshtml", + absoluteIndex: 14 + Environment.NewLine.Length * 2, + lineIndex: 2, + characterIndex: 0, + length: 5 + Environment.NewLine.Length); + + var expectedDiagnostic = RazorExtensionsDiagnosticFactory.CreatePageDirective_MustExistAtTheTopOfFile(sourceSpan); + var content = @" +@somethingelse +@page +"; + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(content, "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + var pageDirectives = irDocument.FindDirectiveReferences(PageDirective.Directive); + var directive = Assert.Single(pageDirectives); + var diagnostic = Assert.Single(directive.Node.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RazorPageDocumentClassifierPass_DoesNotLogErrorIfCommentAndWhitespaceBeforeDirective() + { + // Arrange + var content = @" +@* some comment *@ + +@page +"; + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(content, "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + var pageDirectives = irDocument.FindDirectiveReferences(PageDirective.Directive); + var directive = Assert.Single(pageDirectives); + Assert.Empty(directive.Node.Diagnostics); + } + + [Fact] + public void RazorPageDocumentClassifierPass_SetsDocumentKind() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal("mvc.1.0.razor-page", irDocument.DocumentKind); + } + + [Fact] + public void RazorPageDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + irDocument.DocumentKind = "some-value"; + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal("some-value", irDocument.DocumentKind); + } + + [Fact] + public void RazorPageDocumentClassifierPass_NoOpsIfPageDirectiveIsMalformed() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page+1", "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + irDocument.DocumentKind = "some-value"; + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal("some-value", irDocument.DocumentKind); + } + + [Fact] + public void RazorPageDocumentClassifierPass_SetsNamespace() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal("AspNetCore", visitor.Namespace.Content); + } + + [Fact] + public void RazorPageDocumentClassifierPass_SetsClass() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType); + Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); + Assert.Equal("Test", visitor.Class.ClassName); + } + + [Fact] + public void RazorPageDocumentClassifierPass_NullFilePath_SetsClass() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: null, relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType); + Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); + Assert.Equal("AspNetCore_74fbaab062bb228ed1ab09c5ff8d6ed2417320e2", 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 RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal(expected, visitor.Class.ClassName); + } + + [Fact] + public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = 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 RazorPageDocumentClassifierPass_SanitizesClassName() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = 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 RazorPageDocumentClassifierPass_SetsUpExecuteAsyncMethod() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = 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); + } + + [Fact] + public void RazorPageDocumentClassifierPass_AddsRouteTemplateMetadata() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page \"some-route\"", properties)); + + var engine = CreateProjectEngine().Engine; + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + var attributeNode = Assert.IsType(visitor.ExtensionNode); + Assert.Equal("RouteTemplate", attributeNode.Key); + Assert.Equal("some-route", attributeNode.Value); + } + + protected override void ConfigureProjectEngine(RazorProjectEngineBuilder builder) + { + PageDirective.Register(builder); + } + + private static 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 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 ExtensionIntermediateNode ExtensionNode { 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); + } + + public override void VisitExtension(ExtensionIntermediateNode node) + { + ExtensionNode = node; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/SourceMappingsSerializer.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/SourceMappingsSerializer.cs new file mode 100644 index 0000000000..8c63fd7444 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/SourceMappingsSerializer.cs @@ -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.Version2_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("|"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TagHelperDescriptorExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TagHelperDescriptorExtensionsTest.cs new file mode 100644 index 0000000000..af0b983b55 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TagHelperDescriptorExtensionsTest.cs @@ -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.Version2_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; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml new file mode 100644 index 0000000000..a20b20dae8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml @@ -0,0 +1,8 @@ +
+ Hello world + @string.Format("{0}", "Hello") +
+@{ + var cls = "foo"; +} +

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs new file mode 100644 index 0000000000..d39b64c26d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -0,0 +1,71 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt new file mode 100644 index 0000000000..959329c714 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -0,0 +1,65 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 -

+ 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 -
+ 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 -

+ IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt new file mode 100644 index 0000000000..372b49cb6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -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] ) +| }| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs new file mode 100644 index 0000000000..8e6b1a7bd7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs @@ -0,0 +1,95 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6d079dd6c39f39d17a2faff14404b37ab7e8b8fc" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6d079dd6c39f39d17a2faff14404b37ab7e8b8fc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(0, 4, true); + WriteLiteral("

+ 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 -
+ 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 -

+ IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml new file mode 100644 index 0000000000..224242197b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml @@ -0,0 +1,15 @@ +@* These test files validate that end-to-end, incomplete directives don't throw. *@ + +@page +@page +@page " + +@model +@model + +@inject +@inject +@inject MyService + +@namespace +@namespace diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs new file mode 100644 index 0000000000..40224e4d06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -0,0 +1,74 @@ +// +#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.RazorPages.Page + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +MyService __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..1cfef392ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -0,0 +1,12 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt new file mode 100644 index 0000000000..bd1de30747 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -0,0 +1,76 @@ +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.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - + 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 - (94:3,0 [8] IncompleteDirectives.cshtml) - page + MalformedDirective - (102:4,0 [6] IncompleteDirectives.cshtml) - page + HtmlContent - (108:4,6 [5] IncompleteDirectives.cshtml) + IntermediateToken - (108:4,6 [5] IncompleteDirectives.cshtml) - Html - "\n\n + MalformedDirective - (113:6,0 [6] IncompleteDirectives.cshtml) - model + HtmlContent - (119:6,6 [2] IncompleteDirectives.cshtml) + IntermediateToken - (119:6,6 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (121:7,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + HtmlContent - (128:7,7 [4] IncompleteDirectives.cshtml) + IntermediateToken - (128:7,7 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (132:9,0 [7] IncompleteDirectives.cshtml) - inject + HtmlContent - (139:9,7 [2] IncompleteDirectives.cshtml) + IntermediateToken - (139:9,7 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (141:10,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - + HtmlContent - (149:10,8 [2] IncompleteDirectives.cshtml) + IntermediateToken - (149:10,8 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (151:11,0 [25] IncompleteDirectives.cshtml) - inject + DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + HtmlContent - (176:11,25 [4] IncompleteDirectives.cshtml) + IntermediateToken - (176:11,25 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (180:13,0 [10] IncompleteDirectives.cshtml) - namespace + HtmlContent - (190:13,10 [2] IncompleteDirectives.cshtml) + IntermediateToken - (190:13,10 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (192:14,0 [11] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - + HtmlContent - (203:14,11 [2] IncompleteDirectives.cshtml) + IntermediateToken - (203:14,11 [2] IncompleteDirectives.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt new file mode 100644 index 0000000000..cc79426cf0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (128:7,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (767:19,0 [0] ) +|| + +Source Location: (149:10,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (958:27,0 [0] ) +|| + +Source Location: (159:11,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|MyService| +Generated Location: (1149:35,0 [17] ) +|MyService| + +Source Location: (203:14,11 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1380:43,0 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs new file mode 100644 index 0000000000..25d746e332 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -0,0 +1,65 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5add9dba0a182cd75498c5b24f64a2547e7f49b0" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5add9dba0a182cd75498c5b24f64a2547e7f49b0", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(85, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(108, 5, true); + WriteLiteral("\"\r\n\r\n"); + EndContext(); + BeginContext(119, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(128, 4, true); + WriteLiteral("\r\n\r\n"); + EndContext(); + BeginContext(139, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(149, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(176, 4, true); + WriteLiteral("\r\n\r\n"); + EndContext(); + BeginContext(190, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(203, 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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt new file mode 100644 index 0000000000..1cfef392ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -0,0 +1,12 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt new file mode 100644 index 0000000000..9a14616752 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -0,0 +1,91 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(85, 2, true); + HtmlContent - (85:1,0 [2] IncompleteDirectives.cshtml) + IntermediateToken - (85:1,0 [2] IncompleteDirectives.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (94:3,0 [8] IncompleteDirectives.cshtml) - page + MalformedDirective - (102:4,0 [6] IncompleteDirectives.cshtml) - page + CSharpCode - + IntermediateToken - - CSharp - BeginContext(108, 5, true); + HtmlContent - (108:4,6 [5] IncompleteDirectives.cshtml) + IntermediateToken - (108:4,6 [5] IncompleteDirectives.cshtml) - Html - "\n\n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (113:6,0 [6] IncompleteDirectives.cshtml) - model + CSharpCode - + IntermediateToken - - CSharp - BeginContext(119, 2, true); + HtmlContent - (119:6,6 [2] IncompleteDirectives.cshtml) + IntermediateToken - (119:6,6 [2] IncompleteDirectives.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (121:7,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(128, 4, true); + HtmlContent - (128:7,7 [4] IncompleteDirectives.cshtml) + IntermediateToken - (128:7,7 [4] IncompleteDirectives.cshtml) - Html - \n\n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (132:9,0 [7] IncompleteDirectives.cshtml) - inject + CSharpCode - + IntermediateToken - - CSharp - BeginContext(139, 2, true); + HtmlContent - (139:9,7 [2] IncompleteDirectives.cshtml) + IntermediateToken - (139:9,7 [2] IncompleteDirectives.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (141:10,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(149, 2, true); + HtmlContent - (149:10,8 [2] IncompleteDirectives.cshtml) + IntermediateToken - (149:10,8 [2] IncompleteDirectives.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (151:11,0 [25] IncompleteDirectives.cshtml) - inject + DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + CSharpCode - + IntermediateToken - - CSharp - BeginContext(176, 4, true); + HtmlContent - (176:11,25 [4] IncompleteDirectives.cshtml) + IntermediateToken - (176:11,25 [4] IncompleteDirectives.cshtml) - Html - \n\n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (180:13,0 [10] IncompleteDirectives.cshtml) - namespace + CSharpCode - + IntermediateToken - - CSharp - BeginContext(190, 2, true); + HtmlContent - (190:13,10 [2] IncompleteDirectives.cshtml) + IntermediateToken - (190:13,10 [2] IncompleteDirectives.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + MalformedDirective - (192:14,0 [11] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(203, 2, true); + HtmlContent - (203:14,11 [2] IncompleteDirectives.cshtml) + IntermediateToken - (203:14,11 [2] IncompleteDirectives.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml new file mode 100644 index 0000000000..38efd570da --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml @@ -0,0 +1,2 @@ +@inherits MyBasePageForViews +@model MyModel diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..c5e699c2cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -0,0 +1,56 @@ +// +#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 + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" +MyBasePageForViews __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt new file mode 100644 index 0000000000..3310acfa76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -0,0 +1,39 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (10:0,10 [26] InheritsViewModel.cshtml) - MyBasePageForViews + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..b5fd5c933d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) +|MyBasePageForViews| +Generated Location: (740:19,0 [26] ) +|MyBasePageForViews| + +Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) +|MyModel| +Generated Location: (976:27,0 [7] ) +|MyModel| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs new file mode 100644 index 0000000000..9680177b77 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs @@ -0,0 +1,36 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3ff83e2f0d946feb387a8ea03a529c64350014f8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"3ff83e2f0d946feb387a8ea03a529c64350014f8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt new file mode 100644 index 0000000000..2468ef4662 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt @@ -0,0 +1,20 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml new file mode 100644 index 0000000000..295e4cf3ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml @@ -0,0 +1,2 @@ +@page +@model MyModel diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..25cf7044fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -0,0 +1,50 @@ +// +#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 : MyPageModel + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 2 "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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public MyModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..bcbf42ae26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -0,0 +1,43 @@ +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 - MyPageModel - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (10:0,10 [19] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - MyPageModel + DirectiveToken - (14:1,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 - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public MyModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..e7daecd874 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) +|MyModel| +Generated Location: (745:19,0 [7] ) +|MyModel| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..c1ea0b5c3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs @@ -0,0 +1,39 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d196fc1c66d46d35e35af9b01c737e12bcce6782" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d196fc1c66d46d35e35af9b01c737e12bcce6782", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f311ecbb5c4d63980a59c24af5ffe8baa1c3f99a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyPageModel + { + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public MyModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..2704223a57 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt @@ -0,0 +1,25 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] + 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 + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyPageModel - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public MyModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml new file mode 100644 index 0000000000..0aa749dd3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml @@ -0,0 +1 @@ +@inject MyApp MyPropertyName diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml new file mode 100644 index 0000000000..d699f1e754 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml @@ -0,0 +1,3 @@ +@model MyModel +@inject MyApp MyPropertyName +@inject MyService Html diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..4d4d684cda --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -0,0 +1,82 @@ +// +#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 + { + #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 __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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt new file mode 100644 index 0000000000..c1d70d5d89 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -0,0 +1,43 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..dd6970fdb8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -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| +Generated Location: (1422:43,0 [17] ) +|MyService| + +Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|Html| +Generated Location: (1669:51,22 [4] ) +|Html| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs new file mode 100644 index 0000000000..36974edf08 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2cafb599699b78d76f0355b6f528050b4720789d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2cafb599699b78d76f0355b6f528050b4720789d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt new file mode 100644 index 0000000000..d018107ae2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml new file mode 100644 index 0000000000..8cd61913e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml @@ -0,0 +1,5 @@ +@model MyModel +@inject MyApp MyPropertyName; +@inject MyService Html; +@inject MyApp MyPropertyName2 ; +@inject MyService Html2 ; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs new file mode 100644 index 0000000000..15e13c4def --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -0,0 +1,118 @@ +// +#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 + { + #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 __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 __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 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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt new file mode 100644 index 0000000000..5c4540f366 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -0,0 +1,49 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt new file mode 100644 index 0000000000..8c1b0b9336 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -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| +Generated Location: (1442:43,0 [17] ) +|MyService| + +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| +Generated Location: (2343:75,0 [17] ) +|MyService| + +Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|Html2| +Generated Location: (2594:83,22 [5] ) +|Html2| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs new file mode 100644 index 0000000000..b8eb5c371d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs @@ -0,0 +1,42 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8a53bde02f202036e674a23018e04268a3a844bb" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8a53bde02f202036e674a23018e04268a3a844bb", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt new file mode 100644 index 0000000000..898557c170 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt @@ -0,0 +1,23 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs new file mode 100644 index 0000000000..ec04e2bf8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -0,0 +1,58 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt new file mode 100644 index 0000000000..0b8beeae9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -0,0 +1,40 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt new file mode 100644 index 0000000000..27b118c2ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -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| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs new file mode 100644 index 0000000000..e3493199a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "592a6d8544c71b828d4a3fbf92d398cd3ea72790" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"592a6d8544c71b828d4a3fbf92d398cd3ea72790", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt new file mode 100644 index 0000000000..e05f9d2df9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml new file mode 100644 index 0000000000..6dfb72bc31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml @@ -0,0 +1 @@ +@namespace Test. \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs new file mode 100644 index 0000000000..d99c176c52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -0,0 +1,40 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..90446dc58b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt new file mode 100644 index 0000000000..6f9220aab4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -0,0 +1,40 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + MalformedDirective - (0:0,0 [11] InvalidNamespaceAtEOF.cshtml) - namespace + HtmlContent - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) + IntermediateToken - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) - Html - Test. + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs new file mode 100644 index 0000000000..2accba6951 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs @@ -0,0 +1,39 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "010d175bb6c3f7fa6f2ae04c1fecb4e3bfbf928b" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"010d175bb6c3f7fa6f2ae04c1fecb4e3bfbf928b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(11, 5, 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt new file mode 100644 index 0000000000..90446dc58b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt new file mode 100644 index 0000000000..e99ab2d9c2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt @@ -0,0 +1,27 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + MalformedDirective - (0:0,0 [11] InvalidNamespaceAtEOF.cshtml) - namespace + CSharpCode - + IntermediateToken - - CSharp - BeginContext(11, 5, true); + HtmlContent - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) + IntermediateToken - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) - Html - Test. + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml new file mode 100644 index 0000000000..9b4f9d5559 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml @@ -0,0 +1,4 @@ +@page "foo + +

About Us

+

We are awesome.

\ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..15befce0d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs @@ -0,0 +1,42 @@ +// +#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_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..637d1e902b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..8db9133a4a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt @@ -0,0 +1,53 @@ +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_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page + HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml) + IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n + IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us + IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n + IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome. + IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html -

+ Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs new file mode 100644 index 0000000000..7835a2dae2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs @@ -0,0 +1,41 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "464e008b9a04181fe1e9f2cc6826095698de4739" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"464e008b9a04181fe1e9f2cc6826095698de4739", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(6, 49, true); + WriteLiteral("\"foo\r\n\r\n

About Us

\r\n

We are awesome.

"); + 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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt new file mode 100644 index 0000000000..637d1e902b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt new file mode 100644 index 0000000000..d98f501792 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt @@ -0,0 +1,40 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page + CSharpCode - + IntermediateToken - - CSharp - BeginContext(6, 49, true); + HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml) + IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n + IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us + IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n + IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome. + IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html -

+ CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml new file mode 100644 index 0000000000..4b73b2dc53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml @@ -0,0 +1 @@ +@model System.Collections.IEnumerable diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml new file mode 100644 index 0000000000..c488b1e443 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml @@ -0,0 +1,6 @@ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..f0fe1ad8e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -0,0 +1,76 @@ +// +#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 + { + #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(); +#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(); +#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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..37627e94ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -0,0 +1,68 @@ +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 - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..d4fc8a447a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -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| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..92388de1b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs @@ -0,0 +1,109 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "741fc99adb54ad906c5cdc5391aeffb51a1e767b" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"741fc99adb54ad906c5cdc5391aeffb51a1e767b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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(); + __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(); + __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..1fb7820a75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt @@ -0,0 +1,73 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs new file mode 100644 index 0000000000..c01f69d243 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#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_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" +System.Collections.IEnumerable __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt new file mode 100644 index 0000000000..1ebdc00df2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -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_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (7:0,7 [30] Model.cshtml) - System.Collections.IEnumerable + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt new file mode 100644 index 0000000000..7d84cf754d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) +|System.Collections.IEnumerable| +Generated Location: (769:19,0 [30] ) +|System.Collections.IEnumerable| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs new file mode 100644 index 0000000000..ae8dc1fe65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs @@ -0,0 +1,36 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2c1e88396568d309c236020e59bf2abacfadd612" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2c1e88396568d309c236020e59bf2abacfadd612", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt new file mode 100644 index 0000000000..2b7dcff085 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt @@ -0,0 +1,20 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml new file mode 100644 index 0000000000..350f93b776 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml @@ -0,0 +1,2 @@ +@model ThisShouldBeGenerated +@model System.Collections.IEnumerable diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs new file mode 100644 index 0000000000..2ff817c2ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -0,0 +1,56 @@ +// +#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_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml" +ThisShouldBeGenerated __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml" +System.Collections.IEnumerable __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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..2fe8233c66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt new file mode 100644 index 0000000000..f63a69601b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -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_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (7:0,7 [21] MultipleModels.cshtml) - ThisShouldBeGenerated + DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable + 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 + MalformedDirective - (30:1,0 [39] MultipleModels.cshtml) - model + DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt new file mode 100644 index 0000000000..8853f2b5d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) +|ThisShouldBeGenerated| +Generated Location: (778:19,0 [21] ) +|ThisShouldBeGenerated| + +Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) +|System.Collections.IEnumerable| +Generated Location: (1006:27,0 [30] ) +|System.Collections.IEnumerable| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml new file mode 100644 index 0000000000..ecee97de58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml @@ -0,0 +1,3 @@ +@page +@namespace Test.Namespace +

Hi There!

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs new file mode 100644 index 0000000000..9d7181bfad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Test.Namespace +{ + #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_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml" +global::System.Object __typeHelper = nameof(Test.Namespace); + +#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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt new file mode 100644 index 0000000000..099c37355f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt @@ -0,0 +1,48 @@ +Document - + NamespaceDeclaration - - Test.Namespace + 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_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (18:1,11 [14] PageWithNamespace.cshtml) - Test.Namespace + 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 - (34:2,0 [20] PageWithNamespace.cshtml) + IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt new file mode 100644 index 0000000000..b41240c9c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (18:1,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml) +|Test.Namespace| +Generated Location: (809:19,44 [14] ) +|Test.Namespace| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs new file mode 100644 index 0000000000..9c1a5b03f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs @@ -0,0 +1,41 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1edfb1ba4f5f6c70e2c72f4f23baf4dc0ae14377" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] +namespace Test.Namespace +{ + #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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1edfb1ba4f5f6c70e2c72f4f23baf4dc0ae14377", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(34, 20, true); + WriteLiteral("

Hi There!

\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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt new file mode 100644 index 0000000000..4d26b5c3fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt @@ -0,0 +1,34 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] + NamespaceDeclaration - - Test.Namespace + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(34, 20, true); + HtmlContent - (34:2,0 [20] PageWithNamespace.cshtml) + IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml new file mode 100644 index 0000000000..5172f8f791 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml @@ -0,0 +1,2 @@ +
Some text here.
+@page diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..ec8a4fd5c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.cs @@ -0,0 +1,42 @@ +// +#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_RazorPageWithNoLeadingPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..393b35646e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml(2,1): Error RZ3906: The '@page' directive must precede all other elements defined in a Razor file. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..6139c62c14 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.ir.txt @@ -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_RazorPageWithNoLeadingPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 [28] RazorPageWithNoLeadingPageDirective.cshtml) + IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here. + IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs new file mode 100644 index 0000000000..107beef619 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs @@ -0,0 +1,41 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "40c0ffad85d8fef63edfb5d91a08bd1b3609ba6f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective), null)] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"40c0ffad85d8fef63edfb5d91a08bd1b3609ba6f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(0, 28, true); + WriteLiteral("
Some text here.
\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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.diagnostics.txt new file mode 100644 index 0000000000..393b35646e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml(2,1): Error RZ3906: The '@page' directive must precede all other elements defined in a Razor file. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt new file mode 100644 index 0000000000..c4ad8ed82d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt @@ -0,0 +1,34 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective), null)] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(0, 28, true); + HtmlContent - (0:0,0 [28] RazorPageWithNoLeadingPageDirective.cshtml) + IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here. + IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml new file mode 100644 index 0000000000..2bc617c509 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml @@ -0,0 +1,40 @@ +@page + +@model NewModel +@addTagHelper "*, AppCode" +@using Microsoft.AspNetCore.Mvc.RazorPages + +@functions { + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } +} + +

New Customer

+
+
+
+ +
+ + +
+
+
+
+ +
+
+
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml new file mode 100644 index 0000000000..63d5955e72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml @@ -0,0 +1,13 @@ +@page "/About" + +@model NewModel +@using Microsoft.AspNetCore.Mvc.RazorPages + +@functions { + public class NewModel : PageModel + { + public string Name { get; set; } + } +} + +

New Customer @Model.Name

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.cs new file mode 100644 index 0000000000..0301af92d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.cs @@ -0,0 +1,78 @@ +// +#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; +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("RouteTemplate", "/About")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +global::System.Object __typeHelper = "/About"; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +NewModel __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() + { +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + __o = Model.Name; + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + + public class NewModel : PageModel + { + public string Name { get; set; } + } + +#line default +#line hidden + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.ir.txt new file mode 100644 index 0000000000..721dfa649d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.ir.txt @@ -0,0 +1,61 @@ +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 + UsingDirective - (36:3,1 [41] RazorPagesWithRouteTemplate.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorCompiledItemMetadataAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (6:0,6 [8] RazorPagesWithRouteTemplate.cshtml) - "/About" + DirectiveToken - (25:2,7 [8] RazorPagesWithRouteTemplate.cshtml) - NewModel + 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 - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + HtmlContent - (77:3,42 [4] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (77:3,42 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n + HtmlContent - (191:10,1 [21] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (191:10,1 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n + IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer + CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name + HtmlContent - (223:12,28 [7] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (223:12,28 [5] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (228:12,33 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + CSharpCode - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.mappings.txt new file mode 100644 index 0000000000..d9fa4ef590 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.mappings.txt @@ -0,0 +1,35 @@ +Source Location: (36:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (492:14,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|"/About"| +Generated Location: (1108:25,37 [8] ) +|"/About"| + +Source Location: (25:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|NewModel| +Generated Location: (1313:33,0 [8] ) +|NewModel| + +Source Location: (213:12,18 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|Model.Name| +Generated Location: (1831:48,18 [10] ) +|Model.Name| + +Source Location: (93:5,12 [97] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +| + public class NewModel : PageModel + { + public string Name { get; set; } + } +| +Generated Location: (2039:55,12 [97] ) +| + public class NewModel : PageModel + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs new file mode 100644 index 0000000000..bff519edb2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs @@ -0,0 +1,72 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "547900310554f446d88da593a245719ee9dbb12f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate), @"/About")] +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; +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("RouteTemplate", "/About")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"547900310554f446d88da593a245719ee9dbb12f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(16, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(79, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(193, 19, true); + WriteLiteral("\r\n

New Customer "); + EndContext(); + BeginContext(213, 10, false); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + Write(Model.Name); + +#line default +#line hidden + EndContext(); + BeginContext(223, 7, true); + WriteLiteral("

\r\n"); + EndContext(); + } + #pragma warning restore 1998 +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + + public class NewModel : PageModel + { + public string Name { get; set; } + } + +#line default +#line hidden + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt new file mode 100644 index 0000000000..86990e5de4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt @@ -0,0 +1,62 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate), @"/About")] + 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 + UsingDirective - (36:3,1 [43] RazorPagesWithRouteTemplate.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorCompiledItemMetadataAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(16, 2, true); + HtmlContent - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(79, 2, true); + HtmlContent - (79:4,0 [2] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (79:4,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(193, 19, true); + HtmlContent - (193:11,0 [19] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (193:11,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(213, 10, false); + CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(223, 7, true); + HtmlContent - (223:12,28 [7] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (223:12,28 [5] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (228:12,33 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml new file mode 100644 index 0000000000..b78cc65ec7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml @@ -0,0 +1,36 @@ +@page + +@addTagHelper "*, AppCode" +@using Microsoft.AspNetCore.Mvc.RazorPages + +@functions { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } +} + +

New Customer

+
+
+
+ +
+ + +
+
+
+
+ +
+
+
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..feed2d390d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs @@ -0,0 +1,93 @@ +// +#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; +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" +global::System.Object __typeHelper = "*, 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() + { + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" + __o = Name; + +#line default +#line hidden + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" + + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt new file mode 100644 index 0000000000..de7cd9dd4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt @@ -0,0 +1,145 @@ +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 + UsingDirective - (38:3,1 [41] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (23:2,14 [12] RazorPagesWithoutModel.cshtml) - "*, 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 - (7:1,0 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (7:1,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + HtmlContent - (35:2,26 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (35:2,26 [2] RazorPagesWithoutModel.cshtml) - Html - \n + HtmlContent - (79:3,42 [4] RazorPagesWithoutModel.cshtml) + IntermediateToken - (79:3,42 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n + HtmlContent - (379:18,1 [77] RazorPagesWithoutModel.cshtml) + IntermediateToken - (379:18,1 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n + IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer + IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (406:21,0 [5] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (450:21,44 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (456:22,4 [31] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (468:22,16 [11] RazorPagesWithoutModel.cshtml) + IntermediateToken - (468:22,16 [11] RazorPagesWithoutModel.cshtml) - Html - text-danger + DefaultTagHelperExecute - + HtmlContent - (487:22,35 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (487:22,35 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (493:23,4 [237] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (517:23,28 [48] RazorPagesWithoutModel.cshtml) + IntermediateToken - (517:23,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (527:24,8 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (578:24,59 [10] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (588:25,8 [130] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (611:25,31 [101] RazorPagesWithoutModel.cshtml) + IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (695:27,38 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (702:27,45 [10] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (600:25,20 [9] RazorPagesWithoutModel.cshtml) + IntermediateToken - (600:25,20 [9] RazorPagesWithoutModel.cshtml) - Html - col-md-10 + DefaultTagHelperExecute - + HtmlContent - (718:28,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (718:28,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (505:23,16 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (505:23,16 [10] RazorPagesWithoutModel.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (730:29,10 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (730:29,10 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (736:30,4 [174] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (760:30,28 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (760:30,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (770:31,8 [128] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (809:31,47 [83] RazorPagesWithoutModel.cshtml) + IntermediateToken - (809:31,47 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (823:32,12 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (882:32,71 [10] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (782:31,20 [25] RazorPagesWithoutModel.cshtml) + IntermediateToken - (782:31,20 [25] RazorPagesWithoutModel.cshtml) - Html - col-md-offset-2 col-md-10 + DefaultTagHelperExecute - + HtmlContent - (898:33,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (898:33,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (748:30,16 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (748:30,16 [10] RazorPagesWithoutModel.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (910:34,10 [11] RazorPagesWithoutModel.cshtml) + IntermediateToken - (910:34,10 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (912:35,0 [7] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (919:35,7 [2] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - (95:5,12 [283] RazorPagesWithoutModel.cshtml) + IntermediateToken - (95:5,12 [283] RazorPagesWithoutModel.cshtml) - CSharp - \n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..57e01c4825 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt @@ -0,0 +1,46 @@ +Source Location: (38:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (487:14,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (23:2,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +|"*, AppCode"| +Generated Location: (1443:30,37 [12] ) +|"*, AppCode"| + +Source Location: (566:24,47 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +|Name| +Generated Location: (2113:47,47 [4] ) +|Name| + +Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +| + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } +| +Generated Location: (2898:62,12 [283] ) +| + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs new file mode 100644 index 0000000000..b1b5bb16b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs @@ -0,0 +1,206 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8bf3954ad78688478de155359db8af32627ee2b8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] +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; +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8bf3954ad78688478de155359db8af32627ee2b8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("form-group"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-offset-2 col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(7, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(81, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(381, 75, true); + WriteLiteral("\r\n

New Customer

\r\n
\r\n "); + EndContext(); + BeginContext(456, 31, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(487, 6, true); + WriteLiteral("\r\n "); + EndContext(); + BeginContext(493, 237, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(517, 48, true); + WriteLiteral("\r\n \r\n "); + EndContext(); + BeginContext(588, 130, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(611, 101, true); + WriteLiteral("\r\n \r\n \r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(718, 6, true); + WriteLiteral("\r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(730, 6, true); + WriteLiteral("\r\n "); + EndContext(); + BeginContext(736, 174, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(760, 10, true); + WriteLiteral("\r\n "); + EndContext(); + BeginContext(770, 128, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(809, 83, true); + WriteLiteral("\r\n \r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(898, 6, true); + WriteLiteral("\r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(910, 11, true); + WriteLiteral("\r\n\r\n"); + EndContext(); + } + #pragma warning restore 1998 +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" + + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt new file mode 100644 index 0000000000..d48303ec80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt @@ -0,0 +1,195 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] + 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 + UsingDirective - (38:3,1 [43] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - class - col-md-offset-2 col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(7, 2, true); + HtmlContent - (7:1,0 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (7:1,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(81, 2, true); + HtmlContent - (81:4,0 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (81:4,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(381, 75, true); + HtmlContent - (381:19,0 [75] RazorPagesWithoutModel.cshtml) + IntermediateToken - (381:19,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer + IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (406:21,0 [5] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (450:21,44 [6] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(456, 31, false); + TagHelper - (456:22,4 [31] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(487, 6, true); + HtmlContent - (487:22,35 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (487:22,35 [6] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(493, 237, false); + TagHelper - (493:23,4 [237] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(517, 48, true); + HtmlContent - (517:23,28 [48] RazorPagesWithoutModel.cshtml) + IntermediateToken - (517:23,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (527:24,8 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (578:24,59 [10] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(588, 130, false); + TagHelper - (588:25,8 [130] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(611, 101, true); + HtmlContent - (611:25,31 [101] RazorPagesWithoutModel.cshtml) + IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (695:27,38 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (702:27,45 [10] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(718, 6, true); + HtmlContent - (718:28,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (718:28,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(730, 6, true); + HtmlContent - (730:29,10 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (730:29,10 [6] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(736, 174, false); + TagHelper - (736:30,4 [174] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(760, 10, true); + HtmlContent - (760:30,28 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (760:30,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(770, 128, false); + TagHelper - (770:31,8 [128] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(809, 83, true); + HtmlContent - (809:31,47 [83] RazorPagesWithoutModel.cshtml) + IntermediateToken - (809:31,47 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (823:32,12 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (882:32,71 [10] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(898, 6, true); + HtmlContent - (898:33,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (898:33,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(910, 11, true); + HtmlContent - (910:34,10 [11] RazorPagesWithoutModel.cshtml) + IntermediateToken - (910:34,10 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (912:35,0 [7] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (919:35,7 [2] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - (95:5,12 [283] RazorPagesWithoutModel.cshtml) + IntermediateToken - (95:5,12 [283] RazorPagesWithoutModel.cshtml) - CSharp - \n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs new file mode 100644 index 0000000000..d792bf0160 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs @@ -0,0 +1,104 @@ +// +#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; +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +NewModel __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +global::System.Object __typeHelper = "*, 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() + { + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" + __o = Model.Name; + +#line default +#line hidden + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" + + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt new file mode 100644 index 0000000000..c142630de7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt @@ -0,0 +1,147 @@ +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 + UsingDirective - (55:4,1 [41] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (16:2,7 [8] RazorPages.cshtml) - NewModel + DirectiveToken - (40:3,14 [12] RazorPages.cshtml) - "*, 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 - (7:1,0 [2] RazorPages.cshtml) + IntermediateToken - (7:1,0 [2] RazorPages.cshtml) - Html - \n + HtmlContent - (52:3,26 [2] RazorPages.cshtml) + IntermediateToken - (52:3,26 [2] RazorPages.cshtml) - Html - \n + HtmlContent - (96:4,42 [4] RazorPages.cshtml) + IntermediateToken - (96:4,42 [4] RazorPages.cshtml) - Html - \n\n + HtmlContent - (473:22,1 [78] RazorPages.cshtml) + IntermediateToken - (473:22,1 [4] RazorPages.cshtml) - Html - \n\n + IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html -

+ IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer + IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html -

+ IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html -
+ IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n + TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (563:26,16 [11] RazorPages.cshtml) + IntermediateToken - (563:26,16 [11] RazorPages.cshtml) - Html - text-danger + DefaultTagHelperExecute - + HtmlContent - (582:26,35 [6] RazorPages.cshtml) + IntermediateToken - (582:26,35 [6] RazorPages.cshtml) - Html - \n + TagHelper - (588:27,4 [243] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (612:27,28 [48] RazorPages.cshtml) + IntermediateToken - (612:27,28 [10] RazorPages.cshtml) - Html - \n + IntermediateToken - (622:28,8 [6] RazorPages.cshtml) - Html - + IntermediateToken - (679:28,65 [10] RazorPages.cshtml) - Html - \n + TagHelper - (689:29,8 [130] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (712:29,31 [101] RazorPages.cshtml) + IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - + IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - + IntermediateToken - (796:31,38 [7] RazorPages.cshtml) - Html - + IntermediateToken - (803:31,45 [10] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (701:29,20 [9] RazorPages.cshtml) + IntermediateToken - (701:29,20 [9] RazorPages.cshtml) - Html - col-md-10 + DefaultTagHelperExecute - + HtmlContent - (819:32,14 [6] RazorPages.cshtml) + IntermediateToken - (819:32,14 [6] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (600:27,16 [10] RazorPages.cshtml) + IntermediateToken - (600:27,16 [10] RazorPages.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (831:33,10 [6] RazorPages.cshtml) + IntermediateToken - (831:33,10 [6] RazorPages.cshtml) - Html - \n + TagHelper - (837:34,4 [174] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (861:34,28 [10] RazorPages.cshtml) + IntermediateToken - (861:34,28 [10] RazorPages.cshtml) - Html - \n + TagHelper - (871:35,8 [128] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (910:35,47 [83] RazorPages.cshtml) + IntermediateToken - (910:35,47 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (924:36,12 [7] RazorPages.cshtml) - Html - + IntermediateToken - (983:36,71 [10] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (883:35,20 [25] RazorPages.cshtml) + IntermediateToken - (883:35,20 [25] RazorPages.cshtml) - Html - col-md-offset-2 col-md-10 + DefaultTagHelperExecute - + HtmlContent - (999:37,14 [6] RazorPages.cshtml) + IntermediateToken - (999:37,14 [6] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (849:34,16 [10] RazorPages.cshtml) + IntermediateToken - (849:34,16 [10] RazorPages.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (1011:38,10 [11] RazorPages.cshtml) + IntermediateToken - (1011:38,10 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (1013:39,0 [7] RazorPages.cshtml) - Html -
+ IntermediateToken - (1020:39,7 [2] RazorPages.cshtml) - Html - \n + CSharpCode - (112:6,12 [360] RazorPages.cshtml) + IntermediateToken - (112:6,12 [360] RazorPages.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt new file mode 100644 index 0000000000..4bfb581ff3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt @@ -0,0 +1,57 @@ +Source Location: (55:4,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (475:14,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (16:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|NewModel| +Generated Location: (1370:30,0 [8] ) +|NewModel| + +Source Location: (40:3,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|"*, AppCode"| +Generated Location: (1618:38,37 [12] ) +|"*, AppCode"| + +Source Location: (661:28,47 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|Model.Name| +Generated Location: (2276:55,47 [10] ) +|Model.Name| + +Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +| + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } +| +Generated Location: (3055:70,12 [360] ) +| + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs new file mode 100644 index 0000000000..a879a231b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs @@ -0,0 +1,209 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d33caff161b646a61b273d7c544111395b652557" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] +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; +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d33caff161b646a61b273d7c544111395b652557", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("form-group"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-offset-2 col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(7, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(98, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(475, 76, true); + WriteLiteral("\r\n

New Customer

\r\n
\r\n "); + EndContext(); + BeginContext(551, 31, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(582, 6, true); + WriteLiteral("\r\n "); + EndContext(); + BeginContext(588, 243, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(612, 48, true); + WriteLiteral("\r\n \r\n "); + EndContext(); + BeginContext(689, 130, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(712, 101, true); + WriteLiteral("\r\n \r\n \r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(819, 6, true); + WriteLiteral("\r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(831, 6, true); + WriteLiteral("\r\n "); + EndContext(); + BeginContext(837, 174, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(861, 10, true); + WriteLiteral("\r\n "); + EndContext(); + BeginContext(871, 128, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(910, 83, true); + WriteLiteral("\r\n \r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(999, 6, true); + WriteLiteral("\r\n "); + EndContext(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + BeginContext(1011, 11, true); + WriteLiteral("\r\n\r\n"); + EndContext(); + } + #pragma warning restore 1998 +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" + + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt new file mode 100644 index 0000000000..a8ea42c44c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt @@ -0,0 +1,196 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] + 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 + UsingDirective - (55:4,1 [43] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - class - col-md-offset-2 col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(7, 2, true); + HtmlContent - (7:1,0 [2] RazorPages.cshtml) + IntermediateToken - (7:1,0 [2] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(98, 2, true); + HtmlContent - (98:5,0 [2] RazorPages.cshtml) + IntermediateToken - (98:5,0 [2] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(475, 76, true); + HtmlContent - (475:23,0 [76] RazorPages.cshtml) + IntermediateToken - (475:23,0 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html -

+ IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer + IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html -

+ IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html -
+ IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(551, 31, false); + TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(582, 6, true); + HtmlContent - (582:26,35 [6] RazorPages.cshtml) + IntermediateToken - (582:26,35 [6] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(588, 243, false); + TagHelper - (588:27,4 [243] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(612, 48, true); + HtmlContent - (612:27,28 [48] RazorPages.cshtml) + IntermediateToken - (612:27,28 [10] RazorPages.cshtml) - Html - \n + IntermediateToken - (622:28,8 [6] RazorPages.cshtml) - Html - + IntermediateToken - (679:28,65 [10] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(689, 130, false); + TagHelper - (689:29,8 [130] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(712, 101, true); + HtmlContent - (712:29,31 [101] RazorPages.cshtml) + IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - + IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - + IntermediateToken - (796:31,38 [7] RazorPages.cshtml) - Html - + IntermediateToken - (803:31,45 [10] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(819, 6, true); + HtmlContent - (819:32,14 [6] RazorPages.cshtml) + IntermediateToken - (819:32,14 [6] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(831, 6, true); + HtmlContent - (831:33,10 [6] RazorPages.cshtml) + IntermediateToken - (831:33,10 [6] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(837, 174, false); + TagHelper - (837:34,4 [174] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(861, 10, true); + HtmlContent - (861:34,28 [10] RazorPages.cshtml) + IntermediateToken - (861:34,28 [10] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(871, 128, false); + TagHelper - (871:35,8 [128] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(910, 83, true); + HtmlContent - (910:35,47 [83] RazorPages.cshtml) + IntermediateToken - (910:35,47 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (924:36,12 [7] RazorPages.cshtml) - Html - + IntermediateToken - (983:36,71 [10] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(999, 6, true); + HtmlContent - (999:37,14 [6] RazorPages.cshtml) + IntermediateToken - (999:37,14 [6] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(1011, 11, true); + HtmlContent - (1011:38,10 [11] RazorPages.cshtml) + IntermediateToken - (1011:38,10 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (1013:39,0 [7] RazorPages.cshtml) - Html -
+ IntermediateToken - (1020:39,7 [2] RazorPages.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - (112:6,12 [360] RazorPages.cshtml) + IntermediateToken - (112:6,12 [360] RazorPages.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml new file mode 100644 index 0000000000..7438788ff4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml @@ -0,0 +1,14 @@ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + +@{ + Layout = "_SectionTestLayout.cshtml"; +} + +
Some body
+ +@section Section1 { +
This is in Section 1
+ +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs new file mode 100644 index 0000000000..a720d28d50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -0,0 +1,86 @@ +// +#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_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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/Sections.cshtml" +DateTime __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object __typeHelper = "InputTestTagHelper, AppCode"; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object Section1 = 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() + { +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml"; + +#line default +#line hidden + DefineSection("Section1", async(__razor_section_writer) => { + __InputTestTagHelper = CreateTagHelper(); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt new file mode 100644 index 0000000000..f043a5f6d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -0,0 +1,75 @@ +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_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (7:0,7 [8] Sections.cshtml) - DateTime + DirectiveToken - (33:2,14 [29] Sections.cshtml) - "InputTestTagHelper, AppCode" + DirectiveToken - (152:10,9 [8] Sections.cshtml) - Section1 + 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] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + HtmlContent - (62:2,43 [4] Sections.cshtml) + IntermediateToken - (62:2,43 [4] Sections.cshtml) - Html - \n\n + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n + Section - - Section1 + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt new file mode 100644 index 0000000000..ba25b7bb6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|DateTime| +Generated Location: (1227:25,0 [8] ) +|DateTime| + +Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|"InputTestTagHelper, AppCode"| +Generated Location: (1473:33,37 [29] ) +|"InputTestTagHelper, AppCode"| + +Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Section1| +Generated Location: (1703:41,22 [8] ) +|Section1| + +Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +| + Layout = "_SectionTestLayout.cshtml"; +| +Generated Location: (2169:56,2 [46] ) +| + Layout = "_SectionTestLayout.cshtml"; +| + +Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Date| +Generated Location: (2594:64,102 [4] ) +|Date| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs new file mode 100644 index 0000000000..6e7de7d9b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -0,0 +1,101 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4b7b87da15db4343c99430c0813fd6bc03643453" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4b7b87da15db4343c99430c0813fd6bc03643453", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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(); +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml"; + +#line default +#line hidden + BeginContext(117, 26, true); + WriteLiteral("\r\n
Some body
\r\n\r\n"); + EndContext(); + DefineSection("Section1", async() => { + BeginContext(162, 43, true); + WriteLiteral("\r\n
This is in Section 1
\r\n "); + EndContext(); + BeginContext(205, 25, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTestTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTestTagHelper); +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.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(230, 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt new file mode 100644 index 0000000000..eca96a425a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -0,0 +1,79 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + 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] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(64, 2, true); + HtmlContent - (64:3,0 [2] Sections.cshtml) + IntermediateToken - (64:3,0 [2] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + CSharpCode - + IntermediateToken - - CSharp - BeginContext(117, 26, true); + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Section - - Section1 + CSharpCode - + IntermediateToken - - CSharp - BeginContext(162, 43, true); + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(205, 25, false); + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(230, 2, true); + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml new file mode 100644 index 0000000000..ed2648a986 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml @@ -0,0 +1,4 @@ +@using System.ComponentModel +@using System.Collections +@using System +@using System \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.cs new file mode 100644 index 0000000000..ad57e4a82b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable 1591 +namespace AspNetCore +{ + #line hidden + using TModel = global::System.Object; + 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; +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.ComponentModel; + +#line default +#line hidden +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.Collections; + +#line default +#line hidden +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.ir.txt new file mode 100644 index 0000000000..0163b00a81 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.ir.txt @@ -0,0 +1,46 @@ +Document - + NamespaceDeclaration - - AspNetCore + UsingDirective - - TModel = global::System.Object + 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 + UsingDirective - (1:0,1 [27] UsingDirectives.cshtml) - System.ComponentModel + UsingDirective - (31:1,1 [24] UsingDirectives.cshtml) - System.Collections + UsingDirective - (58:2,1 [12] UsingDirectives.cshtml) - System + UsingDirective - (73:3,1 [12] UsingDirectives.cshtml) - System + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 - (28:0,28 [2] UsingDirectives.cshtml) + IntermediateToken - (28:0,28 [2] UsingDirectives.cshtml) - Html - \n + HtmlContent - (55:1,25 [2] UsingDirectives.cshtml) + IntermediateToken - (55:1,25 [2] UsingDirectives.cshtml) - Html - \n + HtmlContent - (70:2,13 [2] UsingDirectives.cshtml) + IntermediateToken - (70:2,13 [2] UsingDirectives.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.mappings.txt new file mode 100644 index 0000000000..71a6bf2b2d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (1:0,1 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System.ComponentModel| +Generated Location: (461:13,0 [27] ) +|using System.ComponentModel| + +Source Location: (31:1,1 [24] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System.Collections| +Generated Location: (613:18,0 [24] ) +|using System.Collections| + +Source Location: (58:2,1 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System| +Generated Location: (762:23,0 [12] ) +|using System| + +Source Location: (73:3,1 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System| +Generated Location: (899:28,0 [12] ) +|using System| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.codegen.cs new file mode 100644 index 0000000000..1310cb0d8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.codegen.cs @@ -0,0 +1,55 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "452979e8e4dd77a84a4c50425dd3a162e265990d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives))] +namespace AspNetCore +{ + #line hidden + 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; +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.ComponentModel; + +#line default +#line hidden +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.Collections; + +#line default +#line hidden +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"452979e8e4dd77a84a4c50425dd3a162e265990d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.ir.txt new file mode 100644 index 0000000000..c3b71e0393 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.ir.txt @@ -0,0 +1,23 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives))] + NamespaceDeclaration - - AspNetCore + 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 + UsingDirective - (1:0,1 [29] UsingDirectives.cshtml) - System.ComponentModel + UsingDirective - (31:1,1 [26] UsingDirectives.cshtml) - System.Collections + UsingDirective - (58:2,1 [14] UsingDirectives.cshtml) - System + UsingDirective - (73:3,1 [12] UsingDirectives.cshtml) - System + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml new file mode 100644 index 0000000000..0430ccfc69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml @@ -0,0 +1,6 @@ +@addTagHelper "*, AppCode" +@{ + var foo = "Hello"; +} + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..90293d54ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -0,0 +1,90 @@ +// +#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_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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::AllTagHelper __AllTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" +global::System.Object __typeHelper = "*, 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() + { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + + var foo = "Hello"; + +#line default +#line hidden + __AllTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + __o = foo; + +#line default +#line hidden + __TestViewComponentTagHelper.firstName = string.Empty; + __AllTagHelper.Bar = " World"; + 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 Html { get; private set; } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")] + public class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper + { + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.String firstName { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync("Test", new { firstName }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..8e7497e7d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -0,0 +1,59 @@ +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_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (14:0,14 [12] ViewComponentTagHelper.cshtml) - "*, 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 - (26:0,26 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (26:0,26 [2] ViewComponentTagHelper.cshtml) - Html - \n + CSharpCode - (30:1,2 [26] ViewComponentTagHelper.cshtml) + IntermediateToken - (30:1,2 [26] ViewComponentTagHelper.cshtml) - CSharp - \n var foo = "Hello";\n + HtmlContent - (59:4,0 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (59:4,0 [2] ViewComponentTagHelper.cshtml) - Html - \n + TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - AllTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper + DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) + IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo + DefaultTagHelperProperty - (93:5,32 [6] ViewComponentTagHelper.cshtml) - bar - string AllTagHelper.Bar - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (93:5,32 [6] ViewComponentTagHelper.cshtml) + IntermediateToken - (93:5,32 [6] ViewComponentTagHelper.cshtml) - Html - World + DefaultTagHelperExecute - + Inject - + Inject - + Inject - + Inject - + Inject - + ViewComponentTagHelper - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..1af3082e0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +|"*, AppCode"| +Generated Location: (1465:26,37 [12] ) +|"*, AppCode"| + +Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +| + var foo = "Hello"; +| +Generated Location: (1942:41,2 [26] ) +| + var foo = "Hello"; +| + +Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +|foo| +Generated Location: (2393:49,22 [3] ) +|foo| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..7f617e58bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs @@ -0,0 +1,114 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf860c3a5e96240c9d41a0b950e49c1a165ca44d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"bf860c3a5e96240c9d41a0b950e49c1a165ca44d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bar", " World", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::AllTagHelper __AllTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + + var foo = "Hello"; + +#line default +#line hidden + BeginContext(59, 2, true); + WriteLiteral("\r\n"); + EndContext(); + BeginContext(61, 50, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("vc:test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __AllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__AllTagHelper); + __TestViewComponentTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestViewComponentTagHelper); + BeginWriteTagHelperAttribute(); +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + WriteLiteral(foo); + +#line default +#line hidden + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestViewComponentTagHelper.firstName = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("first-name", __TestViewComponentTagHelper.firstName, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __AllTagHelper.Bar = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + 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 Html { get; private set; } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")] + public class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper + { + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.String firstName { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync("Test", new { firstName }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..4c215a09d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt @@ -0,0 +1,46 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - bar - World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (30:1,2 [26] ViewComponentTagHelper.cshtml) + IntermediateToken - (30:1,2 [26] ViewComponentTagHelper.cshtml) - CSharp - \n var foo = "Hello";\n + CSharpCode - + IntermediateToken - - CSharp - BeginContext(59, 2, true); + HtmlContent - (59:4,0 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (59:4,0 [2] ViewComponentTagHelper.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(61, 50, false); + TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - AllTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper + DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) + IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo + PreallocatedTagHelperProperty - (93:5,32 [6] ViewComponentTagHelper.cshtml) - __tagHelperAttribute_0 - bar - Bar + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - + ViewComponentTagHelper - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml new file mode 100644 index 0000000000..eaf33e48ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml @@ -0,0 +1,2 @@ +@namespace Test.Namespace +

Hi There!

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs new file mode 100644 index 0000000000..209d3361f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test.Namespace +{ + #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_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml" +global::System.Object __typeHelper = nameof(Test.Namespace); + +#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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt new file mode 100644 index 0000000000..0af8488598 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test.Namespace + 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_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (11:0,11 [14] ViewWithNamespace.cshtml) - Test.Namespace + 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 - (27:1,0 [20] ViewWithNamespace.cshtml) + IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt new file mode 100644 index 0000000000..2b7a295e01 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (11:0,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml) +|Test.Namespace| +Generated Location: (818:19,44 [14] ) +|Test.Namespace| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs new file mode 100644 index 0000000000..fb4ec5e55e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs @@ -0,0 +1,39 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "471b74bb73c8ae8e0ed24c654340198b9b4a1ec8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] +namespace Test.Namespace +{ + #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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"471b74bb73c8ae8e0ed24c654340198b9b4a1ec8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(27, 20, true); + WriteLiteral("

Hi There!

\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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt new file mode 100644 index 0000000000..5a45f13f76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt @@ -0,0 +1,30 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] + NamespaceDeclaration - - Test.Namespace + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(27, 20, true); + HtmlContent - (27:1,0 [20] ViewWithNamespace.cshtml) + IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml new file mode 100644 index 0000000000..f4e110d289 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml @@ -0,0 +1 @@ +@inject IHtmlHelper Helper \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..363ff66ca5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -0,0 +1,58 @@ +// +#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__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" +IHtmlHelper __typeHelper = default; + +#line default +#line hidden + } + ))(); + ((System.Action)(() => { +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" +global::System.Object Helper = 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 IHtmlHelper Helper { 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..b677049ce1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -0,0 +1,40 @@ +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__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (8:0,8 [19] _ViewImports.cshtml) - IHtmlHelper + DirectiveToken - (28:0,28 [6] _ViewImports.cshtml) - Helper + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..6b845596b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) +|IHtmlHelper| +Generated Location: (760:19,0 [19] ) +|IHtmlHelper| + +Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) +|Helper| +Generated Location: (1006:27,22 [6] ) +|Helper| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..346428fa0d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "74c90591b68437a0868e91dc714ea9827ab8e03a" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"74c90591b68437a0868e91dc714ea9827ab8e03a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 IHtmlHelper Helper { 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..addc2754ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs new file mode 100644 index 0000000000..f68443c5b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs @@ -0,0 +1,160 @@ +#pragma checksum "TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "78993008d95836bec2b9175d4294bf7bd5f5f109" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_InstrumentationPassIntegrationTest_BasicTest), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml")] +[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_InstrumentationPassIntegrationTest_BasicTest))] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"78993008d95836bec2b9175d4294bf7bd5f5f109", @"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml")] + public class TestFiles_IntegrationTests_InstrumentationPassIntegrationTest_BasicTest : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("unbound", new global::Microsoft.AspNetCore.Html.HtmlString("foo"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::FormTagHelper __FormTagHelper; + private global::InputTagHelper __InputTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + BeginContext(31, 28, true); + BeginContext(31, 28, true); + WriteLiteral("Hola\r\n"); + EndContext(); + EndContext(); + BeginContext(61, 7, false); + BeginContext(61, 7, false); +#line 3 "TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml" +Write("Hello"); + +#line default +#line hidden + EndContext(); + EndContext(); + BeginContext(69, 2, true); + BeginContext(69, 2, true); + WriteLiteral("\r\n"); + EndContext(); + EndContext(); + BeginContext(71, 87, false); + BeginContext(71, 87, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + BeginContext(91, 6, true); + BeginContext(91, 6, true); + WriteLiteral("\r\n "); + EndContext(); + EndContext(); + BeginContext(97, 52, false); + BeginContext(97, 52, false); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.FooProp = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); +#line 5 "TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml" +__InputTagHelper.BarProp = DateTime.Now; + +#line default +#line hidden + __tagHelperExecutionContext.AddTagHelperAttribute("date", __InputTagHelper.BarProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + EndContext(); + BeginContext(149, 2, true); + BeginContext(149, 2, true); + WriteLiteral("\r\n"); + EndContext(); + EndContext(); + } + ); + __FormTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__FormTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + EndContext(); + EndContext(); + BeginContext(158, 31, true); + BeginContext(158, 31, true); + WriteLiteral("\r\n\r\nHere is some content "); + EndContext(); + EndContext(); + BeginContext(207, 9, true); + BeginContext(207, 9, true); + WriteLiteral("\r\n"); + EndContext(); + EndContext(); + BeginContext(217, 29, false); + BeginContext(217, 29, false); +#line 9 "TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml" +Write(Foo(item => new global::Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + BeginContext(222, 24, true); + BeginContext(222, 24, true); + WriteLiteral("Hello world"); + EndContext(); + EndContext(); + PopWriter(); +} +))); + +#line default +#line hidden + EndContext(); + 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml new file mode 100644 index 0000000000..8b4fdef616 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml @@ -0,0 +1,9 @@ +@addTagHelper *, TestAssembly +Hola +@("Hello") +
+ +
+ +Here is some content @*with a comment*@ +@Foo(@Hello world) \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt new file mode 100644 index 0000000000..a54315062c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt @@ -0,0 +1,160 @@ +Document - + RazorCompiledItemAttribute - + CSharpCode - + IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_InstrumentationPassIntegrationTest_BasicTest))] + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_InstrumentationPassIntegrationTest_BasicTest - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - unbound - foo - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::FormTagHelper - __FormTagHelper + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - + IntermediateToken - - CSharp - BeginContext(31, 28, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(31, 28, true); + HtmlContent - (31:1,0 [28] BasicTest.cshtml) + IntermediateToken - (31:1,0 [5] BasicTest.cshtml) - Html - + IntermediateToken - (46:1,15 [4] BasicTest.cshtml) - Html - Hola + IntermediateToken - (50:1,19 [7] BasicTest.cshtml) - Html - + IntermediateToken - (57:1,26 [2] BasicTest.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(61, 7, false); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(61, 7, false); + CSharpExpression - (61:2,2 [7] BasicTest.cshtml) + IntermediateToken - (61:2,2 [7] BasicTest.cshtml) - CSharp - "Hello" + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(69, 2, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(69, 2, true); + HtmlContent - (69:2,10 [2] BasicTest.cshtml) + IntermediateToken - (69:2,10 [2] BasicTest.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(71, 87, false); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(71, 87, false); + TagHelper - (71:3,0 [87] BasicTest.cshtml) - form - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpCode - + IntermediateToken - - CSharp - BeginContext(91, 6, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(91, 6, true); + HtmlContent - (91:3,20 [6] BasicTest.cshtml) + IntermediateToken - (91:3,20 [6] BasicTest.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(97, 52, false); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(97, 52, false); + TagHelper - (97:4,4 [52] BasicTest.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + PreallocatedTagHelperProperty - (110:4,17 [5] BasicTest.cshtml) - __tagHelperAttribute_0 - value - FooProp + DefaultTagHelperProperty - (121:4,28 [13] BasicTest.cshtml) - date - System.DateTime InputTagHelper.BarProp - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (122:4,29 [12] BasicTest.cshtml) + IntermediateToken - (122:4,29 [12] BasicTest.cshtml) - CSharp - DateTime.Now + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(149, 2, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(149, 2, true); + HtmlContent - (149:4,56 [2] BasicTest.cshtml) + IntermediateToken - (149:4,56 [2] BasicTest.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + DefaultTagHelperCreate - - FormTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(158, 31, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(158, 31, true); + HtmlContent - (158:5,7 [31] BasicTest.cshtml) + IntermediateToken - (158:5,7 [4] BasicTest.cshtml) - Html - \n\n + IntermediateToken - (162:7,0 [5] BasicTest.cshtml) - Html - + IntermediateToken - (168:7,6 [21] BasicTest.cshtml) - Html - Here is some content + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(207, 9, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(207, 9, true); + HtmlContent - (207:7,45 [9] BasicTest.cshtml) + IntermediateToken - (207:7,45 [7] BasicTest.cshtml) - Html - + IntermediateToken - (214:7,52 [2] BasicTest.cshtml) - Html - \n + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(217, 29, false); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(217, 29, false); + CSharpExpression - (217:8,1 [29] BasicTest.cshtml) + IntermediateToken - (217:8,1 [4] BasicTest.cshtml) - CSharp - Foo( + Template - (222:8,6 [24] BasicTest.cshtml) + CSharpCode - + IntermediateToken - - CSharp - BeginContext(222, 24, true); + CSharpCode - + IntermediateToken - - CSharp - BeginContext(222, 24, true); + HtmlContent - (222:8,6 [24] BasicTest.cshtml) + IntermediateToken - (222:8,6 [5] BasicTest.cshtml) - Html - + IntermediateToken - (228:8,12 [11] BasicTest.cshtml) - Html - Hello world + IntermediateToken - (239:8,23 [7] BasicTest.cshtml) - Html - + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + IntermediateToken - (246:8,30 [1] BasicTest.cshtml) - CSharp - ) + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + CSharpCode - + IntermediateToken - - CSharp - EndContext(); + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs new file mode 100644 index 0000000000..bf56cb729f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -0,0 +1,485 @@ +// 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.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class ViewComponentTagHelperDescriptorFactoryTest + { + private static readonly Assembly _assembly = typeof(ViewComponentTagHelperDescriptorFactoryTest).GetTypeInfo().Assembly; + + [Fact] + public void CreateDescriptor_UnderstandsStringParameters() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(StringParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__StringParameterViewComponentTagHelper", + typeof(StringParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__StringParameterViewComponentTagHelper") + .DisplayName("StringParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:string-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "StringParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_UnderstandsVariousParameterTypes() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(VariousParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__VariousParameterViewComponentTagHelper", + typeof(VariousParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__VariousParameterViewComponentTagHelper") + .DisplayName("VariousParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:various-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("test-enum")) + .RequireAttributeDescriptor(attribute => attribute.Name("test-string")) + .RequireAttributeDescriptor(attribute => attribute.Name("baz"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("test-enum") + .PropertyName("testEnum") + .TypeName(typeof(VariousParameterViewComponent).FullName + "." + nameof(VariousParameterViewComponent.TestEnum)) + .AsEnum() + .DisplayName(typeof(VariousParameterViewComponent).FullName + "." + nameof(VariousParameterViewComponent.TestEnum) + " VariousParameterViewComponentTagHelper.testEnum")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("test-string") + .PropertyName("testString") + .TypeName(typeof(string).FullName) + .DisplayName("string VariousParameterViewComponentTagHelper.testString")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("baz") + .PropertyName("baz") + .TypeName(typeof(int).FullName) + .DisplayName("int VariousParameterViewComponentTagHelper.baz")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "VariousParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_UnderstandsGenericParameters() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(GenericParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__GenericParameterViewComponentTagHelper", + typeof(GenericParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__GenericParameterViewComponentTagHelper") + .DisplayName("GenericParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:generic-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("Foo") + .TypeName("System.Collections.Generic.List") + .DisplayName("System.Collections.Generic.List GenericParameterViewComponentTagHelper.Foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("Bar") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionaryAttribute("bar-", typeof(int).FullName) + .DisplayName("System.Collections.Generic.Dictionary GenericParameterViewComponentTagHelper.Bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "GenericParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_ForSyncViewComponentWithInvokeInBaseType_Works() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__SyncDerivedViewComponentTagHelper", + typeof(SyncDerivedViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__SyncDerivedViewComponentTagHelper") + .DisplayName("SyncDerivedViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:sync-derived") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string SyncDerivedViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string SyncDerivedViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "SyncDerived") + .Build(); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncDerivedViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_ForAsyncViewComponentWithInvokeInBaseType_Works() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__AsyncDerivedViewComponentTagHelper", + typeof(AsyncDerivedViewComponent).Assembly.GetName().Name) + .TypeName("__Generated__AsyncDerivedViewComponentTagHelper") + .DisplayName("AsyncDerivedViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("vc:async-derived")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "AsyncDerived") + .Build(); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncDerivedViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(ViewComponentWithoutInvokeMethod).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoInstanceInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(StaticInvokeAsyncViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoPublicInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(NonPublicInvokeAsyncViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_UnderstandsGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Empty(descriptor.GetAllDiagnostics()); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_UnderstandsNonGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithNonGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Empty(descriptor.GetAllDiagnostics()); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_DoesNotUnderstandVoid() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithString).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AsyncMethod_ShouldReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_DoesNotUnderstandString() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithString).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AsyncMethod_ShouldReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandVoid() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithVoid).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_ShouldReturnValue.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandNonGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithNonGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_CannotReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_CannotReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponent_WithAmbiguousMethods() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(DerivedViewComponentWithAmbiguity).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AmbiguousMethods.Id, diagnostic.Id); + } + } + + public class StringParameterViewComponent + { + public string Invoke(string foo, string bar) => null; + } + + public class VariousParameterViewComponent + { + public string Invoke(TestEnum testEnum, string testString, int baz = 5) => null; + + public enum TestEnum + { + A = 1, + B = 2, + C = 3 + } + } + + public class GenericParameterViewComponent + { + public string Invoke(List Foo, Dictionary Bar) => null; + } + + public class ViewComponentWithoutInvokeMethod + { + } + + public class AsyncViewComponentWithGenericTask + { + public Task InvokeAsync() => null; + } + + public class AsyncViewComponentWithNonGenericTask + { + public Task InvokeAsync() => null; + } + + public class AsyncViewComponentWithVoid + { + public void InvokeAsync() { } + } + + public class AsyncViewComponentWithString + { + public string InvokeAsync() => null; + } + + public class SyncViewComponentWithVoid + { + public void Invoke() { } + } + + public class SyncViewComponentWithNonGenericTask + { + public Task Invoke() => null; + } + + public class SyncViewComponentWithGenericTask + { + public Task Invoke() => null; + } + + public class SyncDerivedViewComponent : StringParameterViewComponent + { + } + + public class AsyncDerivedViewComponent : AsyncViewComponentWithNonGenericTask + { + } + + public class DerivedViewComponentWithAmbiguity : AsyncViewComponentWithNonGenericTask + { + public string Invoke() => null; + } + + public class StaticInvokeAsyncViewComponent + { + public static Task InvokeAsync() => null; + } + + public class NonPublicInvokeAsyncViewComponent + { + protected Task InvokeAsync() => null; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..d78e7b0a82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs @@ -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.IO; +using System.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + // This is just a basic integration test. There are detailed tests for the VCTH visitor and descriptor factory. + public class ViewComponentTagHelperDescriptorProviderTest + { + [Fact] + public void DescriptorProvider_FindsVCTH() + { + // Arrange + var code = @" + public class StringParameterViewComponent + { + public string Invoke(string foo, string bar) => null; + } +"; + + var compilation = MvcShim.BaseCompilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(code)); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ViewComponentTagHelperDescriptorProvider() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__StringParameterViewComponentTagHelper", + TestCompilation.AssemblyName) + .TypeName("__Generated__StringParameterViewComponentTagHelper") + .DisplayName("StringParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:string-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "StringParameter") + .Build(); + + // Act + provider.Execute(context); + + // Assert + Assert.Single(context.Results, d => TagHelperDescriptorComparer.Default.Equals(d, expectedDescriptor)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs new file mode 100644 index 0000000000..00330a4eef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperPassTest.cs @@ -0,0 +1,275 @@ +// 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.Linq; +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.Version2_X +{ + public class ViewComponentTagHelperPassTest + { + [Fact] + public void ViewComponentTagHelperPass_Execute_IgnoresRegularTagHelper() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly") + .TypeName("TestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var @class = FindClassNode(irDocument); + Assert.Equal(3, @class.Children.Count); // No class node created for a VCTH + for (var i = 0; i < @class.Children.Count; i++) + { + Assert.IsNotType(@class.Children[i]); + } + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("Foo")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(vcthFullName, Assert.IsType(tagHelper.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(tagHelper.Children[2]).PropertyName); + + + var @class = FindClassNode(irDocument); + Assert.Equal(4, @class.Children.Count); + + Assert.IsType(@class.Children.Last()); + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper_WithIndexer() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .PropertyName("Tags") + .AsDictionaryAttribute("foo-", "System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(vcthFullName, Assert.IsType(tagHelper.Children[1]).TypeName); + Assert.IsType(tagHelper.Children[2]); + + var @class = FindClassNode(irDocument); + Assert.Equal(4, @class.Children.Count); + + Assert.IsType(@class.Children[3]); + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper_Nested() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper *, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("PTestTagHelper", "TestAssembly") + .TypeName("PTestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .PropertyName("Foo") + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .PropertyName("Foo") + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var outerTagHelper = FindTagHelperNode(irDocument); + Assert.Equal("PTestTagHelper", Assert.IsType(outerTagHelper.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(outerTagHelper.Children[2]).PropertyName); + + var vcth = FindTagHelperNode(outerTagHelper.Children[0]); + Assert.Equal(vcthFullName, Assert.IsType(vcth.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(vcth.Children[2]).PropertyName); + + + var @class = FindClassNode(irDocument); + Assert.Equal(5, @class.Children.Count); + + Assert.IsType(@class.Children.Last()); + } + + private RazorCodeDocument CreateDocument(string content) + { + var source = RazorSourceDocument.Create(content, "test.cshtml"); + return RazorCodeDocument.Create(source); + } + + private RazorProjectEngine CreateProjectEngine(params TagHelperDescriptor[] tagHelpers) + { + return RazorProjectEngine.Create(b => + { + b.Features.Add(new MvcViewDocumentClassifierPass()); + + b.Features.Add(new TestTagHelperFeature(tagHelpers)); + }); + } + + private DocumentIntermediateNode CreateIRDocument(RazorProjectEngine projectEngine, RazorCodeDocument codeDocument) + { + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorDirectiveClassifierPhase) + { + break; + } + } + + // We also expect the default tag helper pass to run first. + var documentNode = codeDocument.GetDocumentIntermediateNode(); + + var defaultTagHelperPass = projectEngine.EngineFeatures.OfType().Single(); + defaultTagHelperPass.Execute(codeDocument, documentNode); + + return codeDocument.GetDocumentIntermediateNode(); + } + + private ClassDeclarationIntermediateNode FindClassNode(IntermediateNode node) + { + var visitor = new ClassDeclarationNodeVisitor(); + visitor.Visit(node); + return visitor.Node; + } + + private TagHelperIntermediateNode FindTagHelperNode(IntermediateNode node) + { + var visitor = new TagHelperNodeVisitor(); + visitor.Visit(node); + return visitor.Node; + } + + private class ClassDeclarationNodeVisitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode Node { get; set; } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + Node = node; + } + } + + private class TagHelperNodeVisitor : IntermediateNodeWalker + { + public TagHelperIntermediateNode Node { get; set; } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + Node = node; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperTargetExtensionTest.cs new file mode 100644 index 0000000000..c5c148b6a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperTargetExtensionTest.cs @@ -0,0 +1,120 @@ +// 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.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class ViewComponentTagHelperTargetExtensionTest + { + [Fact] + public void WriteViewComponentTagHelper_GeneratesViewComponentTagHelper() + { + // Arrange + var tagHelper = TagHelperDescriptorBuilder + .Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("Foo")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build(); + + var extension = new ViewComponentTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new ViewComponentTagHelperIntermediateNode() + { + ClassName = "__Generated__TagCloudViewComponentTagHelper", + TagHelper = tagHelper + }; + + // Act + extension.WriteViewComponentTagHelper(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(""tagcloud"")] +public class __Generated__TagCloudViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TagCloudViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Int32 Foo { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync(""TagCloud"", new { Foo }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteViewComponentTagHelper_GeneratesViewComponentTagHelper_WithIndexer() + { + // Arrange + var tagHelper = TagHelperDescriptorBuilder + .Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .PropertyName("Tags") + .AsDictionaryAttribute("foo-", "System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build(); + + var extension = new ViewComponentTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new ViewComponentTagHelperIntermediateNode() + { + ClassName = "__Generated__TagCloudViewComponentTagHelper", + TagHelper = tagHelper + }; + + // Act + extension.WriteViewComponentTagHelper(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(""tagcloud"")] +public class __Generated__TagCloudViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper _helper = null; + public __Generated__TagCloudViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + _helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Collections.Generic.Dictionary Tags { get; set; } + = new System.Collections.Generic.Dictionary(); + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) + { + (_helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var content = await _helper.InvokeAsync(""TagCloud"", new { Tags }); + output.TagName = null; + output.Content.SetHtmlContent(content); + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs new file mode 100644 index 0000000000..ad75c89bfb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTypeVisitorTest.cs @@ -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; +using System.Collections.Generic; +using System.Reflection; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X +{ + public class ViewComponentTypeVisitorTest + { + private static readonly Assembly _assembly = typeof(ViewComponentTypeVisitorTest).GetTypeInfo().Assembly; + + private static CSharpCompilation Compilation { get; } = TestCompilation.Create(_assembly); + + // In practice MVC will provide a marker attribute for ViewComponents. To prevent a circular reference between MVC and Razor + // we can use a test class as a marker. + private static INamedTypeSymbol TestViewComponentAttributeSymbol { get; } = Compilation.GetTypeByMetadataName(typeof(TestViewComponentAttribute).FullName); + private static INamedTypeSymbol TestNonViewComponentAttributeSymbol { get; } = Compilation.GetTypeByMetadataName(typeof(TestNonViewComponentAttribute).FullName); + + [Fact] + public void IsViewComponent_PlainViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_PlainViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_DecoratedViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_DecoratedVC).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_InheritedViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_InheritedVC).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_AbstractViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_AbstractViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_GenericViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_GenericViewComponent<>).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_InternalViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InternalViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_DecoratedNonViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_DecoratedViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_InheritedNonViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InheritedViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + public abstract class Invalid_AbstractViewComponent + { + } + + public class Invalid_GenericViewComponent + { + } + + internal class Invalid_InternalViewComponent + { + } + + public class Valid_PlainViewComponent + { + } + + [TestViewComponent] + public class Valid_DecoratedVC + { + } + + public class Valid_InheritedVC : Valid_DecoratedVC + { + } + + [TestNonViewComponent] + public class Invalid_DecoratedViewComponent + { + } + + [TestViewComponent] + public class Invalid_InheritedViewComponent : Invalid_DecoratedViewComponent + { + } + + public class TestViewComponentAttribute : Attribute + { + } + + public class TestNonViewComponentAttribute : Attribute + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/xunit.runner.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/xunit.runner.json new file mode 100644 index 0000000000..fcf172c8fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "methodDisplay": "method", + "shadowCopy": false +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ExtensionInitializer.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ExtensionInitializer.cs new file mode 100644 index 0000000000..8c650ebedb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ExtensionInitializer.cs @@ -0,0 +1,16 @@ +// 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.Components; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class ExtensionInitializer : RazorExtensionInitializer + { + public override void Initialize(RazorProjectEngineBuilder builder) + { + RazorExtensions.Register(builder); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/IInjectTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/IInjectTargetExtension.cs new file mode 100644 index 0000000000..89f74d5aaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/IInjectTargetExtension.cs @@ -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 +{ + public interface IInjectTargetExtension : ICodeTargetExtension + { + void WriteInjectProperty(CodeRenderingContext context, InjectIntermediateNode node); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/IViewComponentTagHelperTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/IViewComponentTagHelperTargetExtension.cs new file mode 100644 index 0000000000..1f303e7422 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/IViewComponentTagHelperTargetExtension.cs @@ -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 +{ + public interface IViewComponentTagHelperTargetExtension : ICodeTargetExtension + { + void WriteViewComponentTagHelper(CodeRenderingContext context, ViewComponentTagHelperIntermediateNode node); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectDirective.cs new file mode 100644 index 0000000000..4282ea559f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectDirective.cs @@ -0,0 +1,131 @@ +// 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 +{ + 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) + { + if (documentNode.DocumentKind != RazorPageDocumentClassifierPass.RazorPageDocumentKind && + documentNode.DocumentKind != MvcViewDocumentClassifierPass.MvcViewDocumentKind) + { + // Not a MVC file. Skip. + return; + } + + var visitor = new Visitor(); + visitor.Visit(documentNode); + var modelType = ModelDirective.GetModelType(documentNode); + + var properties = new HashSet(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("", "<" + 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 Directives { get; } = new List(); + + 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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectIntermediateNode.cs new file mode 100644 index 0000000000..572d8bb1dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectIntermediateNode.cs @@ -0,0 +1,58 @@ +// 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; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + 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(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(); + if (extension == null) + { + ReportMissingCodeTargetExtension(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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectTargetExtension.cs new file mode 100644 index 0000000000..d416d3aa0a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/InjectTargetExtension.cs @@ -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 +{ + 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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj new file mode 100644 index 0000000000..afa5ecd679 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj @@ -0,0 +1,20 @@ + + + + ASP.NET Core design time hosting infrastructure for the Razor view engine. + netstandard2.0 + $(PackageTags);aspnetcoremvc + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ModelDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ModelDirective.cs new file mode 100644 index 0000000000..4e0973f14a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ModelDirective.cs @@ -0,0 +1,159 @@ +// 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 +{ + 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; + } + } + + if (document.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind) + { + return visitor.Class.ClassName; + } + else + { + 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) + { + if (documentNode.DocumentKind != RazorPageDocumentClassifierPass.RazorPageDocumentKind && + documentNode.DocumentKind != MvcViewDocumentClassifierPass.MvcViewDocumentKind) + { + // Not a MVC file. Skip. + return; + } + + 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("", "<" + modelType + ">"); + visitor.Class.BaseType = baseType; + } + } + + private class Visitor : IntermediateNodeWalker + { + public NamespaceDeclarationIntermediateNode Namespace { get; private set; } + + public ClassDeclarationIntermediateNode Class { get; private set; } + + public IList ModelDirectives { get; } = new List(); + + 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 + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ModelExpressionPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ModelExpressionPass.cs new file mode 100644 index 0000000000..7b44002ff9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ModelExpressionPass.cs @@ -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 +{ + 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 TagHelpers { get; } = new List(); + + 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); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/MvcImportProjectFeature.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/MvcImportProjectFeature.cs new file mode 100644 index 0000000000..b85402ef79 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/MvcImportProjectFeature.cs @@ -0,0 +1,97 @@ +// 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 +{ + internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature + { + private const string ImportsFileName = "_ViewImports.cshtml"; + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + // Don't add MVC imports for a component + if (FileKinds.IsComponent(projectItem.FileKind)) + { + return Array.Empty(); + } + + var imports = new List(); + 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 imports) + { + imports.Add(DefaultDirectivesProjectItem.Instance); + } + + // Internal for testing + internal void AddHierarchicalImports(RazorProjectItem projectItem, List 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 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 +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor +@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/MvcViewDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/MvcViewDocumentClassifierPass.cs new file mode 100644 index 0000000000..7ab07afc8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/MvcViewDocumentClassifierPass.cs @@ -0,0 +1,90 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + 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); + + if (!codeDocument.TryComputeNamespace(fallbackToRootNamespace: false, out var namespaceName)) + { + @namespace.Content = "AspNetCore"; + } + else + { + @namespace.Content = namespaceName; + } + + if (!TryComputeClassName(codeDocument, out var className)) + { + // 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 = Checksum.BytesToString(codeDocument.Source.GetChecksum()); + @class.ClassName = $"AspNetCore_{checksum}"; + } + else + { + @class.ClassName = className; + } + + + @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage"; + @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 bool TryComputeClassName(RazorCodeDocument codeDocument, out string className) + { + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; + if (string.IsNullOrEmpty(filePath)) + { + className = null; + return false; + } + + className = GetClassNameFromPath(filePath); + return true; + } + + private static string GetClassNameFromPath(string path) + { + const string cshtmlExtension = ".cshtml"; + + if (string.IsNullOrEmpty(path)) + { + return path; + } + + if (path.EndsWith(cshtmlExtension, StringComparison.OrdinalIgnoreCase)) + { + path = path.Substring(0, path.Length - cshtmlExtension.Length); + } + + return CSharpIdentifier.SanitizeIdentifier(path); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/PageDirective.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/PageDirective.cs new file mode 100644 index 0000000000..322c6564ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/PageDirective.cs @@ -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 System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class PageDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "page", + DirectiveKind.SingleLine, + builder => + { + builder.AddOptionalStringToken(Resources.PageDirective_RouteToken_Name, Resources.PageDirective_RouteToken_Description); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.Description = Resources.PageDirective_Description; + }); + + private PageDirective(string routeTemplate, IntermediateNode directiveNode) + { + RouteTemplate = routeTemplate; + DirectiveNode = directiveNode; + } + + public string RouteTemplate { get; } + + public IntermediateNode DirectiveNode { get; } + + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive); + return builder; + } + + public static bool TryGetPageDirective(DocumentIntermediateNode documentNode, out PageDirective pageDirective) + { + var visitor = new Visitor(); + for (var i = 0; i < documentNode.Children.Count; i++) + { + visitor.Visit(documentNode.Children[i]); + } + + if (visitor.DirectiveTokens == null) + { + pageDirective = null; + return false; + } + + var tokens = visitor.DirectiveTokens.ToList(); + string routeTemplate = null; + if (tokens.Count > 0) + { + routeTemplate = TrimQuotes(tokens[0].Content); + } + + pageDirective = new PageDirective(routeTemplate, visitor.DirectiveNode); + return true; + } + + private static string TrimQuotes(string content) + { + // Tokens aren't captured if they're malformed. Therefore, this method will + // always be called with a valid token content. + Debug.Assert(content.Length >= 2); + Debug.Assert(content.StartsWith("\"", StringComparison.Ordinal)); + Debug.Assert(content.EndsWith("\"", StringComparison.Ordinal)); + + return content.Substring(1, content.Length - 2); + } + + private class Visitor : IntermediateNodeWalker + { + public IntermediateNode DirectiveNode { get; private set; } + + public IEnumerable DirectiveTokens { get; private set; } + + public override void VisitDirective(DirectiveIntermediateNode node) + { + if (node.Directive == Directive) + { + DirectiveNode = node; + DirectiveTokens = node.Tokens; + } + } + + public override void VisitMalformedDirective(MalformedDirectiveIntermediateNode node) + { + if (DirectiveTokens == null && node.Directive == Directive) + { + DirectiveNode = node; + DirectiveTokens = node.Tokens; + } + } + } + + #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); + return builder; + } + #endregion + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/PagesPropertyInjectionPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/PagesPropertyInjectionPass.cs new file mode 100644 index 0000000000..4a47275e13 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/PagesPropertyInjectionPass.cs @@ -0,0 +1,57 @@ +// 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; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class PagesPropertyInjectionPass : IntermediateNodePassBase, IRazorOptimizationPass + { + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (documentNode.DocumentKind != RazorPageDocumentClassifierPass.RazorPageDocumentKind) + { + return; + } + + var modelType = ModelDirective.GetModelType(documentNode); + var visitor = new Visitor(); + visitor.Visit(documentNode); + + var @class = visitor.Class; + + var viewDataType = $"global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<{modelType}>"; + var vddProperty = new CSharpCodeIntermediateNode(); + vddProperty.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"public {viewDataType} ViewData => ({viewDataType})PageContext?.ViewData;", + }); + @class.Children.Add(vddProperty); + + var modelProperty = new CSharpCodeIntermediateNode(); + modelProperty.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"public {modelType} Model => ViewData.Model;", + }); + @class.Children.Add(modelProperty); + } + + private class Visitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode Class { get; private set; } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + if (Class == null) + { + Class = node; + } + + base.VisitClassDeclaration(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..7d8a47bc67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Properties/AssemblyInfo.cs @@ -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; +using Microsoft.AspNetCore.Razor.Language; + +[assembly: ProvideRazorExtensionInitializer("MVC-3.0", typeof(ExtensionInitializer))] + +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensions.cs new file mode 100644 index 0000000000..dfaebba007 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensions.cs @@ -0,0 +1,48 @@ +// 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 +{ + public static class RazorExtensions + { + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + InjectDirective.Register(builder); + ModelDirective.Register(builder); + PageDirective.Register(builder); + + SectionDirective.Register(builder); + + builder.Features.Add(new DefaultTagHelperDescriptorProvider()); + builder.Features.Add(new ViewComponentTagHelperDescriptorProvider()); + + builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension()); + builder.AddTargetExtension(new TemplateTargetExtension() + { + TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult", + }); + + builder.Features.Add(new ModelExpressionPass()); + builder.Features.Add(new PagesPropertyInjectionPass()); + builder.Features.Add(new ViewComponentTagHelperPass()); + builder.Features.Add(new RazorPageDocumentClassifierPass()); + builder.Features.Add(new MvcViewDocumentClassifierPass()); + + builder.Features.Add(new MvcImportProjectFeature()); + + // The default C# language version for what this Razor configuration supports. + builder.SetCSharpLanguageVersion(LanguageVersion.CSharp8); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensionsDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensionsDiagnosticFactory.cs new file mode 100644 index 0000000000..74adb4fe93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensionsDiagnosticFactory.cs @@ -0,0 +1,131 @@ +// 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 +{ + 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; + } + + internal static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3905", + () => Resources.PageDirectiveCannotBeImported, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_CannotBeImported(SourceSpan source) + { + var fileName = Path.GetFileName(source.FilePath); + var diagnostic = RazorDiagnostic.Create(PageDirective_CannotBeImported, source, PageDirective.Directive.Directive, fileName); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor PageDirective_MustExistAtTheTopOfFile = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3906", + () => Resources.PageDirectiveMustExistAtTheTopOfFile, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_MustExistAtTheTopOfFile(SourceSpan source) + { + var fileName = Path.GetFileName(source.FilePath); + var diagnostic = RazorDiagnostic.Create(PageDirective_MustExistAtTheTopOfFile, source, PageDirective.Directive.Directive); + + return diagnostic; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorPageDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorPageDocumentClassifierPass.cs new file mode 100644 index 0000000000..567754cd66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorPageDocumentClassifierPass.cs @@ -0,0 +1,181 @@ +// 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.Diagnostics; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class RazorPageDocumentClassifierPass : DocumentClassifierPassBase + { + public static readonly string RazorPageDocumentKind = "mvc.1.0.razor-page"; + public static readonly string RouteTemplateKey = "RouteTemplate"; + + private static readonly RazorProjectEngine LeadingDirectiveParsingEngine = RazorProjectEngine.Create( + RazorConfiguration.Create(RazorLanguageVersion.Version_3_0, "leading-directive-parser", Array.Empty()), + RazorProjectFileSystem.Create("/"), + builder => + { + for (var i = builder.Phases.Count - 1; i >= 0; i--) + { + var phase = builder.Phases[i]; + builder.Phases.RemoveAt(i); + if (phase is IRazorDocumentClassifierPhase) + { + break; + } + } + + RazorExtensions.Register(builder); + builder.Features.Add(new LeadingDirectiveParserOptionsFeature()); + }); + + protected override string DocumentKind => RazorPageDocumentKind; + + protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + return PageDirective.TryGetPageDirective(documentNode, out var pageDirective); + } + + protected override void OnDocumentStructureCreated( + RazorCodeDocument codeDocument, + NamespaceDeclarationIntermediateNode @namespace, + ClassDeclarationIntermediateNode @class, + MethodDeclarationIntermediateNode method) + { + base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); + + if (!codeDocument.TryComputeNamespace(fallbackToRootNamespace: false, out var namespaceName)) + { + @namespace.Content = "AspNetCore"; + } + else + { + @namespace.Content = namespaceName; + } + + if (!TryComputeClassName(codeDocument, out var className)) + { + // 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 = Checksum.BytesToString(codeDocument.Source.GetChecksum()); + @class.ClassName = $"AspNetCore_{checksum}"; + } + else + { + @class.ClassName = className; + } + + @class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page"; + @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}"; + + var document = codeDocument.GetDocumentIntermediateNode(); + PageDirective.TryGetPageDirective(document, out var pageDirective); + + EnsureValidPageDirective(codeDocument, pageDirective); + + AddRouteTemplateMetadataAttribute(@namespace, @class, pageDirective); + } + + private static void AddRouteTemplateMetadataAttribute(NamespaceDeclarationIntermediateNode @namespace, ClassDeclarationIntermediateNode @class, PageDirective pageDirective) + { + if (string.IsNullOrEmpty(pageDirective.RouteTemplate)) + { + return; + } + + var classIndex = @namespace.Children.IndexOf(@class); + if (classIndex == -1) + { + return; + } + + var metadataAttributeNode = new RazorCompiledItemMetadataAttributeIntermediateNode + { + Key = RouteTemplateKey, + Value = pageDirective.RouteTemplate, + }; + // Metadata attributes need to be inserted right before the class declaration. + @namespace.Children.Insert(classIndex, metadataAttributeNode); + } + + private void EnsureValidPageDirective(RazorCodeDocument codeDocument, PageDirective pageDirective) + { + Debug.Assert(pageDirective != null); + + if (pageDirective.DirectiveNode.IsImported()) + { + pageDirective.DirectiveNode.Diagnostics.Add( + RazorExtensionsDiagnosticFactory.CreatePageDirective_CannotBeImported(pageDirective.DirectiveNode.Source.Value)); + } + else + { + // The document contains a page directive and it is not imported. + // We now want to make sure this page directive exists at the top of the file. + // We are going to do that by re-parsing the document until the very first line that is not Razor comment + // or whitespace. We then make sure the page directive still exists in the re-parsed IR tree. + var leadingDirectiveCodeDocument = RazorCodeDocument.Create(codeDocument.Source); + LeadingDirectiveParsingEngine.Engine.Process(leadingDirectiveCodeDocument); + + var leadingDirectiveDocumentNode = leadingDirectiveCodeDocument.GetDocumentIntermediateNode(); + if (!PageDirective.TryGetPageDirective(leadingDirectiveDocumentNode, out var _)) + { + // The page directive is not the leading directive. Add an error. + pageDirective.DirectiveNode.Diagnostics.Add( + RazorExtensionsDiagnosticFactory.CreatePageDirective_MustExistAtTheTopOfFile(pageDirective.DirectiveNode.Source.Value)); + } + } + } + + private class LeadingDirectiveParserOptionsFeature : RazorEngineFeatureBase, IConfigureRazorParserOptionsFeature + { + public int Order { get; } + + public void Configure(RazorParserOptionsBuilder options) + { + options.ParseLeadingDirectives = true; + } + } + + private bool TryComputeClassName(RazorCodeDocument codeDocument, out string className) + { + var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; + if (string.IsNullOrEmpty(filePath)) + { + className = null; + return false; + } + + className = GetClassNameFromPath(filePath); + return true; + } + + private static string GetClassNameFromPath(string path) + { + const string cshtmlExtension = ".cshtml"; + + if (string.IsNullOrEmpty(path)) + { + return path; + } + + if (path.EndsWith(cshtmlExtension, StringComparison.OrdinalIgnoreCase)) + { + path = path.Substring(0, path.Length - cshtmlExtension.Length); + } + + return CSharpIdentifier.SanitizeIdentifier(path); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Resources.resx new file mode 100644 index 0000000000..9a0b9cfdc4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/Resources.resx @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Value cannot be null or empty. + + + Inject a service from the application's service container into a property. + + + The name of the property. + + + PropertyName + + + The type of the service to inject. + + + TypeName + + + Specify the view or page model for the page. + + + The model type. + + + TypeName + + + The 'inherits' keyword is not allowed when a '{0}' keyword is used. + + + A property name must be specified when using the '{0}' statement. Format for a '{0}' statement is '@{0} <Type Name> <Property Name>'. + + + The '{0}' keyword must be followed by a type name on the same line. + + + Only one '{0}' statement is allowed in a file. + + + Invalid tag helper property '{0}.{1}'. Dictionary values must not be of type '{2}'. + + + The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor cshtml file. + + + The '@{0}' directive must precede all other elements defined in a Razor file. + + + Mark the page as a Razor Page. + + + An optional route template for the page. + + + RouteTemplate + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/TagHelperDescriptorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/TagHelperDescriptorExtensions.cs new file mode 100644 index 0000000000..dd32c0b013 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/TagHelperDescriptorExtensions.cs @@ -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 +{ + public static class TagHelperDescriptorExtensions + { + /// + /// Indicates whether a represents a view component. + /// + /// The to check. + /// Whether a represents a view component. + 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; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentResources.resx new file mode 100644 index 0000000000..d6aad4ff3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentResources.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + View component '{0}' must have exactly one public method named '{1}' or '{2}'. + + + Method '{0}' of view component '{1}' should be declared to return {2}&lt;T&gt;. + + + Could not find an '{0}' or '{1}' method for the view component '{2}'. + + + Method '{0}' of view component '{1}' cannot return a {2}. + + + Method '{0}' of view component '{1}' should be declared to return a value. + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperConventions.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperConventions.cs new file mode 100644 index 0000000000..fa7563d37b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperConventions.cs @@ -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 +{ + public static class ViewComponentTagHelperConventions + { + public static readonly string Kind = "MVC.ViewComponent"; + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs new file mode 100644 index 0000000000..c266d7541d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs @@ -0,0 +1,284 @@ +// 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 +{ + 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 PrimitiveDisplayTypeNameLookups = new Dictionary(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 = GetInvokeMethods(type); + + if (methods.Count == 0) + { + diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_CannotFindMethod(type.ToDisplayString(FullNameTypeDisplayFormat)); + method = null; + return false; + } + else if (methods.Count > 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. + 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. + 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 static IReadOnlyList GetInvokeMethods(INamedTypeSymbol type) + { + var methods = new List(); + while (type != null) + { + var currentTypeMethods = type.GetMembers() + .OfType() + .Where(m => + m.DeclaredAccessibility == Accessibility.Public && + !m.IsStatic && + (string.Equals(m.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal) || + string.Equals(m.Name, ViewComponentTypes.SyncMethodName, StringComparison.Ordinal))); + + methods.AddRange(currentTypeMethods); + + type = type.BaseType; + } + + return methods; + } + + private void AddRequiredAttributes(ImmutableArray 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 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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..d0d9805f6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorProvider.cs @@ -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 +{ + 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(); + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperIntermediateNode.cs new file mode 100644 index 0000000000..9283b2c092 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperIntermediateNode.cs @@ -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 +{ + 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(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(); + if (extension == null) + { + ReportMissingCodeTargetExtension(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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperMetadata.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperMetadata.cs new file mode 100644 index 0000000000..ca8aae361d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperMetadata.cs @@ -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 +{ + public static class ViewComponentTagHelperMetadata + { + /// + /// The key in a containing + /// the short name of a view component. + /// + public static readonly string Name = "MVC.ViewComponent.Name"; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperPass.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperPass.cs new file mode 100644 index 0000000000..0c3b14563e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperPass.cs @@ -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 +{ + 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(); + 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 _tagHelpers; + + public Context(NamespaceDeclarationIntermediateNode @namespace, ClassDeclarationIntermediateNode @class) + { + Namespace = @namespace; + Class = @class; + + _tagHelpers = new Dictionary(); + } + + public ClassDeclarationIntermediateNode Class { get; } + + public NamespaceDeclarationIntermediateNode Namespace { get; } + + + public IEnumerable 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"; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperTargetExtension.cs new file mode 100644 index 0000000000..1e2e7c89c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperTargetExtension.cs @@ -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 +{ + 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; } = "__helperContent"; + + 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() + { + { 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(")]"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs new file mode 100644 index 0000000000..8c7a3b4065 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs @@ -0,0 +1,88 @@ +// 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 Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + internal class ViewComponentTypeVisitor : SymbolVisitor + { + private readonly INamedTypeSymbol _viewComponentAttribute; + private readonly INamedTypeSymbol _nonViewComponentAttribute; + private readonly List _results; + + public ViewComponentTypeVisitor( + INamedTypeSymbol viewComponentAttribute, + INamedTypeSymbol nonViewComponentAttribute, + List 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 (_viewComponentAttribute == null) + { + return false; + } + + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypes.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypes.cs new file mode 100644 index 0000000000..5558ba5e06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypes.cs @@ -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 +{ + 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"; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/baseline.netcore.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/baseline.netcore.json new file mode 100644 index 0000000000..488fa33c0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/baseline.netcore.json @@ -0,0 +1,1235 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Razor.Extensions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.AssemblyAttributeInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.IInjectTargetExtension", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.CodeGeneration.ICodeTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectIntermediateNode", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.Intermediate.ExtensionIntermediateNode", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_TypeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TypeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MemberName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MemberName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Children", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Accept", + "Parameters": [ + { + "Name": "visitor", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeVisitor" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteNode", + "Parameters": [ + { + "Name": "target", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeTarget" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectTargetExtension", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Mvc.Razor.Extensions.IInjectTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Mvc.Razor.Extensions.IInjectTargetExtension", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InstrumentationPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.IViewComponentTagHelperTargetExtension", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.CodeGeneration.ICodeTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteViewComponentTagHelper", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperIntermediateNode" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ModelDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetModelType", + "Parameters": [ + { + "Name": "document", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ModelExpressionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.MvcRazorTemplateEngine", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateCodeDocument", + "Parameters": [ + { + "Name": "projectItem", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectItem" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "engine", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorEngine" + }, + { + "Name": "project", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.MvcViewDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MvcViewDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.NamespaceDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.PageDirective", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RouteTemplate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DirectiveNode", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNode", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryGetPageDirective", + "Parameters": [ + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + }, + { + "Name": "pageDirective", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.PageDirective", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.PagesPropertyInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorPageDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RazorPageDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RouteTemplateKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.TagHelperDescriptorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "IsViewComponentKind", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetViewComponentName", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.String", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperConventions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Kind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperDescriptorProvider", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Order", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperIntermediateNode", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.Intermediate.ExtensionIntermediateNode", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Children", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClassName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClassName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelper", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelper", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Accept", + "Parameters": [ + { + "Name": "visitor", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeVisitor" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteNode", + "Parameters": [ + { + "Name": "target", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeTarget" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperMetadata", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriterExtensions+CSharpCodeWritingScope", + "Visibility": "Public", + "Kind": "Struct", + "Sealed": true, + "ImplementedInterfaces": [ + "System.IDisposable" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Dispose", + "Parameters": [], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "System.IDisposable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "writer", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter" + }, + { + "Name": "tabSize", + "Type": "System.Int32", + "DefaultValue": "4" + }, + { + "Name": "autoSpace", + "Type": "System.Boolean", + "DefaultValue": "True" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTypes+ViewComponent", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Name\"" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/baseline.netframework.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/baseline.netframework.json new file mode 100644 index 0000000000..7d416ca9c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/baseline.netframework.json @@ -0,0 +1,1023 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Razor.Extensions, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.AssemblyAttributeInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.IInjectTargetExtension", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.CodeGeneration.ICodeTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectIntermediateNode", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.Intermediate.ExtensionIntermediateNode", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_TypeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TypeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MemberName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MemberName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Children", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Accept", + "Parameters": [ + { + "Name": "visitor", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeVisitor" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteNode", + "Parameters": [ + { + "Name": "target", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeTarget" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectTargetExtension", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Mvc.Razor.Extensions.IInjectTargetExtension" + ], + "Members": [ + { + "Kind": "Method", + "Name": "WriteInjectProperty", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeRenderingContext" + }, + { + "Name": "node", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InjectIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Mvc.Razor.Extensions.IInjectTargetExtension", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.InstrumentationPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ModelDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetModelType", + "Parameters": [ + { + "Name": "document", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ModelExpressionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.MvcRazorTemplateEngine", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateCodeDocument", + "Parameters": [ + { + "Name": "projectItem", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProjectItem" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "engine", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorEngine" + }, + { + "Name": "project", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorProject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.MvcViewDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MvcViewDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.NamespaceDirective", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.PageDirective", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RouteTemplate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DirectiveNode", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNode", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryGetPageDirective", + "Parameters": [ + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + }, + { + "Name": "pageDirective", + "Type": "Microsoft.AspNetCore.Mvc.Razor.Extensions.PageDirective", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Directive", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Razor.Language.DirectiveDescriptor", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.PagesPropertyInjectionPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Register", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorPageDocumentClassifierPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.DocumentClassifierPassBase", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "IsMatch", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnDocumentStructureCreated", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "namespace", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.NamespaceDeclarationIntermediateNode" + }, + { + "Name": "class", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.ClassDeclarationIntermediateNode" + }, + { + "Name": "method", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.MethodDeclarationIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RazorPageDocumentKind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.TagHelperDescriptorExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "IsViewComponentKind", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.Boolean", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetViewComponentName", + "Parameters": [ + { + "Name": "tagHelper", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor" + } + ], + "ReturnType": "System.String", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperConventions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Kind", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperDescriptorProvider", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Order", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperMetadata", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTagHelperPass", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteCore", + "Parameters": [ + { + "Name": "codeDocument", + "Type": "Microsoft.AspNetCore.Razor.Language.RazorCodeDocument" + }, + { + "Name": "documentNode", + "Type": "Microsoft.AspNetCore.Razor.Language.Intermediate.DocumentIntermediateNode" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriterExtensions+CSharpCodeWritingScope", + "Visibility": "Public", + "Kind": "Struct", + "Sealed": true, + "ImplementedInterfaces": [ + "System.IDisposable" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Dispose", + "Parameters": [], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "System.IDisposable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "writer", + "Type": "Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter" + }, + { + "Name": "tabSize", + "Type": "System.Int32", + "DefaultValue": "4" + }, + { + "Name": "autoSpace", + "Type": "System.Boolean", + "DefaultValue": "True" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Mvc.Razor.Extensions.ViewComponentTypes+ViewComponent", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Name\"" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/breakingchanges.netcore.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/breakingchanges.netcore.json new file mode 100644 index 0000000000..5f5b6444f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/breakingchanges.netcore.json @@ -0,0 +1,11 @@ +[ + { + "TypeId": "public static class Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorExtensions", + "MemberId": "public static System.Void Register(Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder builder)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.Extensions.InstrumentationPass : Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase, Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Kind": "Removal" + } +] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/breakingchanges.netframework.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/breakingchanges.netframework.json new file mode 100644 index 0000000000..5f5b6444f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/breakingchanges.netframework.json @@ -0,0 +1,11 @@ +[ + { + "TypeId": "public static class Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorExtensions", + "MemberId": "public static System.Void Register(Microsoft.AspNetCore.Razor.Language.IRazorEngineBuilder builder)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.Extensions.InstrumentationPass : Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase, Microsoft.AspNetCore.Razor.Language.IRazorOptimizationPass", + "Kind": "Removal" + } +] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/InjectDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/InjectDirectiveTest.cs new file mode 100644 index 0000000000..a935b23bfb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/InjectDirectiveTest.cs @@ -0,0 +1,210 @@ +// 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 +{ + public class InjectDirectiveTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_3_0; + + [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(@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(@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 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(@class.Children[1]); + Assert.Equal("PropertyType", node.TypeName); + Assert.Equal("PropertyName", node.MemberName); + } + + [Fact] + public void InjectDirectivePass_Execute_ExpandsTModel_WithModelTypeFirst() + { + // Arrange + var codeDocument = CreateDocument(@" +@model ModelType +@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(@class.Children[1]); + Assert.Equal("PropertyType", node.TypeName); + Assert.Equal("PropertyName", node.MemberName); + } + + [Fact] + public void InjectDirectivePass_Execute_ExpandsTModel_WithModelType() + { + // Arrange + var codeDocument = CreateDocument(@" +@inject PropertyType 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(@class.Children[1]); + Assert.Equal("PropertyType", 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; + } + + protected override void ConfigureProjectEngine(RazorProjectEngineBuilder builder) + { + // Notice we're not registering the InjectDirective.Pass here so we can run it on demand. + builder.AddDirective(InjectDirective.Directive); + builder.AddDirective(ModelDirective.Directive); + } + + 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; + } + } + + var irDocument = codeDocument.GetDocumentIntermediateNode(); + irDocument.DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind; + return irDocument; + } + + private class ClassNodeVisitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode Node { get; set; } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + Node = node; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/InjectTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/InjectTargetExtensionTest.cs new file mode 100644 index 0000000000..65a632d613 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/InjectTargetExtensionTest.cs @@ -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 +{ + 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", + 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 PropertyName { get; private set; }" + Environment.NewLine + Environment.NewLine + + "#line default" + Environment.NewLine + + "#line hidden" + Environment.NewLine + + "#nullable disable" + Environment.NewLine, + context.CodeWriter.GenerateCode()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs new file mode 100644 index 0000000000..150d4e012b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -0,0 +1,1102 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.IntegrationTests +{ + public class CodeGenerationIntegrationTest : IntegrationTestBase + { + private readonly static CSharpCompilation DefaultBaseCompilation = MvcShim.BaseCompilation.WithAssemblyName("AppCode"); + + public CodeGenerationIntegrationTest() + : base(generateBaselines: null) + { + Configuration = RazorConfiguration.Create( + RazorLanguageVersion.Version_3_0, + "MVC-3.0", + new[] { new AssemblyExtension("MVC-3.0", typeof(ExtensionInitializer).Assembly) }); + } + + protected override CSharpCompilation BaseCompilation => DefaultBaseCompilation; + + protected override RazorConfiguration Configuration { get; } + + #region Runtime + + [Fact] + public void UsingDirectives_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false, throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + + var diagnostics = compiled.Compilation.GetDiagnostics().Where(d => d.Severity >= DiagnosticSeverity.Warning); + Assert.Equal("The using directive for 'System' appeared previously in this namespace", Assert.Single(diagnostics).GetMessage()); + } + + [Fact] + public void InvalidNamespaceAtEOF_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ1014", Assert.Single(diagnotics).Id); + } + + [Fact] + public void IncompleteDirectives_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyService +{ + public string Html { get; set; } +}"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + + // We expect this test to generate a bunch of errors. + Assert.True(compiled.CodeDocument.GetCSharpDocument().Diagnostics.Count > 0); + } + + [Fact] + public void InheritsViewModel_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Razor; + +public class MyBasePageForViews : RazorPage +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} +public class MyModel +{ + +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void InheritsWithViewImports_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.RazorPages; + +public abstract class MyPageModel : Page +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} + +public class MyModel +{ + +}"); + AddProjectItemFromText(@"@inherits MyPageModel"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void AttributeDirectiveWithViewImports_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + AddProjectItemFromText(@" +@using System +@attribute [Serializable]"); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false, throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + + var diagnostics = compiled.Compilation.GetDiagnostics().Where(d => d.Severity >= DiagnosticSeverity.Warning); + Assert.Equal("Duplicate 'Serializable' attribute", Assert.Single(diagnostics).GetMessage()); + } + + [Fact] + public void MalformedPageDirective_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ1016", Assert.Single(diagnotics).Id); + } + + [Fact] + public void Basic_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void BasicComponent_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(fileKind: FileKinds.Component); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void Sections_Runtime() + { + // 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: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void _ViewImports_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void Inject_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyApp +{ + public string MyProperty { get; set; } +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void InjectWithModel_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyModel +{ + +} + +public class MyService +{ + public string Html { get; set; } +} + +public class MyApp +{ + public string MyProperty { get; set; } +}"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void InjectWithSemicolon_Runtime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyModel +{ + +} + +public class MyApp +{ + public string MyProperty { get; set; } +} + +public class MyService +{ + public string Html { get; set; } +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void Model_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void ModelExpressionTagHelper_Runtime() + { + // 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: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void RazorPages_Runtime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void RazorPagesWithRouteTemplate_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void RazorPagesWithoutModel_Runtime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void PageWithNamespace_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void ViewWithNamespace_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact(Skip = "Reenable after CS1701 errors are resolved")] + public void ViewComponentTagHelper_Runtime() + { + // 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: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + } + + [Fact] + public void RazorPageWithNoLeadingPageDirective_Runtime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: false); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ3906", Assert.Single(diagnotics).Id); + } + #endregion + + #region DesignTime + + [Fact] + public void UsingDirectives_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true, throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + + var diagnostics = compiled.Compilation.GetDiagnostics().Where(d => d.Severity >= DiagnosticSeverity.Warning); + Assert.Equal("The using directive for 'System' appeared previously in this namespace", Assert.Single(diagnostics).GetMessage()); + } + + [Fact] + public void InvalidNamespaceAtEOF_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ1014", Assert.Single(diagnotics).Id); + } + + [Fact] + public void IncompleteDirectives_DesignTime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyService +{ + public string Html { get; set; } +}"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + 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 : 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void InheritsWithViewImports_DesignTime() + { + // Arrange + AddCSharpSyntaxTree(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.RazorPages; + +public abstract class MyPageModel : Page +{ + public override Task ExecuteAsync() + { + throw new System.NotImplementedException(); + } +} + +public class MyModel +{ + +}"); + + AddProjectItemFromText(@"@inherits MyPageModel"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void AttributeDirectiveWithViewImports_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + AddProjectItemFromText(@" +@using System +@attribute [Serializable]"); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true, throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + + var diagnostics = compiled.Compilation.GetDiagnostics().Where(d => d.Severity >= DiagnosticSeverity.Warning); + Assert.Equal("Duplicate 'Serializable' attribute", Assert.Single(diagnostics).GetMessage()); + } + + [Fact] + public void MalformedPageDirective_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ1016", Assert.Single(diagnotics).Id); + } + + [Fact] + public void Basic_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void BasicComponent_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(fileKind: FileKinds.Component); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void _ViewImports_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void InjectWithModel_DesignTime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyModel +{ + +} + +public class MyService +{ + 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void InjectWithSemicolon_DesignTime() + { + // Arrange + AddCSharpSyntaxTree(@" +public class MyModel +{ + +} + +public class MyApp +{ + public string MyProperty { get; set; } +} + +public class MyService +{ + public string Html { get; set; } +} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void Model_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void RazorPages_DesignTime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void RazorPagesWithRouteTemplate_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void RazorPagesWithoutModel_DesignTime() + { + // Arrange + AddCSharpSyntaxTree($@" +public class DivTagHelper : {typeof(TagHelper).FullName} +{{ + +}} +"); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void PageWithNamespace_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void ViewWithNamespace_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToAssembly(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + 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()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + } + + [Fact] + public void RazorPageWithNoLeadingPageDirective_DesignTime() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem, designTime: true); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(compiled.CodeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument()); + AssertLinePragmas(compiled.CodeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(compiled.CodeDocument); + + var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics; + Assert.Equal("RZ3906", Assert.Single(diagnotics).Id); + } + + #endregion + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj new file mode 100644 index 0000000000..8609730955 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test.csproj @@ -0,0 +1,38 @@ + + + + $(StandardTestTfms) + true + $(DefaultItemExcludes);TestFiles\** + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs new file mode 100644 index 0000000000..527120915b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelDirectiveTest.cs @@ -0,0 +1,327 @@ +// 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.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 +{ + public class ModelDirectiveTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_3_0; + + [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 +@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_DifferentOrdering() + { + // Arrange + var codeDocument = CreateDocument(@" +@model Type1 +@inherits BaseType +@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", @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 +"); + + 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_DesignTime_AddsTModelUsingDirective() + { + // Arrange + var codeDocument = CreateDocument(@" +@inherits BaseType +"); + + 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", @class.BaseType); + + var @namespace = FindNamespaceNode(irDocument); + var usingNode = Assert.IsType(@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 +@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", @class.BaseType); + + var @namespace = FindNamespaceNode(irDocument); + var usingNode = Assert.IsType(@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(designTime: false); + } + + 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); + + b.Features.Add(new RazorPageDocumentClassifierPass()); + b.Features.Add(new MvcViewDocumentClassifierPass()); + 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 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); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs new file mode 100644 index 0000000000..92f6ef816e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ModelExpressionPassTest.cs @@ -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 +{ + public class ModelExpressionPassTest + { + [Fact] + public void ModelExpressionPass_NonModelExpressionProperty_Ignored() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +

"); + + 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().Single(); + + var token = Assert.IsType(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

"); + + 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().Single(); + + var expression = Assert.IsType(Assert.Single(setProperty.Children)); + Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Bar)", GetCSharpContent(expression)); + + var originalNode = Assert.IsType(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

"); + + 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().Single(); + + var expression = Assert.IsType(Assert.Single(setProperty.Children)); + Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => Bar)", GetCSharpContent(expression)); + + var originalNode = Assert.IsType(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; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcImportProjectFeatureTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcImportProjectFeatureTest.cs new file mode 100644 index 0000000000..7e811ee261 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcImportProjectFeatureTest.cs @@ -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 +{ + public class MvcImportProjectFeatureTest + { + [Fact] + public void AddDefaultDirectivesImport_AddsSingleDynamicImport() + { + // Arrange + var imports = new List(); + + // Act + MvcImportProjectFeature.AddDefaultDirectivesImport(imports); + + // Assert + var import = Assert.Single(imports); + Assert.Null(import.FilePath); + } + + [Fact] + public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk() + { + // Arrange + var imports = new List(); + 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(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(); + var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml"); + var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem }); + var mvcImportFeature = new MvcImportProjectFeature() + { + ProjectEngine = Mock.Of(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)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcShim.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcShim.cs new file mode 100644 index 0000000000..0ee1e1a66d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcShim.cs @@ -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"; + + 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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs new file mode 100644 index 0000000000..3cb503f9fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/MvcViewDocumentClassifierPassTest.cs @@ -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 +{ + public class MvcViewDocumentClassifierPassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_3_0; + + [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", 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", 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 projectEngine, RazorCodeDocument codeDocument) + { + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs new file mode 100644 index 0000000000..6cf2796358 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/PageDirectiveTest.cs @@ -0,0 +1,148 @@ +// 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.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class PageDirectiveTest + { + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfPageIsMalformed() + { + // Arrange + var content = "@page \"some-route-template\" Invalid"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Equal("some-route-template", pageDirective.RouteTemplate); + Assert.NotNull(pageDirective.DirectiveNode); + } + + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfPageIsImported() + { + // Arrange + var content = "Hello world"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var importDocument = RazorSourceDocument.Create("@page", "imports.cshtml"); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { importDocument }); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Null(pageDirective.RouteTemplate); + } + + [Fact] + public void TryGetPageDirective_ReturnsFalse_IfPageDoesNotHaveDirective() + { + // Arrange + var content = "Hello world"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.False(result); + Assert.Null(pageDirective); + } + + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfPageDoesStartWithDirective() + { + // Arrange + var content = "Hello @page"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Null(pageDirective.RouteTemplate); + Assert.NotNull(pageDirective.DirectiveNode); + } + + [Fact] + public void TryGetPageDirective_ReturnsTrue_IfContentHasDirective() + { + // Arrange + var content = "@page"; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Null(pageDirective.RouteTemplate); + } + + [Fact] + public void TryGetPageDirective_ParsesRouteTemplate() + { + // Arrange + var content = "@page \"some-route-template\""; + var sourceDocument = RazorSourceDocument.Create(content, "file"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var engine = CreateEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + var result = PageDirective.TryGetPageDirective(irDocument, out var pageDirective); + + // Assert + Assert.True(result); + Assert.Equal("some-route-template", pageDirective.RouteTemplate); + } + + private RazorEngine CreateEngine() + { + return RazorProjectEngine.Create(b => + { + PageDirective.Register(b); + }).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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3337ebeac2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs new file mode 100644 index 0000000000..c66ac3d4e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/RazorPageDocumentClassifierPassTest.cs @@ -0,0 +1,419 @@ +// 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.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class RazorPageDocumentClassifierPassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_3_0; + + [Fact] + public void RazorPageDocumentClassifierPass_LogsErrorForImportedPageDirectives() + { + // Arrange + var sourceSpan = new SourceSpan("import.cshtml", 0, 0, 0, 5); + var expectedDiagnostic = RazorExtensionsDiagnosticFactory.CreatePageDirective_CannotBeImported(sourceSpan); + var importDocument = RazorSourceDocument.Create("@page", "import.cshtml"); + var sourceDocument = RazorSourceDocument.Create("

Hello World

", "main.cshtml"); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { importDocument }); + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var pageDirectives = irDocument.FindDirectiveReferences(PageDirective.Directive); + var directive = Assert.Single(pageDirectives); + var diagnostic = Assert.Single(directive.Node.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RazorPageDocumentClassifierPass_LogsErrorIfDirectiveNotAtTopOfFile() + { + // Arrange + var sourceSpan = new SourceSpan( + "Test.cshtml", + absoluteIndex: 14 + Environment.NewLine.Length * 2, + lineIndex: 2, + characterIndex: 0, + length: 5 + Environment.NewLine.Length); + + var expectedDiagnostic = RazorExtensionsDiagnosticFactory.CreatePageDirective_MustExistAtTheTopOfFile(sourceSpan); + var content = @" +@somethingelse +@page +"; + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(content, "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + var pageDirectives = irDocument.FindDirectiveReferences(PageDirective.Directive); + var directive = Assert.Single(pageDirectives); + var diagnostic = Assert.Single(directive.Node.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RazorPageDocumentClassifierPass_DoesNotLogErrorIfCommentAndWhitespaceBeforeDirective() + { + // Arrange + var content = @" +@* some comment *@ + +@page +"; + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(content, "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + var pageDirectives = irDocument.FindDirectiveReferences(PageDirective.Directive); + var directive = Assert.Single(pageDirectives); + Assert.Empty(directive.Node.Diagnostics); + } + + [Fact] + public void RazorPageDocumentClassifierPass_SetsDocumentKind() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal("mvc.1.0.razor-page", irDocument.DocumentKind); + } + + [Fact] + public void RazorPageDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + irDocument.DocumentKind = "some-value"; + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal("some-value", irDocument.DocumentKind); + } + + [Fact] + public void RazorPageDocumentClassifierPass_NoOpsIfPageDirectiveIsMalformed() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page+1", "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + irDocument.DocumentKind = "some-value"; + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal("some-value", irDocument.DocumentKind); + } + + [Fact] + public void RazorPageDocumentClassifierPass_SetsNamespace() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal("AspNetCore", visitor.Namespace.Content); + } + + [Fact] + public void RazorPageDocumentClassifierPass_SetsClass() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType); + Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); + Assert.Equal("Test", visitor.Class.ClassName); + } + + [Fact] + public void RazorPageDocumentClassifierPass_NullFilePath_SetsClass() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: null, relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal("global::Microsoft.AspNetCore.Mvc.RazorPages.Page", visitor.Class.BaseType); + Assert.Equal(new[] { "public" }, visitor.Class.Modifiers); + Assert.Equal("AspNetCore_74fbaab062bb228ed1ab09c5ff8d6ed2417320e2", 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 RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + Assert.Equal(expected, visitor.Class.ClassName); + } + + [Fact] + public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = 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 RazorPageDocumentClassifierPass_SanitizesClassName() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties)); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = 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 RazorPageDocumentClassifierPass_SetsUpExecuteAsyncMethod() + { + // Arrange + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml")); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = 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); + } + + [Fact] + public void RazorPageDocumentClassifierPass_AddsRouteTemplateMetadata() + { + // Arrange + var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml"); + var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page \"some-route\"", properties)); + + var engine = CreateRuntimeEngine(); + var irDocument = CreateIRDocument(engine, codeDocument); + var pass = new RazorPageDocumentClassifierPass + { + Engine = engine + }; + + // Act + pass.Execute(codeDocument, irDocument); + var visitor = new Visitor(); + visitor.Visit(irDocument); + + // Assert + var attributeNode = Assert.IsType(visitor.ExtensionNode); + Assert.Equal("RouteTemplate", attributeNode.Key); + Assert.Equal("some-route", attributeNode.Value); + } + + private RazorEngine CreateRuntimeEngine() + { + return CreateProjectEngine(b => + { + PageDirective.Register(b); + }).Engine; + } + + private static 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 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 ExtensionIntermediateNode ExtensionNode { 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); + } + + public override void VisitExtension(ExtensionIntermediateNode node) + { + ExtensionNode = node; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/SourceMappingsSerializer.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/SourceMappingsSerializer.cs new file mode 100644 index 0000000000..c2dd799b05 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/SourceMappingsSerializer.cs @@ -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 +{ + 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("|"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TagHelperDescriptorExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TagHelperDescriptorExtensionsTest.cs new file mode 100644 index 0000000000..e9e423853c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TagHelperDescriptorExtensionsTest.cs @@ -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 +{ + 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; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml new file mode 100644 index 0000000000..8bd338cc83 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml @@ -0,0 +1 @@ +@attribute [Serializable] \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..efddc5b3f3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.codegen.cs @@ -0,0 +1,60 @@ +// +#pragma warning disable 1591 +namespace AspNetCore +{ + #line hidden + using TModel = global::System.Object; + 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; +#nullable restore +#line 1 "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml" +using System; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml" +[Serializable] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml" + [Serializable] + +#line default +#line hidden +#nullable disable + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirectiveWithViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.codegen.html new file mode 100644 index 0000000000..e2017f6ce6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.codegen.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..bb927053f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.ir.txt @@ -0,0 +1,43 @@ +Document - + NamespaceDeclaration - - AspNetCore + UsingDirective - - TModel = global::System.Object + 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 + UsingDirective - (1:0,1 [12] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - System + CSharpCode - (26:1,11 [14] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) + IntermediateToken - (26:1,11 [14] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - CSharp - [Serializable] + CSharpCode - (11:0,11 [14] AttributeDirectiveWithViewImports.cshtml) + IntermediateToken - (11:0,11 [14] AttributeDirectiveWithViewImports.cshtml) - CSharp - [Serializable] + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirectiveWithViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (26:1,11 [14] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - [Serializable] + DirectiveToken - (11:0,11 [14] AttributeDirectiveWithViewImports.cshtml) - [Serializable] + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..f9bb95cbea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (11:0,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml) +|[Serializable]| +Generated Location: (854:28,11 [14] ) +|[Serializable]| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..bd318ff573 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_Runtime.codegen.cs @@ -0,0 +1,56 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5104989e6480d1ba77366a985b9e04e65a055725" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirectiveWithViewImports), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml")] +namespace AspNetCore +{ + #line hidden + 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; +#nullable restore +#line 1 "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml" +using System; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml" +[Serializable] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml" + [Serializable] + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5104989e6480d1ba77366a985b9e04e65a055725", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a7ca527618810d649c818bfc7baa259b22980b2a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirectiveWithViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..42edc1c806 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirectiveWithViewImports_Runtime.ir.txt @@ -0,0 +1,23 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - AspNetCore + 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 + UsingDirective - (1:0,1 [14] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - System + CSharpCode - (26:1,11 [14] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) + IntermediateToken - (26:1,11 [14] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - CSharp - [Serializable] + CSharpCode - (11:0,11 [14] AttributeDirectiveWithViewImports.cshtml) + IntermediateToken - (11:0,11 [14] AttributeDirectiveWithViewImports.cshtml) - CSharp - [Serializable] + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirectiveWithViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml new file mode 100644 index 0000000000..a20b20dae8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml @@ -0,0 +1,8 @@ +
+ Hello world + @string.Format("{0}", "Hello") +
+@{ + var cls = "foo"; +} +

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml new file mode 100644 index 0000000000..85206b7b78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml @@ -0,0 +1,9 @@ +@implements IDisposable +

+ Hello world + @string.Format("{0}", "Hello") +
+ +@functions { + void IDisposable.Dispose(){ } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs new file mode 100644 index 0000000000..5b6a7f8b5e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.cs @@ -0,0 +1,61 @@ +// +#pragma warning disable 1591 +namespace __GeneratedComponent +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class AspNetCore_d3c3d6059615673cb46fc4974164d61eabadb890 : Microsoft.AspNetCore.Components.ComponentBase, IDisposable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" +IDisposable __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" + this.ToString() + +#line default +#line hidden +#nullable disable + ; +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" +__o = string.Format("{0}", "Hello"); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" + + void IDisposable.Dispose(){ } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.html new file mode 100644 index 0000000000..e7b0219a38 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.codegen.html @@ -0,0 +1,9 @@ + +
+ Hello world + +
+ + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt new file mode 100644 index 0000000000..98c5fca72d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - __GeneratedComponent + 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 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - AspNetCore_d3c3d6059615673cb46fc4974164d61eabadb890 - Microsoft.AspNetCore.Components.ComponentBase - IDisposable + DesignTimeDirective - + DirectiveToken - (12:0,12 [11] BasicComponent.cshtml) - IDisposable + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (25:1,0 [91] BasicComponent.cshtml) - div + HtmlAttribute - (29:1,4 [25] BasicComponent.cshtml) - class=" - " + CSharpExpressionAttributeValue - (37:1,12 [16] BasicComponent.cshtml) - + IntermediateToken - (38:1,13 [15] BasicComponent.cshtml) - CSharp - this.ToString() + HtmlContent - (55:1,30 [23] BasicComponent.cshtml) + IntermediateToken - (55:1,30 [23] BasicComponent.cshtml) - Html - \n Hello world\n + CSharpExpression - (79:3,5 [29] BasicComponent.cshtml) + IntermediateToken - (79:3,5 [29] BasicComponent.cshtml) - CSharp - string.Format("{0}", "Hello") + HtmlContent - (108:3,34 [2] BasicComponent.cshtml) + IntermediateToken - (108:3,34 [2] BasicComponent.cshtml) - Html - \n + HtmlContent - (116:4,6 [4] BasicComponent.cshtml) + IntermediateToken - (116:4,6 [4] BasicComponent.cshtml) - Html - \n\n + HtmlContent - (170:8,1 [2] BasicComponent.cshtml) + IntermediateToken - (170:8,1 [2] BasicComponent.cshtml) - Html - \n + CSharpCode - (132:6,12 [37] BasicComponent.cshtml) + IntermediateToken - (132:6,12 [37] BasicComponent.cshtml) - CSharp - \n void IDisposable.Dispose(){ }\n diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt new file mode 100644 index 0000000000..728e0023db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_DesignTime.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (12:0,12 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) +|IDisposable| +Generated Location: (649:17,0 [11] ) +|IDisposable| + +Source Location: (38:1,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) +|this.ToString()| +Generated Location: (1248:35,13 [15] ) +|this.ToString()| + +Source Location: (79:3,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) +|string.Format("{0}", "Hello")| +Generated Location: (1445:43,6 [29] ) +|string.Format("{0}", "Hello")| + +Source Location: (132:6,12 [37] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml) +| + void IDisposable.Dispose(){ } +| +Generated Location: (1697:52,12 [37] ) +| + void IDisposable.Dispose(){ } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs new file mode 100644 index 0000000000..f1f8cd28b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs @@ -0,0 +1,51 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d3c3d6059615673cb46fc4974164d61eabadb890" +// +#pragma warning disable 1591 +namespace __GeneratedComponent +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class AspNetCore_d3c3d6059615673cb46fc4974164d61eabadb890 : Microsoft.AspNetCore.Components.ComponentBase, IDisposable + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "class", +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" + this.ToString() + +#line default +#line hidden +#nullable disable + ); + __builder.AddMarkupContent(2, "\r\n Hello world\r\n "); + __builder.AddContent(3, +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" + string.Format("{0}", "Hello") + +#line default +#line hidden +#nullable disable + ); + __builder.AddMarkupContent(4, "\r\n"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent.cshtml" + + void IDisposable.Dispose(){ } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt new file mode 100644 index 0000000000..663160b90d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - __GeneratedComponent + 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 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - AspNetCore_d3c3d6059615673cb46fc4974164d61eabadb890 - Microsoft.AspNetCore.Components.ComponentBase - IDisposable + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (25:1,0 [91] BasicComponent.cshtml) - div + HtmlAttribute - (29:1,4 [25] BasicComponent.cshtml) - class=" - " + CSharpExpressionAttributeValue - (37:1,12 [16] BasicComponent.cshtml) - + IntermediateToken - (38:1,13 [15] BasicComponent.cshtml) - CSharp - this.ToString() + HtmlContent - (55:1,30 [23] BasicComponent.cshtml) + IntermediateToken - (55:1,30 [19] BasicComponent.cshtml) - Html - \n Hello world\n + IntermediateToken - (74:3,0 [4] BasicComponent.cshtml) - Html - + CSharpExpression - (79:3,5 [29] BasicComponent.cshtml) + IntermediateToken - (79:3,5 [29] BasicComponent.cshtml) - CSharp - string.Format("{0}", "Hello") + HtmlContent - (108:3,34 [2] BasicComponent.cshtml) + IntermediateToken - (108:3,34 [2] BasicComponent.cshtml) - Html - \n + CSharpCode - (132:6,12 [37] BasicComponent.cshtml) + IntermediateToken - (132:6,12 [37] BasicComponent.cshtml) - CSharp - \n void IDisposable.Dispose(){ }\n diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs new file mode 100644 index 0000000000..48a1f5fdba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.cs @@ -0,0 +1,83 @@ +// +#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 + { + #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() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" + __o = this.ToString(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" +__o = string.Format("{0}", "Hello"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" + + var cls = "foo"; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" + if(cls != null) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" + __o = cls; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" + } + +#line default +#line hidden +#nullable disable + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.html new file mode 100644 index 0000000000..08d042e897 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.codegen.html @@ -0,0 +1,8 @@ +
+ Hello world + +
+ + + +

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt new file mode 100644 index 0000000000..959329c714 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -0,0 +1,65 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 -

+ 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 -
+ 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 -

+ IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt new file mode 100644 index 0000000000..5c0927db71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.mappings.txt @@ -0,0 +1,34 @@ +Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) +|this.ToString()| +Generated Location: (1049:27,13 [15] ) +|this.ToString()| + +Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) +|string.Format("{0}", "Hello")| +Generated Location: (1223:34,6 [29] ) +|string.Format("{0}", "Hello")| + +Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) +| + var cls = "foo"; +| +Generated Location: (1407:41,2 [25] ) +| + var cls = "foo"; +| + +Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) +|if(cls != null) { | +Generated Location: (1593:49,11 [18] ) +|if(cls != null) { | + +Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) +|cls| +Generated Location: (1793:56,30 [3] ) +|cls| + +Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml) +| }| +Generated Location: (1982:63,33 [2] ) +| }| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs new file mode 100644 index 0000000000..1885fba68a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_Runtime.codegen.cs @@ -0,0 +1,92 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6d079dd6c39f39d17a2faff14404b37ab7e8b8fc" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6d079dd6c39f39d17a2faff14404b37ab7e8b8fc", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("

+ IntermediateToken - (30:0,30 [19] Basic.cshtml) - Html - \n Hello world\n + IntermediateToken - (49:2,0 [4] Basic.cshtml) - Html - + 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 -
+ 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 -

+ IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml new file mode 100644 index 0000000000..224242197b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml @@ -0,0 +1,15 @@ +@* These test files validate that end-to-end, incomplete directives don't throw. *@ + +@page +@page +@page " + +@model +@model + +@inject +@inject +@inject MyService + +@namespace +@namespace diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs new file mode 100644 index 0000000000..f8f7622360 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -0,0 +1,82 @@ +// +#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.RazorPages.Page + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +MyService __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.html new file mode 100644 index 0000000000..85fabc0abd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.html @@ -0,0 +1,15 @@ + + + + + " + + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..1cfef392ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -0,0 +1,12 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt new file mode 100644 index 0000000000..bd1de30747 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -0,0 +1,76 @@ +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.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - + 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 - (94:3,0 [8] IncompleteDirectives.cshtml) - page + MalformedDirective - (102:4,0 [6] IncompleteDirectives.cshtml) - page + HtmlContent - (108:4,6 [5] IncompleteDirectives.cshtml) + IntermediateToken - (108:4,6 [5] IncompleteDirectives.cshtml) - Html - "\n\n + MalformedDirective - (113:6,0 [6] IncompleteDirectives.cshtml) - model + HtmlContent - (119:6,6 [2] IncompleteDirectives.cshtml) + IntermediateToken - (119:6,6 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (121:7,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + HtmlContent - (128:7,7 [4] IncompleteDirectives.cshtml) + IntermediateToken - (128:7,7 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (132:9,0 [7] IncompleteDirectives.cshtml) - inject + HtmlContent - (139:9,7 [2] IncompleteDirectives.cshtml) + IntermediateToken - (139:9,7 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (141:10,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - + HtmlContent - (149:10,8 [2] IncompleteDirectives.cshtml) + IntermediateToken - (149:10,8 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (151:11,0 [25] IncompleteDirectives.cshtml) - inject + DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + HtmlContent - (176:11,25 [4] IncompleteDirectives.cshtml) + IntermediateToken - (176:11,25 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (180:13,0 [10] IncompleteDirectives.cshtml) - namespace + HtmlContent - (190:13,10 [2] IncompleteDirectives.cshtml) + IntermediateToken - (190:13,10 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (192:14,0 [11] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - + HtmlContent - (203:14,11 [2] IncompleteDirectives.cshtml) + IntermediateToken - (203:14,11 [2] IncompleteDirectives.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt new file mode 100644 index 0000000000..b99213a7cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (128:7,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (786:20,0 [0] ) +|| + +Source Location: (149:10,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1015:30,0 [0] ) +|| + +Source Location: (159:11,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|MyService| +Generated Location: (1244:40,0 [17] ) +|MyService| + +Source Location: (203:14,11 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1514:50,0 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs new file mode 100644 index 0000000000..fa72740aa3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -0,0 +1,46 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5add9dba0a182cd75498c5b24f64a2547e7f49b0" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5add9dba0a182cd75498c5b24f64a2547e7f49b0", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\"\r\n\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt new file mode 100644 index 0000000000..1cfef392ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -0,0 +1,12 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt new file mode 100644 index 0000000000..c874623d1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -0,0 +1,53 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + 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 - (94:3,0 [8] IncompleteDirectives.cshtml) - page + MalformedDirective - (102:4,0 [6] IncompleteDirectives.cshtml) - page + HtmlContent - (108:4,6 [5] IncompleteDirectives.cshtml) + IntermediateToken - (108:4,6 [5] IncompleteDirectives.cshtml) - Html - "\n\n + MalformedDirective - (113:6,0 [6] IncompleteDirectives.cshtml) - model + HtmlContent - (119:6,6 [2] IncompleteDirectives.cshtml) + IntermediateToken - (119:6,6 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (121:7,0 [7] IncompleteDirectives.cshtml) - model + DirectiveToken - (128:7,7 [0] IncompleteDirectives.cshtml) - + HtmlContent - (128:7,7 [4] IncompleteDirectives.cshtml) + IntermediateToken - (128:7,7 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (132:9,0 [7] IncompleteDirectives.cshtml) - inject + HtmlContent - (139:9,7 [2] IncompleteDirectives.cshtml) + IntermediateToken - (139:9,7 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (141:10,0 [8] IncompleteDirectives.cshtml) - inject + DirectiveToken - (149:10,8 [0] IncompleteDirectives.cshtml) - + HtmlContent - (149:10,8 [2] IncompleteDirectives.cshtml) + IntermediateToken - (149:10,8 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (151:11,0 [25] IncompleteDirectives.cshtml) - inject + DirectiveToken - (159:11,8 [17] IncompleteDirectives.cshtml) - MyService + HtmlContent - (176:11,25 [4] IncompleteDirectives.cshtml) + IntermediateToken - (176:11,25 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (180:13,0 [10] IncompleteDirectives.cshtml) - namespace + HtmlContent - (190:13,10 [2] IncompleteDirectives.cshtml) + IntermediateToken - (190:13,10 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (192:14,0 [11] IncompleteDirectives.cshtml) - namespace + DirectiveToken - (203:14,11 [0] IncompleteDirectives.cshtml) - + HtmlContent - (203:14,11 [2] IncompleteDirectives.cshtml) + IntermediateToken - (203:14,11 [2] IncompleteDirectives.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml new file mode 100644 index 0000000000..38efd570da --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml @@ -0,0 +1,2 @@ +@inherits MyBasePageForViews +@model MyModel diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..92bb26ff8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.cs @@ -0,0 +1,60 @@ +// +#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 + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" +MyBasePageForViews __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" +MyModel __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.html new file mode 100644 index 0000000000..6adf1586e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.codegen.html @@ -0,0 +1,2 @@ + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt new file mode 100644 index 0000000000..3310acfa76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.ir.txt @@ -0,0 +1,39 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (10:0,10 [26] InheritsViewModel.cshtml) - MyBasePageForViews + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..84a0fc0bc1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) +|MyBasePageForViews| +Generated Location: (759:20,0 [26] ) +|MyBasePageForViews| + +Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml) +|MyModel| +Generated Location: (1034:30,0 [7] ) +|MyModel| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs new file mode 100644 index 0000000000..ba04e112a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.codegen.cs @@ -0,0 +1,35 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3ff83e2f0d946feb387a8ea03a529c64350014f8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"3ff83e2f0d946feb387a8ea03a529c64350014f8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt new file mode 100644 index 0000000000..c9350fc966 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel_Runtime.ir.txt @@ -0,0 +1,18 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml new file mode 100644 index 0000000000..295e4cf3ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml @@ -0,0 +1,2 @@ +@page +@model MyModel diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..70e733c3aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.cs @@ -0,0 +1,52 @@ +// +#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 : MyPageModel + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" +MyModel __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public MyModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.html new file mode 100644 index 0000000000..b1214751a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.codegen.html @@ -0,0 +1,2 @@ + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..bcbf42ae26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.ir.txt @@ -0,0 +1,43 @@ +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 - MyPageModel - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (10:0,10 [19] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - MyPageModel + DirectiveToken - (14:1,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 - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public MyModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..2aefff4635 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml) +|MyModel| +Generated Location: (764:20,0 [7] ) +|MyModel| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..b1adc79c5f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d196fc1c66d46d35e35af9b01c737e12bcce6782" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d196fc1c66d46d35e35af9b01c737e12bcce6782", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f311ecbb5c4d63980a59c24af5ffe8baa1c3f99a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyPageModel + { + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public MyModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..9432b939ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports_Runtime.ir.txt @@ -0,0 +1,23 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyPageModel - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public MyModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml new file mode 100644 index 0000000000..0aa749dd3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml @@ -0,0 +1 @@ +@inject MyApp MyPropertyName diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml new file mode 100644 index 0000000000..d699f1e754 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml @@ -0,0 +1,3 @@ +@model MyModel +@inject MyApp MyPropertyName +@inject MyService Html diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..dcd2bee26f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.cs @@ -0,0 +1,92 @@ +// +#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 + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" +MyModel __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" +MyApp __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" +global::System.Object MyPropertyName = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" +MyService __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" +global::System.Object Html = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.html new file mode 100644 index 0000000000..b05e435fda --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.codegen.html @@ -0,0 +1,3 @@ + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt new file mode 100644 index 0000000000..c1d70d5d89 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -0,0 +1,43 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..eb2a7eb7bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|MyModel| +Generated Location: (785:20,0 [7] ) +|MyModel| + +Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|MyApp| +Generated Location: (1039:30,0 [5] ) +|MyApp| + +Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|MyPropertyName| +Generated Location: (1313:40,22 [14] ) +|MyPropertyName| + +Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|MyService| +Generated Location: (1558:50,0 [17] ) +|MyService| + +Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml) +|Html| +Generated Location: (1844:60,22 [4] ) +|Html| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs new file mode 100644 index 0000000000..526da9d107 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.codegen.cs @@ -0,0 +1,37 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2cafb599699b78d76f0355b6f528050b4720789d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2cafb599699b78d76f0355b6f528050b4720789d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt new file mode 100644 index 0000000000..5072c066c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_Runtime.ir.txt @@ -0,0 +1,19 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml new file mode 100644 index 0000000000..8cd61913e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml @@ -0,0 +1,5 @@ +@model MyModel +@inject MyApp MyPropertyName; +@inject MyService Html; +@inject MyApp MyPropertyName2 ; +@inject MyService Html2 ; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs new file mode 100644 index 0000000000..3f7ff5b26d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.cs @@ -0,0 +1,136 @@ +// +#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 + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +MyModel __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +MyApp __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +global::System.Object MyPropertyName = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +MyService __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +global::System.Object Html = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +MyApp __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +global::System.Object MyPropertyName2 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +MyService __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" +global::System.Object Html2 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.html new file mode 100644 index 0000000000..0c20f0ce0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.codegen.html @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt new file mode 100644 index 0000000000..5c4540f366 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -0,0 +1,49 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + 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 + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt new file mode 100644 index 0000000000..fda44e6571 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.mappings.txt @@ -0,0 +1,45 @@ +Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyModel| +Generated Location: (793:20,0 [7] ) +|MyModel| + +Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyApp| +Generated Location: (1051:30,0 [5] ) +|MyApp| + +Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyPropertyName| +Generated Location: (1329:40,22 [14] ) +|MyPropertyName| + +Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyService| +Generated Location: (1578:50,0 [17] ) +|MyService| + +Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|Html| +Generated Location: (1868:60,22 [4] ) +|Html| + +Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyApp| +Generated Location: (2107:70,0 [5] ) +|MyApp| + +Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyPropertyName2| +Generated Location: (2385:80,22 [15] ) +|MyPropertyName2| + +Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|MyService| +Generated Location: (2635:90,0 [17] ) +|MyService| + +Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml) +|Html2| +Generated Location: (2925:100,22 [5] ) +|Html2| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs new file mode 100644 index 0000000000..b88abec1b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.codegen.cs @@ -0,0 +1,41 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8a53bde02f202036e674a23018e04268a3a844bb" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8a53bde02f202036e674a23018e04268a3a844bb", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 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 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 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt new file mode 100644 index 0000000000..518747b642 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs new file mode 100644 index 0000000000..32f6e7deee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.cs @@ -0,0 +1,62 @@ +// +#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 + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" +MyApp __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" +global::System.Object MyPropertyName = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.html new file mode 100644 index 0000000000..8a218bdd8d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.codegen.html @@ -0,0 +1 @@ + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt new file mode 100644 index 0000000000..0b8beeae9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -0,0 +1,40 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt new file mode 100644 index 0000000000..460ccddc4c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) +|MyApp| +Generated Location: (767:20,0 [5] ) +|MyApp| + +Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml) +|MyPropertyName| +Generated Location: (1032:30,22 [14] ) +|MyPropertyName| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs new file mode 100644 index 0000000000..0d61a8c1ed --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.codegen.cs @@ -0,0 +1,37 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "592a6d8544c71b828d4a3fbf92d398cd3ea72790" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"592a6d8544c71b828d4a3fbf92d398cd3ea72790", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt new file mode 100644 index 0000000000..8be484dac7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_Runtime.ir.txt @@ -0,0 +1,19 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml new file mode 100644 index 0000000000..6dfb72bc31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml @@ -0,0 +1 @@ +@namespace Test. \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs new file mode 100644 index 0000000000..d99c176c52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.cs @@ -0,0 +1,40 @@ +// +#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 + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.html new file mode 100644 index 0000000000..c72931e132 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.codegen.html @@ -0,0 +1 @@ + Test. \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..90446dc58b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt new file mode 100644 index 0000000000..6f9220aab4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.ir.txt @@ -0,0 +1,40 @@ +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 - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + MalformedDirective - (0:0,0 [11] InvalidNamespaceAtEOF.cshtml) - namespace + HtmlContent - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) + IntermediateToken - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) - Html - Test. + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs new file mode 100644 index 0000000000..df5eecceee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.codegen.cs @@ -0,0 +1,36 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "010d175bb6c3f7fa6f2ae04c1fecb4e3bfbf928b" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"010d175bb6c3f7fa6f2ae04c1fecb4e3bfbf928b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("Test."); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt new file mode 100644 index 0000000000..90446dc58b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt new file mode 100644 index 0000000000..c64540ac63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + MalformedDirective - (0:0,0 [11] InvalidNamespaceAtEOF.cshtml) - namespace + HtmlContent - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) + IntermediateToken - (11:0,11 [5] InvalidNamespaceAtEOF.cshtml) - Html - Test. + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml new file mode 100644 index 0000000000..9b4f9d5559 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml @@ -0,0 +1,4 @@ +@page "foo + +

About Us

+

We are awesome.

\ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..15befce0d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.cs @@ -0,0 +1,42 @@ +// +#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_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.html new file mode 100644 index 0000000000..9645bac584 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.codegen.html @@ -0,0 +1,4 @@ + "foo + +

About Us

+

We are awesome.

\ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..637d1e902b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..8db9133a4a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt @@ -0,0 +1,53 @@ +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_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 + MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page + HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml) + IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n + IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us + IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n + IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome. + IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html -

+ Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs new file mode 100644 index 0000000000..5dae856544 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "464e008b9a04181fe1e9f2cc6826095698de4739" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"464e008b9a04181fe1e9f2cc6826095698de4739", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\"foo\r\n\r\n

About Us

\r\n

We are awesome.

"); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt new file mode 100644 index 0000000000..637d1e902b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt new file mode 100644 index 0000000000..d3369badef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.ir.txt @@ -0,0 +1,34 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page + HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml) + IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n + IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us + IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n + IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html -

+ IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome. + IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html -

+ Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml new file mode 100644 index 0000000000..4b73b2dc53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml @@ -0,0 +1 @@ +@model System.Collections.IEnumerable diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml new file mode 100644 index 0000000000..c488b1e443 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml @@ -0,0 +1,6 @@ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..2dc89dfe21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.cs @@ -0,0 +1,84 @@ +// +#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 + { + #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)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" +DateTime __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" +global::System.Object __typeHelper = "InputTestTagHelper, AppCode"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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(); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __InputTestTagHelper = CreateTagHelper(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => Model); + +#line default +#line hidden +#nullable disable + 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.html new file mode 100644 index 0000000000..4649d9d2d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.codegen.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..37627e94ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -0,0 +1,68 @@ +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 - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..e1bbbe7295 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) +|DateTime| +Generated Location: (1278:26,0 [8] ) +|DateTime| + +Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) +|"InputTestTagHelper, AppCode"| +Generated Location: (1579:36,37 [29] ) +|"InputTestTagHelper, AppCode"| + +Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) +|Date| +Generated Location: (2296:54,102 [4] ) +|Date| + +Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml) +|Model| +Generated Location: (2726:63,94 [5] ) +|Model| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..f275cc4bbc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.codegen.cs @@ -0,0 +1,100 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "741fc99adb54ad906c5cdc5391aeffb51a1e767b" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"741fc99adb54ad906c5cdc5391aeffb51a1e767b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTestTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTestTagHelper); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden +#nullable disable + __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(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTestTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTestTagHelper); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => Model); + +#line default +#line hidden +#nullable disable + __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(); + WriteLiteral("\r\n"); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..681d19e1be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_Runtime.ir.txt @@ -0,0 +1,47 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + 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 - (64:3,0 [2] ModelExpressionTagHelper.cshtml) + IntermediateToken - (64:3,0 [2] ModelExpressionTagHelper.cshtml) - Html - \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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs new file mode 100644 index 0000000000..62b7f11ccc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.cs @@ -0,0 +1,50 @@ +// +#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_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" +System.Collections.IEnumerable __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.html new file mode 100644 index 0000000000..1638a82fb4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.codegen.html @@ -0,0 +1 @@ + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt new file mode 100644 index 0000000000..1ebdc00df2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -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_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (7:0,7 [30] Model.cshtml) - System.Collections.IEnumerable + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt new file mode 100644 index 0000000000..5328a5fda4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml) +|System.Collections.IEnumerable| +Generated Location: (788:20,0 [30] ) +|System.Collections.IEnumerable| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs new file mode 100644 index 0000000000..8f3494ed1c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.codegen.cs @@ -0,0 +1,35 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2c1e88396568d309c236020e59bf2abacfadd612" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2c1e88396568d309c236020e59bf2abacfadd612", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt new file mode 100644 index 0000000000..37e82ffb6e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_Runtime.ir.txt @@ -0,0 +1,18 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml new file mode 100644 index 0000000000..350f93b776 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml @@ -0,0 +1,2 @@ +@model ThisShouldBeGenerated +@model System.Collections.IEnumerable diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs new file mode 100644 index 0000000000..d44e698a48 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.cs @@ -0,0 +1,60 @@ +// +#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_MultipleModels : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml" +ThisShouldBeGenerated __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml" +System.Collections.IEnumerable __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.html new file mode 100644 index 0000000000..4a2f4743cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.codegen.html @@ -0,0 +1,2 @@ + + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..2fe8233c66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt new file mode 100644 index 0000000000..f63a69601b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -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_MultipleModels - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (7:0,7 [21] MultipleModels.cshtml) - ThisShouldBeGenerated + DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable + 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 + MalformedDirective - (30:1,0 [39] MultipleModels.cshtml) - model + DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt new file mode 100644 index 0000000000..170b1068b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) +|ThisShouldBeGenerated| +Generated Location: (797:20,0 [21] ) +|ThisShouldBeGenerated| + +Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml) +|System.Collections.IEnumerable| +Generated Location: (1064:30,0 [30] ) +|System.Collections.IEnumerable| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml new file mode 100644 index 0000000000..ecee97de58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml @@ -0,0 +1,3 @@ +@page +@namespace Test.Namespace +

Hi There!

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs new file mode 100644 index 0000000000..8ef243c98e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable 1591 +namespace Test.Namespace +{ + #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_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml" +global::System.Object __typeHelper = nameof(Test.Namespace); + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.html new file mode 100644 index 0000000000..6742b0a9e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.codegen.html @@ -0,0 +1,3 @@ + + +

Hi There!

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt new file mode 100644 index 0000000000..099c37355f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt @@ -0,0 +1,48 @@ +Document - + NamespaceDeclaration - - Test.Namespace + 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_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (18:1,11 [14] PageWithNamespace.cshtml) - Test.Namespace + 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 - (34:2,0 [20] PageWithNamespace.cshtml) + IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt new file mode 100644 index 0000000000..74d9dc1432 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (18:1,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml) +|Test.Namespace| +Generated Location: (828:20,44 [14] ) +|Test.Namespace| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs new file mode 100644 index 0000000000..f5a8fb31ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1edfb1ba4f5f6c70e2c72f4f23baf4dc0ae14377" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] +namespace Test.Namespace +{ + #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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"1edfb1ba4f5f6c70e2c72f4f23baf4dc0ae14377", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("

Hi There!

\r\n"); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt new file mode 100644 index 0000000000..7909f65e7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_Runtime.ir.txt @@ -0,0 +1,28 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Test.Namespace + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (34:2,0 [20] PageWithNamespace.cshtml) + IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html -

+ IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml new file mode 100644 index 0000000000..5172f8f791 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml @@ -0,0 +1,2 @@ +
Some text here.
+@page diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..ec8a4fd5c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.cs @@ -0,0 +1,42 @@ +// +#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_RazorPageWithNoLeadingPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.html new file mode 100644 index 0000000000..8f9ba3e623 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.codegen.html @@ -0,0 +1,2 @@ +
Some text here.
+ diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..393b35646e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml(2,1): Error RZ3906: The '@page' directive must precede all other elements defined in a Razor file. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..6139c62c14 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.ir.txt @@ -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_RazorPageWithNoLeadingPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 [28] RazorPageWithNoLeadingPageDirective.cshtml) + IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here. + IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs new file mode 100644 index 0000000000..848c33ffd5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "40c0ffad85d8fef63edfb5d91a08bd1b3609ba6f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"40c0ffad85d8fef63edfb5d91a08bd1b3609ba6f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("
Some text here.
\r\n"); + } + #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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.diagnostics.txt new file mode 100644 index 0000000000..393b35646e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective.cshtml(2,1): Error RZ3906: The '@page' directive must precede all other elements defined in a Razor file. diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt new file mode 100644 index 0000000000..1007d84ea5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPageWithNoLeadingPageDirective_Runtime.ir.txt @@ -0,0 +1,28 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [28] RazorPageWithNoLeadingPageDirective.cshtml) + IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here. + IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html -
+ IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml new file mode 100644 index 0000000000..2bc617c509 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml @@ -0,0 +1,40 @@ +@page + +@model NewModel +@addTagHelper "*, AppCode" +@using Microsoft.AspNetCore.Mvc.RazorPages + +@functions { + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } +} + +

New Customer

+
+
+
+ +
+ + +
+
+
+
+ +
+
+
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml new file mode 100644 index 0000000000..63d5955e72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml @@ -0,0 +1,13 @@ +@page "/About" + +@model NewModel +@using Microsoft.AspNetCore.Mvc.RazorPages + +@functions { + public class NewModel : PageModel + { + public string Name { get; set; } + } +} + +

New Customer @Model.Name

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.cs new file mode 100644 index 0000000000..566c5b5b38 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.cs @@ -0,0 +1,88 @@ +// +#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; +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("RouteTemplate", "/About")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +global::System.Object __typeHelper = "/About"; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +NewModel __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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() + { +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + __o = Model.Name; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + + public class NewModel : PageModel + { + public string Name { get; set; } + } + +#line default +#line hidden +#nullable disable + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.html new file mode 100644 index 0000000000..dbfd76ba01 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.codegen.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + +

New Customer

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.ir.txt new file mode 100644 index 0000000000..721dfa649d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.ir.txt @@ -0,0 +1,61 @@ +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 + UsingDirective - (36:3,1 [41] RazorPagesWithRouteTemplate.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorCompiledItemMetadataAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (6:0,6 [8] RazorPagesWithRouteTemplate.cshtml) - "/About" + DirectiveToken - (25:2,7 [8] RazorPagesWithRouteTemplate.cshtml) - NewModel + 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 - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + HtmlContent - (77:3,42 [4] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (77:3,42 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n + HtmlContent - (191:10,1 [21] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (191:10,1 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n + IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer + CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name + HtmlContent - (223:12,28 [7] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (223:12,28 [5] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (228:12,33 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + CSharpCode - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.mappings.txt new file mode 100644 index 0000000000..36cf7cd79b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_DesignTime.mappings.txt @@ -0,0 +1,35 @@ +Source Location: (36:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (511:15,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|"/About"| +Generated Location: (1165:28,37 [8] ) +|"/About"| + +Source Location: (25:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|NewModel| +Generated Location: (1408:38,0 [8] ) +|NewModel| + +Source Location: (213:12,18 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +|Model.Name| +Generated Location: (1965:55,18 [10] ) +|Model.Name| + +Source Location: (93:5,12 [97] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml) +| + public class NewModel : PageModel + { + public string Name { get; set; } + } +| +Generated Location: (2211:64,12 [97] ) +| + public class NewModel : PageModel + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs new file mode 100644 index 0000000000..eb6860f4b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.codegen.cs @@ -0,0 +1,67 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "547900310554f446d88da593a245719ee9dbb12f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml")] +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; +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("RouteTemplate", "/About")] + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"547900310554f446d88da593a245719ee9dbb12f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n

New Customer "); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + Write(Model.Name); + +#line default +#line hidden +#nullable disable + WriteLiteral("

\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml" + + public class NewModel : PageModel + { + public string Name { get; set; } + } + +#line default +#line hidden +#nullable disable + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt new file mode 100644 index 0000000000..f43b667b2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate_Runtime.ir.txt @@ -0,0 +1,40 @@ +Document - + RazorCompiledItemAttribute - + 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 + UsingDirective - (36:3,1 [43] RazorPagesWithRouteTemplate.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorCompiledItemMetadataAttribute - + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithRouteTemplate - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (16:1,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + HtmlContent - (79:4,0 [2] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (79:4,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + HtmlContent - (193:11,0 [19] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (193:11,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer + CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name + HtmlContent - (223:12,28 [7] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (223:12,28 [5] RazorPagesWithRouteTemplate.cshtml) - Html -

+ IntermediateToken - (228:12,33 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n + CSharpCode - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) + IntermediateToken - (93:5,12 [97] RazorPagesWithRouteTemplate.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml new file mode 100644 index 0000000000..b78cc65ec7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml @@ -0,0 +1,36 @@ +@page + +@addTagHelper "*, AppCode" +@using Microsoft.AspNetCore.Mvc.RazorPages + +@functions { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } +} + +

New Customer

+
+
+
+ +
+ + +
+
+
+
+ +
+
+
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs new file mode 100644 index 0000000000..08d7f97108 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.cs @@ -0,0 +1,101 @@ +// +#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; +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden +#nullable disable + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" +global::System.Object __typeHelper = "*, AppCode"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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() + { + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" + __o = Name; + +#line default +#line hidden +#nullable disable + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" + + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden +#nullable disable + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.html new file mode 100644 index 0000000000..ae827b1270 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.codegen.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + +

New Customer

+
+
+
+ +
+ + +
+
+
+
+ +
+
+
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt new file mode 100644 index 0000000000..de7cd9dd4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt @@ -0,0 +1,145 @@ +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 + UsingDirective - (38:3,1 [41] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (23:2,14 [12] RazorPagesWithoutModel.cshtml) - "*, 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 - (7:1,0 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (7:1,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + HtmlContent - (35:2,26 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (35:2,26 [2] RazorPagesWithoutModel.cshtml) - Html - \n + HtmlContent - (79:3,42 [4] RazorPagesWithoutModel.cshtml) + IntermediateToken - (79:3,42 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n + HtmlContent - (379:18,1 [77] RazorPagesWithoutModel.cshtml) + IntermediateToken - (379:18,1 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n + IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer + IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (406:21,0 [5] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (450:21,44 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (456:22,4 [31] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (468:22,16 [11] RazorPagesWithoutModel.cshtml) + IntermediateToken - (468:22,16 [11] RazorPagesWithoutModel.cshtml) - Html - text-danger + DefaultTagHelperExecute - + HtmlContent - (487:22,35 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (487:22,35 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (493:23,4 [237] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (517:23,28 [48] RazorPagesWithoutModel.cshtml) + IntermediateToken - (517:23,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (527:24,8 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (578:24,59 [10] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (588:25,8 [130] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (611:25,31 [101] RazorPagesWithoutModel.cshtml) + IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (695:27,38 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (702:27,45 [10] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (600:25,20 [9] RazorPagesWithoutModel.cshtml) + IntermediateToken - (600:25,20 [9] RazorPagesWithoutModel.cshtml) - Html - col-md-10 + DefaultTagHelperExecute - + HtmlContent - (718:28,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (718:28,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (505:23,16 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (505:23,16 [10] RazorPagesWithoutModel.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (730:29,10 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (730:29,10 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (736:30,4 [174] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (760:30,28 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (760:30,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (770:31,8 [128] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (809:31,47 [83] RazorPagesWithoutModel.cshtml) + IntermediateToken - (809:31,47 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (823:32,12 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (882:32,71 [10] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (782:31,20 [25] RazorPagesWithoutModel.cshtml) + IntermediateToken - (782:31,20 [25] RazorPagesWithoutModel.cshtml) - Html - col-md-offset-2 col-md-10 + DefaultTagHelperExecute - + HtmlContent - (898:33,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (898:33,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (748:30,16 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (748:30,16 [10] RazorPagesWithoutModel.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (910:34,10 [11] RazorPagesWithoutModel.cshtml) + IntermediateToken - (910:34,10 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (912:35,0 [7] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (919:35,7 [2] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - (95:5,12 [283] RazorPagesWithoutModel.cshtml) + IntermediateToken - (95:5,12 [283] RazorPagesWithoutModel.cshtml) - CSharp - \n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt new file mode 100644 index 0000000000..3a72396f8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.mappings.txt @@ -0,0 +1,46 @@ +Source Location: (38:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (506:15,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (23:2,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +|"*, AppCode"| +Generated Location: (1500:33,37 [12] ) +|"*, AppCode"| + +Source Location: (566:24,47 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +|Name| +Generated Location: (2208:52,47 [4] ) +|Name| + +Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml) +| + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } +| +Generated Location: (3031:69,12 [283] ) +| + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs new file mode 100644 index 0000000000..26274f3e74 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.codegen.cs @@ -0,0 +1,173 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8bf3954ad78688478de155359db8af32627ee2b8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] +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; +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8bf3954ad78688478de155359db8af32627ee2b8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("form-group"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-offset-2 col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n

New Customer

\r\n
\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n \r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml" + + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden +#nullable disable + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt new file mode 100644 index 0000000000..68f1bee78c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_Runtime.ir.txt @@ -0,0 +1,117 @@ +Document - + RazorCompiledItemAttribute - + 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 + UsingDirective - (38:3,1 [43] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - class - col-md-offset-2 col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (7:1,0 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (7:1,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + HtmlContent - (81:4,0 [2] RazorPagesWithoutModel.cshtml) + IntermediateToken - (81:4,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + HtmlContent - (381:19,0 [75] RazorPagesWithoutModel.cshtml) + IntermediateToken - (381:19,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer + IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html -

+ IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (406:21,0 [5] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (450:21,44 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (456:22,4 [31] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (487:22,35 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (487:22,35 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (493:23,4 [237] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (517:23,28 [48] RazorPagesWithoutModel.cshtml) + IntermediateToken - (517:23,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (527:24,8 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (578:24,59 [10] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (588:25,8 [130] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (611:25,31 [101] RazorPagesWithoutModel.cshtml) + IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (695:27,38 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (702:27,45 [10] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (718:28,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (718:28,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (730:29,10 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (730:29,10 [6] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (736:30,4 [174] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (760:30,28 [10] RazorPagesWithoutModel.cshtml) + IntermediateToken - (760:30,28 [10] RazorPagesWithoutModel.cshtml) - Html - \n + TagHelper - (770:31,8 [128] RazorPagesWithoutModel.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (809:31,47 [83] RazorPagesWithoutModel.cshtml) + IntermediateToken - (809:31,47 [14] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (823:32,12 [7] RazorPagesWithoutModel.cshtml) - Html - + IntermediateToken - (882:32,71 [10] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + HtmlContent - (898:33,14 [6] RazorPagesWithoutModel.cshtml) + IntermediateToken - (898:33,14 [6] RazorPagesWithoutModel.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (910:34,10 [11] RazorPagesWithoutModel.cshtml) + IntermediateToken - (910:34,10 [2] RazorPagesWithoutModel.cshtml) - Html - \n + IntermediateToken - (912:35,0 [7] RazorPagesWithoutModel.cshtml) - Html -
+ IntermediateToken - (919:35,7 [2] RazorPagesWithoutModel.cshtml) - Html - \n + CSharpCode - (95:5,12 [283] RazorPagesWithoutModel.cshtml) + IntermediateToken - (95:5,12 [283] RazorPagesWithoutModel.cshtml) - CSharp - \n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs new file mode 100644 index 0000000000..bce76cb7e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.cs @@ -0,0 +1,114 @@ +// +#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; +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden +#nullable disable + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + #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::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +NewModel __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +global::System.Object __typeHelper = "*, AppCode"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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() + { + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" + __o = Model.Name; + +#line default +#line hidden +#nullable disable + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" + + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden +#nullable disable + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.html new file mode 100644 index 0000000000..dc0c2ec4e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.codegen.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + +

New Customer

+
+
+
+ +
+ + +
+
+
+
+ +
+
+
diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt new file mode 100644 index 0000000000..c142630de7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt @@ -0,0 +1,147 @@ +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 + UsingDirective - (55:4,1 [41] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (16:2,7 [8] RazorPages.cshtml) - NewModel + DirectiveToken - (40:3,14 [12] RazorPages.cshtml) - "*, 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 - (7:1,0 [2] RazorPages.cshtml) + IntermediateToken - (7:1,0 [2] RazorPages.cshtml) - Html - \n + HtmlContent - (52:3,26 [2] RazorPages.cshtml) + IntermediateToken - (52:3,26 [2] RazorPages.cshtml) - Html - \n + HtmlContent - (96:4,42 [4] RazorPages.cshtml) + IntermediateToken - (96:4,42 [4] RazorPages.cshtml) - Html - \n\n + HtmlContent - (473:22,1 [78] RazorPages.cshtml) + IntermediateToken - (473:22,1 [4] RazorPages.cshtml) - Html - \n\n + IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html -

+ IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer + IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html -

+ IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html -
+ IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n + TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (563:26,16 [11] RazorPages.cshtml) + IntermediateToken - (563:26,16 [11] RazorPages.cshtml) - Html - text-danger + DefaultTagHelperExecute - + HtmlContent - (582:26,35 [6] RazorPages.cshtml) + IntermediateToken - (582:26,35 [6] RazorPages.cshtml) - Html - \n + TagHelper - (588:27,4 [243] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (612:27,28 [48] RazorPages.cshtml) + IntermediateToken - (612:27,28 [10] RazorPages.cshtml) - Html - \n + IntermediateToken - (622:28,8 [6] RazorPages.cshtml) - Html - + IntermediateToken - (679:28,65 [10] RazorPages.cshtml) - Html - \n + TagHelper - (689:29,8 [130] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (712:29,31 [101] RazorPages.cshtml) + IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - + IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - + IntermediateToken - (796:31,38 [7] RazorPages.cshtml) - Html - + IntermediateToken - (803:31,45 [10] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (701:29,20 [9] RazorPages.cshtml) + IntermediateToken - (701:29,20 [9] RazorPages.cshtml) - Html - col-md-10 + DefaultTagHelperExecute - + HtmlContent - (819:32,14 [6] RazorPages.cshtml) + IntermediateToken - (819:32,14 [6] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (600:27,16 [10] RazorPages.cshtml) + IntermediateToken - (600:27,16 [10] RazorPages.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (831:33,10 [6] RazorPages.cshtml) + IntermediateToken - (831:33,10 [6] RazorPages.cshtml) - Html - \n + TagHelper - (837:34,4 [174] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (861:34,28 [10] RazorPages.cshtml) + IntermediateToken - (861:34,28 [10] RazorPages.cshtml) - Html - \n + TagHelper - (871:35,8 [128] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (910:35,47 [83] RazorPages.cshtml) + IntermediateToken - (910:35,47 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (924:36,12 [7] RazorPages.cshtml) - Html - + IntermediateToken - (983:36,71 [10] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (883:35,20 [25] RazorPages.cshtml) + IntermediateToken - (883:35,20 [25] RazorPages.cshtml) - Html - col-md-offset-2 col-md-10 + DefaultTagHelperExecute - + HtmlContent - (999:37,14 [6] RazorPages.cshtml) + IntermediateToken - (999:37,14 [6] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (849:34,16 [10] RazorPages.cshtml) + IntermediateToken - (849:34,16 [10] RazorPages.cshtml) - Html - form-group + DefaultTagHelperExecute - + HtmlContent - (1011:38,10 [11] RazorPages.cshtml) + IntermediateToken - (1011:38,10 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (1013:39,0 [7] RazorPages.cshtml) - Html -
+ IntermediateToken - (1020:39,7 [2] RazorPages.cshtml) - Html - \n + CSharpCode - (112:6,12 [360] RazorPages.cshtml) + IntermediateToken - (112:6,12 [360] RazorPages.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt new file mode 100644 index 0000000000..57342529a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.mappings.txt @@ -0,0 +1,57 @@ +Source Location: (55:4,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|using Microsoft.AspNetCore.Mvc.RazorPages| +Generated Location: (494:15,0 [41] ) +|using Microsoft.AspNetCore.Mvc.RazorPages| + +Source Location: (16:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|NewModel| +Generated Location: (1427:33,0 [8] ) +|NewModel| + +Source Location: (40:3,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|"*, AppCode"| +Generated Location: (1714:43,37 [12] ) +|"*, AppCode"| + +Source Location: (661:28,47 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +|Model.Name| +Generated Location: (2410:62,47 [10] ) +|Model.Name| + +Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml) +| + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } +| +Generated Location: (3227:79,12 [360] ) +| + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs new file mode 100644 index 0000000000..f258cbe703 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.codegen.cs @@ -0,0 +1,176 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d33caff161b646a61b273d7c544111395b652557" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), @"mvc.1.0.razor-page", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] +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; +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" +using Microsoft.AspNetCore.Mvc.RazorPages; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d33caff161b646a61b273d7c544111395b652557", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages : global::Microsoft.AspNetCore.Mvc.RazorPages.Page + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("form-group"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-offset-2 col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n

New Customer

\r\n
\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n \r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml" + + public class NewModel : PageModel + { + public IActionResult OnPost(Customer customer) + { + Name = customer.Name; + return Redirect("~/customers/inlinepagemodels/"); + } + + public string Name { get; set; } + } + + public class Customer + { + public string Name { get; set; } + } + +#line default +#line hidden +#nullable disable + [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 Html { get; private set; } + public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + public NewModel Model => ViewData.Model; + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt new file mode 100644 index 0000000000..169b9f0254 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_Runtime.ir.txt @@ -0,0 +1,118 @@ +Document - + RazorCompiledItemAttribute - + 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 + UsingDirective - (55:4,1 [43] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - text-danger - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - form-group - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - class - col-md-offset-2 col-md-10 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (7:1,0 [2] RazorPages.cshtml) + IntermediateToken - (7:1,0 [2] RazorPages.cshtml) - Html - \n + HtmlContent - (98:5,0 [2] RazorPages.cshtml) + IntermediateToken - (98:5,0 [2] RazorPages.cshtml) - Html - \n + HtmlContent - (475:23,0 [76] RazorPages.cshtml) + IntermediateToken - (475:23,0 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html -

+ IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer + IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html -

+ IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html -
+ IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n + TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (582:26,35 [6] RazorPages.cshtml) + IntermediateToken - (582:26,35 [6] RazorPages.cshtml) - Html - \n + TagHelper - (588:27,4 [243] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (612:27,28 [48] RazorPages.cshtml) + IntermediateToken - (612:27,28 [10] RazorPages.cshtml) - Html - \n + IntermediateToken - (622:28,8 [6] RazorPages.cshtml) - Html - + IntermediateToken - (679:28,65 [10] RazorPages.cshtml) - Html - \n + TagHelper - (689:29,8 [130] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (712:29,31 [101] RazorPages.cshtml) + IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - + IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - + IntermediateToken - (796:31,38 [7] RazorPages.cshtml) - Html - + IntermediateToken - (803:31,45 [10] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (819:32,14 [6] RazorPages.cshtml) + IntermediateToken - (819:32,14 [6] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (831:33,10 [6] RazorPages.cshtml) + IntermediateToken - (831:33,10 [6] RazorPages.cshtml) - Html - \n + TagHelper - (837:34,4 [174] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (861:34,28 [10] RazorPages.cshtml) + IntermediateToken - (861:34,28 [10] RazorPages.cshtml) - Html - \n + TagHelper - (871:35,8 [128] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (910:35,47 [83] RazorPages.cshtml) + IntermediateToken - (910:35,47 [14] RazorPages.cshtml) - Html - \n + IntermediateToken - (924:36,12 [7] RazorPages.cshtml) - Html - + IntermediateToken - (983:36,71 [10] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + HtmlContent - (999:37,14 [6] RazorPages.cshtml) + IntermediateToken - (999:37,14 [6] RazorPages.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (1011:38,10 [11] RazorPages.cshtml) + IntermediateToken - (1011:38,10 [2] RazorPages.cshtml) - Html - \n + IntermediateToken - (1013:39,0 [7] RazorPages.cshtml) - Html -
+ IntermediateToken - (1020:39,7 [2] RazorPages.cshtml) - Html - \n + CSharpCode - (112:6,12 [360] RazorPages.cshtml) + IntermediateToken - (112:6,12 [360] RazorPages.cshtml) - CSharp - \n public class NewModel : PageModel\n {\n public IActionResult OnPost(Customer customer)\n {\n Name = customer.Name;\n return Redirect("~/customers/inlinepagemodels/");\n }\n\n public string Name { get; set; }\n }\n\n public class Customer\n {\n public string Name { get; set; }\n }\n + Inject - + Inject - + Inject - + Inject - + Inject - + CSharpCode - + IntermediateToken - - CSharp - public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData; + CSharpCode - + IntermediateToken - - CSharp - public NewModel Model => ViewData.Model; diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml new file mode 100644 index 0000000000..7438788ff4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml @@ -0,0 +1,14 @@ +@model DateTime + +@addTagHelper "InputTestTagHelper, AppCode" + +@{ + Layout = "_SectionTestLayout.cshtml"; +} + +
Some body
+ +@section Section1 { +
This is in Section 1
+ +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs new file mode 100644 index 0000000000..81e8732052 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -0,0 +1,96 @@ +// +#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_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +DateTime __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object __typeHelper = "InputTestTagHelper, AppCode"; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object Section1 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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() + { +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml"; + +#line default +#line hidden +#nullable disable + DefineSection("Section1", async(__razor_section_writer) => { + __InputTestTagHelper = CreateTagHelper(); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden +#nullable disable + 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.html new file mode 100644 index 0000000000..849f18b015 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.html @@ -0,0 +1,14 @@ + + + + + + + + +
Some body
+ + +
This is in Section 1
+ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt new file mode 100644 index 0000000000..f043a5f6d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -0,0 +1,75 @@ +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_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (7:0,7 [8] Sections.cshtml) - DateTime + DirectiveToken - (33:2,14 [29] Sections.cshtml) - "InputTestTagHelper, AppCode" + DirectiveToken - (152:10,9 [8] Sections.cshtml) - Section1 + 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] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + HtmlContent - (62:2,43 [4] Sections.cshtml) + IntermediateToken - (62:2,43 [4] Sections.cshtml) - Html - \n\n + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n + Section - - Section1 + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt new file mode 100644 index 0000000000..0b447c4139 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|DateTime| +Generated Location: (1246:26,0 [8] ) +|DateTime| + +Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|"InputTestTagHelper, AppCode"| +Generated Location: (1531:36,37 [29] ) +|"InputTestTagHelper, AppCode"| + +Source Location: (152:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Section1| +Generated Location: (1799:46,22 [8] ) +|Section1| + +Source Location: (68:4,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +| + Layout = "_SectionTestLayout.cshtml"; +| +Generated Location: (2304:63,2 [46] ) +| + Layout = "_SectionTestLayout.cshtml"; +| + +Source Location: (222:12,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Date| +Generated Location: (2767:73,102 [4] ) +|Date| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs new file mode 100644 index 0000000000..e655481c1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -0,0 +1,92 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4b7b87da15db4343c99430c0813fd6bc03643453" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4b7b87da15db4343c99430c0813fd6bc03643453", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml"; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n
Some body
\r\n\r\n"); + DefineSection("Section1", async() => { + WriteLiteral("\r\n
This is in Section 1
\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTestTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTestTagHelper); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date); + +#line default +#line hidden +#nullable disable + __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(); + WriteLiteral("\r\n"); + } + ); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt new file mode 100644 index 0000000000..cd3fe0dbad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -0,0 +1,53 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (17:1,0 [2] Sections.cshtml) + IntermediateToken - (17:1,0 [2] Sections.cshtml) - Html - \n + HtmlContent - (64:3,0 [2] Sections.cshtml) + IntermediateToken - (64:3,0 [2] Sections.cshtml) - Html - \n + CSharpCode - (68:4,2 [46] Sections.cshtml) + IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n + HtmlContent - (117:7,0 [26] Sections.cshtml) + IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html -
+ IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body + IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html -
+ IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n + Section - - Section1 + HtmlContent - (162:10,19 [43] Sections.cshtml) + IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html -
+ IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html -
+ IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n + TagHelper - (205:12,4 [25] Sections.cshtml) - input-test - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTestTagHelper + DefaultTagHelperProperty - (222:12,21 [4] Sections.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model => + IntermediateToken - - CSharp - __model. + IntermediateToken - (222:12,21 [4] Sections.cshtml) - CSharp - Date + IntermediateToken - - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (230:12,29 [2] Sections.cshtml) + IntermediateToken - (230:12,29 [2] Sections.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml new file mode 100644 index 0000000000..ed2648a986 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml @@ -0,0 +1,4 @@ +@using System.ComponentModel +@using System.Collections +@using System +@using System \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.cs new file mode 100644 index 0000000000..11eff28154 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.cs @@ -0,0 +1,67 @@ +// +#pragma warning disable 1591 +namespace AspNetCore +{ + #line hidden + using TModel = global::System.Object; + 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; +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.ComponentModel; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.Collections; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden +#nullable disable + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.html new file mode 100644 index 0000000000..52fe51a130 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.codegen.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.ir.txt new file mode 100644 index 0000000000..0163b00a81 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.ir.txt @@ -0,0 +1,46 @@ +Document - + NamespaceDeclaration - - AspNetCore + UsingDirective - - TModel = global::System.Object + 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 + UsingDirective - (1:0,1 [27] UsingDirectives.cshtml) - System.ComponentModel + UsingDirective - (31:1,1 [24] UsingDirectives.cshtml) - System.Collections + UsingDirective - (58:2,1 [12] UsingDirectives.cshtml) - System + UsingDirective - (73:3,1 [12] UsingDirectives.cshtml) - System + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, 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 - (28:0,28 [2] UsingDirectives.cshtml) + IntermediateToken - (28:0,28 [2] UsingDirectives.cshtml) - Html - \n + HtmlContent - (55:1,25 [2] UsingDirectives.cshtml) + IntermediateToken - (55:1,25 [2] UsingDirectives.cshtml) - Html - \n + HtmlContent - (70:2,13 [2] UsingDirectives.cshtml) + IntermediateToken - (70:2,13 [2] UsingDirectives.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.mappings.txt new file mode 100644 index 0000000000..4337c16790 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (1:0,1 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System.ComponentModel| +Generated Location: (480:14,0 [27] ) +|using System.ComponentModel| + +Source Location: (31:1,1 [24] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System.Collections| +Generated Location: (670:21,0 [24] ) +|using System.Collections| + +Source Location: (58:2,1 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System| +Generated Location: (857:28,0 [12] ) +|using System| + +Source Location: (73:3,1 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml) +|using System| +Generated Location: (1032:35,0 [12] ) +|using System| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.codegen.cs new file mode 100644 index 0000000000..9cd56d20e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.codegen.cs @@ -0,0 +1,62 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "452979e8e4dd77a84a4c50425dd3a162e265990d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml")] +namespace AspNetCore +{ + #line hidden + 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; +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.ComponentModel; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System.Collections; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml" +using System; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"452979e8e4dd77a84a4c50425dd3a162e265990d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.ir.txt new file mode 100644 index 0000000000..a2ef127e9a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/UsingDirectives_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - AspNetCore + 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 + UsingDirective - (1:0,1 [29] UsingDirectives.cshtml) - System.ComponentModel + UsingDirective - (31:1,1 [26] UsingDirectives.cshtml) - System.Collections + UsingDirective - (58:2,1 [14] UsingDirectives.cshtml) - System + UsingDirective - (73:3,1 [12] UsingDirectives.cshtml) - System + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_UsingDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml new file mode 100644 index 0000000000..0430ccfc69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml @@ -0,0 +1,6 @@ +@addTagHelper "*, AppCode" +@{ + var foo = "Hello"; +} + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..949d5a2480 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.cs @@ -0,0 +1,96 @@ +// +#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_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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::AllTagHelper __AllTagHelper; + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" +global::System.Object __typeHelper = "*, AppCode"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + + var foo = "Hello"; + +#line default +#line hidden +#nullable disable + __AllTagHelper = CreateTagHelper(); + __TestViewComponentTagHelper = CreateTagHelper(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + __o = foo; + +#line default +#line hidden +#nullable disable + __TestViewComponentTagHelper.firstName = string.Empty; + __AllTagHelper.Bar = " World"; + 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 Html { get; private set; } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")] + public class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper + { + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __helper = null; + public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + __helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.String firstName { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext __context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput __output) + { + (__helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var __helperContent = await __helper.InvokeAsync("Test", new { firstName }); + __output.TagName = null; + __output.Content.SetHtmlContent(__helperContent); + } + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.html new file mode 100644 index 0000000000..5b456be824 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.codegen.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..8e7497e7d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.ir.txt @@ -0,0 +1,59 @@ +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_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (14:0,14 [12] ViewComponentTagHelper.cshtml) - "*, 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 - (26:0,26 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (26:0,26 [2] ViewComponentTagHelper.cshtml) - Html - \n + CSharpCode - (30:1,2 [26] ViewComponentTagHelper.cshtml) + IntermediateToken - (30:1,2 [26] ViewComponentTagHelper.cshtml) - CSharp - \n var foo = "Hello";\n + HtmlContent - (59:4,0 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (59:4,0 [2] ViewComponentTagHelper.cshtml) - Html - \n + TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - AllTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper + DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) + IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo + DefaultTagHelperProperty - (93:5,32 [6] ViewComponentTagHelper.cshtml) - bar - string AllTagHelper.Bar - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (93:5,32 [6] ViewComponentTagHelper.cshtml) + IntermediateToken - (93:5,32 [6] ViewComponentTagHelper.cshtml) - Html - World + DefaultTagHelperExecute - + Inject - + Inject - + Inject - + Inject - + Inject - + ViewComponentTagHelper - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..bd8d1df67f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_DesignTime.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +|"*, AppCode"| +Generated Location: (1484:27,37 [12] ) +|"*, AppCode"| + +Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +| + var foo = "Hello"; +| +Generated Location: (1999:44,2 [26] ) +| + var foo = "Hello"; +| + +Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml) +|foo| +Generated Location: (2488:54,22 [3] ) +|foo| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..64d0b0ebb4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.codegen.cs @@ -0,0 +1,113 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf860c3a5e96240c9d41a0b950e49c1a165ca44d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"bf860c3a5e96240c9d41a0b950e49c1a165ca44d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + private global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper __TestViewComponentTagHelper; + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bar", " World", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::AllTagHelper __AllTagHelper; + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + + var foo = "Hello"; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("vc:test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __AllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__AllTagHelper); + __TestViewComponentTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestViewComponentTagHelper); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml" + WriteLiteral(foo); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestViewComponentTagHelper.firstName = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("first-name", __TestViewComponentTagHelper.firstName, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __AllTagHelper.Bar = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #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 Html { get; private set; } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute("vc:test")] + public class __Generated__TestViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper + { + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __helper = null; + public __Generated__TestViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + __helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.String firstName { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext __context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput __output) + { + (__helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var __helperContent = await __helper.InvokeAsync("Test", new { firstName }); + __output.TagName = null; + __output.Content.SetHtmlContent(__helperContent); + } + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..2390c1e5c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper_Runtime.ir.txt @@ -0,0 +1,36 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + FieldDeclaration - - private - global::AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper - __TestViewComponentTagHelper + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - bar - World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::AllTagHelper - __AllTagHelper + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (30:1,2 [26] ViewComponentTagHelper.cshtml) + IntermediateToken - (30:1,2 [26] ViewComponentTagHelper.cshtml) - CSharp - \n var foo = "Hello";\n + HtmlContent - (59:4,0 [2] ViewComponentTagHelper.cshtml) + IntermediateToken - (59:4,0 [2] ViewComponentTagHelper.cshtml) - Html - \n + TagHelper - (61:5,0 [50] ViewComponentTagHelper.cshtml) - vc:test - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - AllTagHelper + DefaultTagHelperCreate - - AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper.__Generated__TestViewComponentTagHelper + DefaultTagHelperProperty - (82:5,21 [4] ViewComponentTagHelper.cshtml) - first-name - string TestViewComponentTagHelper.firstName - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (83:5,22 [3] ViewComponentTagHelper.cshtml) + IntermediateToken - (83:5,22 [3] ViewComponentTagHelper.cshtml) - CSharp - foo + PreallocatedTagHelperProperty - (93:5,32 [6] ViewComponentTagHelper.cshtml) - __tagHelperAttribute_0 - bar - Bar + DefaultTagHelperExecute - + Inject - + Inject - + Inject - + Inject - + Inject - + ViewComponentTagHelper - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml new file mode 100644 index 0000000000..eaf33e48ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml @@ -0,0 +1,2 @@ +@namespace Test.Namespace +

Hi There!

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs new file mode 100644 index 0000000000..4f9c742ead --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Test.Namespace +{ + #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_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml" +global::System.Object __typeHelper = nameof(Test.Namespace); + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.html new file mode 100644 index 0000000000..835b3a68ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.codegen.html @@ -0,0 +1,2 @@ + +

Hi There!

diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt new file mode 100644 index 0000000000..0af8488598 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test.Namespace + 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_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (11:0,11 [14] ViewWithNamespace.cshtml) - Test.Namespace + 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 - (27:1,0 [20] ViewWithNamespace.cshtml) + IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt new file mode 100644 index 0000000000..927c17b475 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (11:0,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml) +|Test.Namespace| +Generated Location: (837:20,44 [14] ) +|Test.Namespace| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs new file mode 100644 index 0000000000..8bc8dc2d56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.codegen.cs @@ -0,0 +1,36 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "471b74bb73c8ae8e0ed24c654340198b9b4a1ec8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] +namespace Test.Namespace +{ + #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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"471b74bb73c8ae8e0ed24c654340198b9b4a1ec8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 1998 + public async override global::System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("

Hi There!

\r\n"); + } + #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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt new file mode 100644 index 0000000000..f0b68a6453 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_Runtime.ir.txt @@ -0,0 +1,24 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Test.Namespace + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (27:1,0 [20] ViewWithNamespace.cshtml) + IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There! + IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html -

+ IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml new file mode 100644 index 0000000000..f4e110d289 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml @@ -0,0 +1 @@ +@inject IHtmlHelper Helper \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs new file mode 100644 index 0000000000..8d14c6501d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.cs @@ -0,0 +1,62 @@ +// +#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__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" +IHtmlHelper __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" +global::System.Object Helper = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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 IHtmlHelper Helper { 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.html new file mode 100644 index 0000000000..262e601e9c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.codegen.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt new file mode 100644 index 0000000000..b677049ce1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -0,0 +1,40 @@ +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__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + DesignTimeDirective - + DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper + 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 - (729:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (832:14,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor + DirectiveToken - (8:0,8 [19] _ViewImports.cshtml) - IHtmlHelper + DirectiveToken - (28:0,28 [6] _ViewImports.cshtml) - Helper + 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 - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt new file mode 100644 index 0000000000..d95f0ecc0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) +|IHtmlHelper| +Generated Location: (779:20,0 [19] ) +|IHtmlHelper| + +Source Location: (28:0,28 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml) +|Helper| +Generated Location: (1064:30,22 [6] ) +|Helper| + diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs new file mode 100644 index 0000000000..d319412226 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.codegen.cs @@ -0,0 +1,37 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "74c90591b68437a0868e91dc714ea9827ab8e03a" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] +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; + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"74c90591b68437a0868e91dc714ea9827ab8e03a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage + { + #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 IHtmlHelper Helper { 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 Html { get; private set; } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt new file mode 100644 index 0000000000..f4eeece9fd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_Runtime.ir.txt @@ -0,0 +1,19 @@ +Document - + RazorCompiledItemAttribute - + 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 + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + Inject - + Inject - + Inject - + Inject - + Inject - + Inject - diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs new file mode 100644 index 0000000000..8e874ac608 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -0,0 +1,485 @@ +// 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.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class ViewComponentTagHelperDescriptorFactoryTest + { + private static readonly Assembly _assembly = typeof(ViewComponentTagHelperDescriptorFactoryTest).GetTypeInfo().Assembly; + + [Fact] + public void CreateDescriptor_UnderstandsStringParameters() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(StringParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__StringParameterViewComponentTagHelper", + typeof(StringParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__StringParameterViewComponentTagHelper") + .DisplayName("StringParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:string-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "StringParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_UnderstandsVariousParameterTypes() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(VariousParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__VariousParameterViewComponentTagHelper", + typeof(VariousParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__VariousParameterViewComponentTagHelper") + .DisplayName("VariousParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:various-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("test-enum")) + .RequireAttributeDescriptor(attribute => attribute.Name("test-string")) + .RequireAttributeDescriptor(attribute => attribute.Name("baz"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("test-enum") + .PropertyName("testEnum") + .TypeName(typeof(VariousParameterViewComponent).FullName + "." + nameof(VariousParameterViewComponent.TestEnum)) + .AsEnum() + .DisplayName(typeof(VariousParameterViewComponent).FullName + "." + nameof(VariousParameterViewComponent.TestEnum) + " VariousParameterViewComponentTagHelper.testEnum")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("test-string") + .PropertyName("testString") + .TypeName(typeof(string).FullName) + .DisplayName("string VariousParameterViewComponentTagHelper.testString")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("baz") + .PropertyName("baz") + .TypeName(typeof(int).FullName) + .DisplayName("int VariousParameterViewComponentTagHelper.baz")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "VariousParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_UnderstandsGenericParameters() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(GenericParameterViewComponent).FullName); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__GenericParameterViewComponentTagHelper", + typeof(GenericParameterViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__GenericParameterViewComponentTagHelper") + .DisplayName("GenericParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:generic-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("Foo") + .TypeName("System.Collections.Generic.List") + .DisplayName("System.Collections.Generic.List GenericParameterViewComponentTagHelper.Foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("Bar") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionaryAttribute("bar-", typeof(int).FullName) + .DisplayName("System.Collections.Generic.Dictionary GenericParameterViewComponentTagHelper.Bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "GenericParameter") + .Build(); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_ForSyncViewComponentWithInvokeInBaseType_Works() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__SyncDerivedViewComponentTagHelper", + typeof(SyncDerivedViewComponent).GetTypeInfo().Assembly.GetName().Name) + .TypeName("__Generated__SyncDerivedViewComponentTagHelper") + .DisplayName("SyncDerivedViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:sync-derived") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string SyncDerivedViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string SyncDerivedViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "SyncDerived") + .Build(); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncDerivedViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_ForAsyncViewComponentWithInvokeInBaseType_Works() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__AsyncDerivedViewComponentTagHelper", + typeof(AsyncDerivedViewComponent).Assembly.GetName().Name) + .TypeName("__Generated__AsyncDerivedViewComponentTagHelper") + .DisplayName("AsyncDerivedViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("vc:async-derived")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "AsyncDerived") + .Build(); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncDerivedViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(ViewComponentWithoutInvokeMethod).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoInstanceInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(StaticInvokeAsyncViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_AddsDiagnostic_ForViewComponentWithNoPublicInvokeMethod() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(NonPublicInvokeAsyncViewComponent).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_CannotFindMethod.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_UnderstandsGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Empty(descriptor.GetAllDiagnostics()); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_UnderstandsNonGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithNonGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + Assert.Empty(descriptor.GetAllDiagnostics()); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_DoesNotUnderstandVoid() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithString).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AsyncMethod_ShouldReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvokeAsync_DoesNotUnderstandString() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(AsyncViewComponentWithString).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AsyncMethod_ShouldReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandVoid() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithVoid).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_ShouldReturnValue.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandNonGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithNonGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_CannotReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponentWithInvoke_DoesNotUnderstandGenericTask() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(SyncViewComponentWithGenericTask).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_SyncMethod_CannotReturnTask.Id, diagnostic.Id); + } + + [Fact] + public void CreateDescriptor_ForViewComponent_WithAmbiguousMethods() + { + // Arrange + var testCompilation = TestCompilation.Create(_assembly); + var factory = new ViewComponentTagHelperDescriptorFactory(testCompilation); + + var viewComponent = testCompilation.GetTypeByMetadataName(typeof(DerivedViewComponentWithAmbiguity).FullName); + + // Act + var descriptor = factory.CreateDescriptor(viewComponent); + + // Assert + var diagnostic = Assert.Single(descriptor.GetAllDiagnostics()); + Assert.Equal(RazorExtensionsDiagnosticFactory.ViewComponent_AmbiguousMethods.Id, diagnostic.Id); + } + } + + public class StringParameterViewComponent + { + public string Invoke(string foo, string bar) => null; + } + + public class VariousParameterViewComponent + { + public string Invoke(TestEnum testEnum, string testString, int baz = 5) => null; + + public enum TestEnum + { + A = 1, + B = 2, + C = 3 + } + } + + public class GenericParameterViewComponent + { + public string Invoke(List Foo, Dictionary Bar) => null; + } + + public class ViewComponentWithoutInvokeMethod + { + } + + public class AsyncViewComponentWithGenericTask + { + public Task InvokeAsync() => null; + } + + public class AsyncViewComponentWithNonGenericTask + { + public Task InvokeAsync() => null; + } + + public class AsyncViewComponentWithVoid + { + public void InvokeAsync() { } + } + + public class AsyncViewComponentWithString + { + public string InvokeAsync() => null; + } + + public class SyncViewComponentWithVoid + { + public void Invoke() { } + } + + public class SyncViewComponentWithNonGenericTask + { + public Task Invoke() => null; + } + + public class SyncViewComponentWithGenericTask + { + public Task Invoke() => null; + } + + public class SyncDerivedViewComponent : StringParameterViewComponent + { + } + + public class AsyncDerivedViewComponent : AsyncViewComponentWithNonGenericTask + { + } + + public class DerivedViewComponentWithAmbiguity : AsyncViewComponentWithNonGenericTask + { + public string Invoke() => null; + } + + public class StaticInvokeAsyncViewComponent + { + public static Task InvokeAsync() => null; + } + + public class NonPublicInvokeAsyncViewComponent + { + protected Task InvokeAsync() => null; + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..10faadb243 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs @@ -0,0 +1,69 @@ +// 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.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + // This is just a basic integration test. There are detailed tests for the VCTH visitor and descriptor factory. + public class ViewComponentTagHelperDescriptorProviderTest + { + [Fact] + public void DescriptorProvider_FindsVCTH() + { + // Arrange + var code = @" + public class StringParameterViewComponent + { + public string Invoke(string foo, string bar) => null; + } +"; + + var compilation = MvcShim.BaseCompilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(code)); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ViewComponentTagHelperDescriptorProvider() + { + Engine = RazorProjectEngine.CreateEmpty().Engine, + }; + + var expectedDescriptor = TagHelperDescriptorBuilder.Create( + ViewComponentTagHelperConventions.Kind, + "__Generated__StringParameterViewComponentTagHelper", + TestCompilation.AssemblyName) + .TypeName("__Generated__StringParameterViewComponentTagHelper") + .DisplayName("StringParameterViewComponentTagHelper") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("vc:string-parameter") + .RequireAttributeDescriptor(attribute => attribute.Name("foo")) + .RequireAttributeDescriptor(attribute => attribute.Name("bar"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("foo") + .PropertyName("foo") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.foo")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bar") + .PropertyName("bar") + .TypeName(typeof(string).FullName) + .DisplayName("string StringParameterViewComponentTagHelper.bar")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "StringParameter") + .Build(); + + // Act + provider.Execute(context); + + // Assert + Assert.Single(context.Results, d => TagHelperDescriptorComparer.Default.Equals(d, expectedDescriptor)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs new file mode 100644 index 0000000000..02039ced8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperPassTest.cs @@ -0,0 +1,275 @@ +// 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.Linq; +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 +{ + public class ViewComponentTagHelperPassTest + { + [Fact] + public void ViewComponentTagHelperPass_Execute_IgnoresRegularTagHelper() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly") + .TypeName("TestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var @class = FindClassNode(irDocument); + Assert.Equal(3, @class.Children.Count); // No class node created for a VCTH + for (var i = 0; i < @class.Children.Count; i++) + { + Assert.IsNotType(@class.Children[i]); + } + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("Foo")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(vcthFullName, Assert.IsType(tagHelper.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(tagHelper.Children[2]).PropertyName); + + + var @class = FindClassNode(irDocument); + Assert.Equal(4, @class.Children.Count); + + Assert.IsType(@class.Children.Last()); + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper_WithIndexer() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .PropertyName("Tags") + .AsDictionaryAttribute("foo-", "System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(vcthFullName, Assert.IsType(tagHelper.Children[1]).TypeName); + Assert.IsType(tagHelper.Children[2]); + + var @class = FindClassNode(irDocument); + Assert.Equal(4, @class.Children.Count); + + Assert.IsType(@class.Children[3]); + } + + [Fact] + public void ViewComponentTagHelperPass_Execute_CreatesViewComponentTagHelper_Nested() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper *, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("PTestTagHelper", "TestAssembly") + .TypeName("PTestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .PropertyName("Foo") + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .PropertyName("Foo") + .Name("Foo") + .TypeName("System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build() + }; + + var projectEngine = CreateProjectEngine(tagHelpers); + var pass = new ViewComponentTagHelperPass() + { + Engine = projectEngine.Engine, + }; + + var irDocument = CreateIRDocument(projectEngine, codeDocument); + + var vcthFullName = "AspNetCore.test.__Generated__TagCloudViewComponentTagHelper"; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var outerTagHelper = FindTagHelperNode(irDocument); + Assert.Equal("PTestTagHelper", Assert.IsType(outerTagHelper.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(outerTagHelper.Children[2]).PropertyName); + + var vcth = FindTagHelperNode(outerTagHelper.Children[0]); + Assert.Equal(vcthFullName, Assert.IsType(vcth.Children[1]).TypeName); + Assert.Equal("Foo", Assert.IsType(vcth.Children[2]).PropertyName); + + + var @class = FindClassNode(irDocument); + Assert.Equal(5, @class.Children.Count); + + Assert.IsType(@class.Children.Last()); + } + + private RazorCodeDocument CreateDocument(string content) + { + var source = RazorSourceDocument.Create(content, "test.cshtml"); + return RazorCodeDocument.Create(source); + } + + private RazorProjectEngine CreateProjectEngine(params TagHelperDescriptor[] tagHelpers) + { + return RazorProjectEngine.Create(b => + { + b.Features.Add(new MvcViewDocumentClassifierPass()); + + b.Features.Add(new TestTagHelperFeature(tagHelpers)); + }); + } + + private DocumentIntermediateNode CreateIRDocument(RazorProjectEngine projectEngine, RazorCodeDocument codeDocument) + { + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorDirectiveClassifierPhase) + { + break; + } + } + + // We also expect the default tag helper pass to run first. + var documentNode = codeDocument.GetDocumentIntermediateNode(); + + var defaultTagHelperPass = projectEngine.EngineFeatures.OfType().Single(); + defaultTagHelperPass.Execute(codeDocument, documentNode); + + return codeDocument.GetDocumentIntermediateNode(); + } + + private ClassDeclarationIntermediateNode FindClassNode(IntermediateNode node) + { + var visitor = new ClassDeclarationNodeVisitor(); + visitor.Visit(node); + return visitor.Node; + } + + private TagHelperIntermediateNode FindTagHelperNode(IntermediateNode node) + { + var visitor = new TagHelperNodeVisitor(); + visitor.Visit(node); + return visitor.Node; + } + + private class ClassDeclarationNodeVisitor : IntermediateNodeWalker + { + public ClassDeclarationIntermediateNode Node { get; set; } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + Node = node; + } + } + + private class TagHelperNodeVisitor : IntermediateNodeWalker + { + public TagHelperIntermediateNode Node { get; set; } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + Node = node; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperTargetExtensionTest.cs new file mode 100644 index 0000000000..5ea55d011a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperTargetExtensionTest.cs @@ -0,0 +1,120 @@ +// 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.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class ViewComponentTagHelperTargetExtensionTest + { + [Fact] + public void WriteViewComponentTagHelper_GeneratesViewComponentTagHelper() + { + // Arrange + var tagHelper = TagHelperDescriptorBuilder + .Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("Foo")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build(); + + var extension = new ViewComponentTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new ViewComponentTagHelperIntermediateNode() + { + ClassName = "__Generated__TagCloudViewComponentTagHelper", + TagHelper = tagHelper + }; + + // Act + extension.WriteViewComponentTagHelper(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(""tagcloud"")] +public class __Generated__TagCloudViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __helper = null; + public __Generated__TagCloudViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + __helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Int32 Foo { get; set; } + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext __context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput __output) + { + (__helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var __helperContent = await __helper.InvokeAsync(""TagCloud"", new { Foo }); + __output.TagName = null; + __output.Content.SetHtmlContent(__helperContent); + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteViewComponentTagHelper_GeneratesViewComponentTagHelper_WithIndexer() + { + // Arrange + var tagHelper = TagHelperDescriptorBuilder + .Create(ViewComponentTagHelperConventions.Kind, "TestTagHelper", "TestAssembly") + .TypeName("__Generated__TagCloudViewComponentTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .PropertyName("Tags") + .AsDictionaryAttribute("foo-", "System.Int32")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("tagcloud")) + .AddMetadata(ViewComponentTagHelperMetadata.Name, "TagCloud") + .Build(); + + var extension = new ViewComponentTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new ViewComponentTagHelperIntermediateNode() + { + ClassName = "__Generated__TagCloudViewComponentTagHelper", + TagHelper = tagHelper + }; + + // Act + extension.WriteViewComponentTagHelper(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(""tagcloud"")] +public class __Generated__TagCloudViewComponentTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper +{ + private readonly global::Microsoft.AspNetCore.Mvc.IViewComponentHelper __helper = null; + public __Generated__TagCloudViewComponentTagHelper(global::Microsoft.AspNetCore.Mvc.IViewComponentHelper helper) + { + __helper = helper; + } + [Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute, global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute] + public global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { get; set; } + public System.Collections.Generic.Dictionary Tags { get; set; } + = new System.Collections.Generic.Dictionary(); + public override async global::System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext __context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput __output) + { + (__helper as global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware)?.Contextualize(ViewContext); + var __helperContent = await __helper.InvokeAsync(""TagCloud"", new { Tags }); + __output.TagName = null; + __output.Content.SetHtmlContent(__helperContent); + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs new file mode 100644 index 0000000000..3e72a824bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTypeVisitorTest.cs @@ -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; +using System.Collections.Generic; +using System.Reflection; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions +{ + public class ViewComponentTypeVisitorTest + { + private static readonly Assembly _assembly = typeof(ViewComponentTypeVisitorTest).GetTypeInfo().Assembly; + + private static CSharpCompilation Compilation { get; } = TestCompilation.Create(_assembly); + + // In practice MVC will provide a marker attribute for ViewComponents. To prevent a circular reference between MVC and Razor + // we can use a test class as a marker. + private static INamedTypeSymbol TestViewComponentAttributeSymbol { get; } = Compilation.GetTypeByMetadataName(typeof(TestViewComponentAttribute).FullName); + private static INamedTypeSymbol TestNonViewComponentAttributeSymbol { get; } = Compilation.GetTypeByMetadataName(typeof(TestNonViewComponentAttribute).FullName); + + [Fact] + public void IsViewComponent_PlainViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_PlainViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_DecoratedViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_DecoratedVC).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_InheritedViewComponent_ReturnsTrue() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_InheritedVC).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.True(isViewComponent); + } + + [Fact] + public void IsViewComponent_AbstractViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_AbstractViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_GenericViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_GenericViewComponent<>).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_InternalViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InternalViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_DecoratedNonViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_DecoratedViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + [Fact] + public void IsViewComponent_InheritedNonViewComponent_ReturnsFalse() + { + // Arrange + var testVisitor = new ViewComponentTypeVisitor( + TestViewComponentAttributeSymbol, + TestNonViewComponentAttributeSymbol, + new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InheritedViewComponent).FullName); + + // Act + var isViewComponent = testVisitor.IsViewComponent(tagHelperSymbol); + + // Assert + Assert.False(isViewComponent); + } + + public abstract class Invalid_AbstractViewComponent + { + } + + public class Invalid_GenericViewComponent + { + } + + internal class Invalid_InternalViewComponent + { + } + + public class Valid_PlainViewComponent + { + } + + [TestViewComponent] + public class Valid_DecoratedVC + { + } + + public class Valid_InheritedVC : Valid_DecoratedVC + { + } + + [TestNonViewComponent] + public class Invalid_DecoratedViewComponent + { + } + + [TestViewComponent] + public class Invalid_InheritedViewComponent : Invalid_DecoratedViewComponent + { + } + + public class TestViewComponentAttribute : Attribute + { + } + + public class TestNonViewComponentAttribute : Attribute + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/xunit.runner.json b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/xunit.runner.json new file mode 100644 index 0000000000..fcf172c8fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "methodDisplay": "method", + "shadowCopy": false +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptor.cs new file mode 100644 index 0000000000..84a83b3e8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptor.cs @@ -0,0 +1,48 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class AllowedChildTagDescriptor : IEquatable + { + public string Name { get; protected set; } + + public string DisplayName { get; protected set; } + + public IReadOnlyList Diagnostics { get; protected set; } + + public bool HasErrors + { + get + { + var errors = Diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); + + return errors; + } + } + + public override string ToString() + { + return DisplayName ?? base.ToString(); + } + + public bool Equals(AllowedChildTagDescriptor other) + { + return AllowedChildTagDescriptorComparer.Default.Equals(this, other); + } + + public override bool Equals(object obj) + { + return Equals(obj as AllowedChildTagDescriptor); + } + + public override int GetHashCode() + { + return AllowedChildTagDescriptorComparer.Default.GetHashCode(this); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorBuilder.cs new file mode 100644 index 0000000000..46fc3cc6aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorBuilder.cs @@ -0,0 +1,17 @@ +// 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.Razor.Language +{ + public abstract class AllowedChildTagDescriptorBuilder + { + public abstract string Name { get; set; } + + public abstract string DisplayName { get; set; } + + public abstract RazorDiagnosticCollection Diagnostics { get; } + + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs new file mode 100644 index 0000000000..f6b4ea5776 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs @@ -0,0 +1,51 @@ +// 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.Extensions.Internal; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class AllowedChildTagDescriptorComparer : IEqualityComparer + { + /// + /// A default instance of the . + /// + public static readonly AllowedChildTagDescriptorComparer Default = + new AllowedChildTagDescriptorComparer(); + + private AllowedChildTagDescriptorComparer() + { + } + + /// + public virtual bool Equals( + AllowedChildTagDescriptor descriptorX, + AllowedChildTagDescriptor descriptorY) + { + if (object.ReferenceEquals(descriptorX, descriptorY)) + { + return true; + } + + if (descriptorX == null ^ descriptorY == null) + { + return false; + } + + return + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && + string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal); + } + + /// + public virtual int GetHashCode(AllowedChildTagDescriptor descriptor) + { + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Name, StringComparer.Ordinal); + + return hash.CombinedHash; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AssemblyExtension.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AssemblyExtension.cs new file mode 100644 index 0000000000..97f1c31c15 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AssemblyExtension.cs @@ -0,0 +1,55 @@ +// 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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class AssemblyExtension : RazorExtension + { + public AssemblyExtension(string extensionName, Assembly assembly) + { + if (extensionName == null) + { + throw new ArgumentNullException(nameof(extensionName)); + } + + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + ExtensionName = extensionName; + Assembly = assembly; + } + + public override string ExtensionName { get; } + + public Assembly Assembly { get; } + + internal RazorExtensionInitializer CreateInitializer() + { + // It's not an error to have an assembly with no initializers. This is useful to specify a dependency + // that doesn't really provide any Razor configuration. + var attributes = Assembly.GetCustomAttributes(); + foreach (var attribute in attributes) + { + // Using extension names and requiring them to line up allows a single assembly to ship multiple + // extensions/initializers for different configurations. + if (!string.Equals(attribute.ExtensionName, ExtensionName, StringComparison.Ordinal)) + { + continue; + } + + // There's no real protection/exception handling here because this set isn't really user-extensible + // right now. This would be a great place to add some additional diagnostics and hardening in the + // future. + var initializer = (RazorExtensionInitializer)Activator.CreateInstance(attribute.InitializerType); + return initializer; + } + + return null; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AttributeStructure.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AttributeStructure.cs new file mode 100644 index 0000000000..9a191578c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AttributeStructure.cs @@ -0,0 +1,15 @@ +// 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.Razor.Language +{ + // This is the design time equivalent of Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle. + // They should be kept in sync. + public enum AttributeStructure + { + DoubleQuotes, + SingleQuotes, + NoQuotes, + Minimized, + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs new file mode 100644 index 0000000000..ecfd96105f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs @@ -0,0 +1,84 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + /// + /// A metadata class describing a tag helper attribute. + /// + public abstract class BoundAttributeDescriptor : IEquatable + { + protected BoundAttributeDescriptor(string kind) + { + Kind = kind; + } + + public string Kind { get; } + + public bool IsIndexerStringProperty { get; protected set; } + + public bool IsIndexerBooleanProperty { get; protected set; } + + public bool IsEnum { get; protected set; } + + public bool IsStringProperty { get; protected set; } + + public bool IsBooleanProperty { get; protected set; } + + public string Name { get; protected set; } + + public string IndexerNamePrefix { get; protected set; } + + public string TypeName { get; protected set; } + + public string IndexerTypeName { get; protected set; } + + public bool HasIndexer { get; protected set; } + + public string Documentation { get; protected set; } + + public string DisplayName { get; protected set; } + + public bool CaseSensitive { get; protected set; } + + public IReadOnlyList Diagnostics { get; protected set; } + + public IReadOnlyDictionary Metadata { get; protected set; } + + public virtual IReadOnlyList BoundAttributeParameters { get; protected set; } + + public bool HasErrors + { + get + { + var errors = Diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); + + return errors; + } + } + + public override string ToString() + { + return DisplayName ?? base.ToString(); + } + + public bool Equals(BoundAttributeDescriptor other) + { + return BoundAttributeDescriptorComparer.Default.Equals(this, other); + } + + public override bool Equals(object obj) + { + return Equals(obj as BoundAttributeDescriptor); + } + + public override int GetHashCode() + { + return BoundAttributeDescriptorComparer.Default.GetHashCode(this); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs new file mode 100644 index 0000000000..b6fb01d7ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs @@ -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 System.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class BoundAttributeDescriptorBuilder + { + public abstract string Name { get; set; } + + public abstract string TypeName { get; set; } + + public abstract bool IsEnum { get; set; } + + public abstract bool IsDictionary { get; set; } + + public abstract string IndexerAttributeNamePrefix { get; set; } + + public abstract string IndexerValueTypeName { get; set; } + + public abstract string Documentation { get; set; } + + public abstract string DisplayName { get; set; } + + public abstract IDictionary Metadata { get; } + + public abstract RazorDiagnosticCollection Diagnostics { get; } + + public virtual IReadOnlyList BoundAttributeParameters { get; } + + public virtual void BindAttributeParameter(Action configure) + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs new file mode 100644 index 0000000000..ac01e48aa1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs @@ -0,0 +1,98 @@ +// 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.Components; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class BoundAttributeDescriptorBuilderExtensions + { + public static void SetPropertyName(this BoundAttributeDescriptorBuilder builder, string propertyName) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (propertyName == null) + { + throw new ArgumentNullException(nameof(propertyName)); + } + + builder.Metadata[TagHelperMetadata.Common.PropertyName] = propertyName; + } + + public static string GetPropertyName(this BoundAttributeDescriptorBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (builder.Metadata.TryGetValue(TagHelperMetadata.Common.PropertyName, out var value)) + { + return value; + } + + return null; + } + + public static void AsDictionary( + this BoundAttributeDescriptorBuilder builder, + string attributeNamePrefix, + string valueTypeName) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.IsDictionary = true; + builder.IndexerAttributeNamePrefix = attributeNamePrefix; + builder.IndexerValueTypeName = valueTypeName; + } + + public static bool IsDirectiveAttribute(this BoundAttributeDescriptorBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + return + builder.Metadata.TryGetValue(ComponentMetadata.Common.DirectiveAttribute, out var value) && + string.Equals(bool.TrueString, value); + } + + public static void SetPropertyName(this BoundAttributeParameterDescriptorBuilder builder, string propertyName) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (propertyName == null) + { + throw new ArgumentNullException(nameof(propertyName)); + } + + builder.Metadata[TagHelperMetadata.Common.PropertyName] = propertyName; + } + + public static string GetPropertyName(this BoundAttributeParameterDescriptorBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (builder.Metadata.TryGetValue(TagHelperMetadata.Common.PropertyName, out var value)) + { + return value; + } + + return null; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs new file mode 100644 index 0000000000..54154a7aaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs @@ -0,0 +1,65 @@ +// 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.Extensions.Internal; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class BoundAttributeDescriptorComparer : IEqualityComparer + { + /// + /// A default instance of the . + /// + public static readonly BoundAttributeDescriptorComparer Default = new BoundAttributeDescriptorComparer(); + + private BoundAttributeDescriptorComparer() + { + } + + public virtual bool Equals(BoundAttributeDescriptor descriptorX, BoundAttributeDescriptor descriptorY) + { + if (object.ReferenceEquals(descriptorX, descriptorY)) + { + return true; + } + + if (descriptorX == null ^ descriptorY == null) + { + return false; + } + + return + string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal) && + descriptorX.IsIndexerStringProperty == descriptorY.IsIndexerStringProperty && + descriptorX.IsEnum == descriptorY.IsEnum && + descriptorX.HasIndexer == descriptorY.HasIndexer && + descriptorX.CaseSensitive == descriptorY.CaseSensitive && + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && + string.Equals(descriptorX.IndexerNamePrefix, descriptorY.IndexerNamePrefix, StringComparison.Ordinal) && + string.Equals(descriptorX.TypeName, descriptorY.TypeName, StringComparison.Ordinal) && + string.Equals(descriptorX.IndexerTypeName, descriptorY.IndexerTypeName, StringComparison.Ordinal) && + string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal) && + string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && + Enumerable.SequenceEqual( + descriptorX.Metadata.OrderBy(propertyX => propertyX.Key, StringComparer.Ordinal), + descriptorY.Metadata.OrderBy(propertyY => propertyY.Key, StringComparer.Ordinal)); + } + + public virtual int GetHashCode(BoundAttributeDescriptor descriptor) + { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Kind); + hash.Add(descriptor.Name, StringComparer.Ordinal); + + return hash.CombinedHash; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorExtensions.cs new file mode 100644 index 0000000000..9ea08e8537 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorExtensions.cs @@ -0,0 +1,87 @@ +// 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.Components; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public static class BoundAttributeDescriptorExtensions + { + public static string GetPropertyName(this BoundAttributeDescriptor attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + attribute.Metadata.TryGetValue(TagHelperMetadata.Common.PropertyName, out var propertyName); + return propertyName; + } + + public static bool IsDefaultKind(this BoundAttributeDescriptor attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return string.Equals(attribute.Kind, TagHelperConventions.DefaultKind, StringComparison.Ordinal); + } + + internal static bool ExpectsStringValue(this BoundAttributeDescriptor attribute, string name) + { + if (attribute.IsStringProperty) + { + return true; + } + + var isIndexerNameMatch = TagHelperMatchingConventions.SatisfiesBoundAttributeIndexer(name, attribute); + return isIndexerNameMatch && attribute.IsIndexerStringProperty; + } + + internal static bool ExpectsBooleanValue(this BoundAttributeDescriptor attribute, string name) + { + if (attribute.IsBooleanProperty) + { + return true; + } + + var isIndexerNameMatch = TagHelperMatchingConventions.SatisfiesBoundAttributeIndexer(name, attribute); + return isIndexerNameMatch && attribute.IsIndexerBooleanProperty; + } + + public static bool IsDirectiveAttribute(this BoundAttributeDescriptor attribute) + { + if (attribute == null) + { + throw new ArgumentNullException(nameof(attribute)); + } + + return + attribute.Metadata.TryGetValue(ComponentMetadata.Common.DirectiveAttribute, out var value) && + string.Equals(bool.TrueString, value); + } + + public static bool IsDefaultKind(this BoundAttributeParameterDescriptor parameter) + { + if (parameter == null) + { + throw new ArgumentNullException(nameof(parameter)); + } + + return string.Equals(parameter.Kind, TagHelperConventions.DefaultKind, StringComparison.Ordinal); + } + + public static string GetPropertyName(this BoundAttributeParameterDescriptor parameter) + { + if (parameter == null) + { + throw new ArgumentNullException(nameof(parameter)); + } + + parameter.Metadata.TryGetValue(TagHelperMetadata.Common.PropertyName, out var propertyName); + return propertyName; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs new file mode 100644 index 0000000000..904718d730 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs @@ -0,0 +1,69 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class BoundAttributeParameterDescriptor : IEquatable + { + protected BoundAttributeParameterDescriptor(string kind) + { + Kind = kind; + } + + public string Kind { get; } + + public bool IsEnum { get; protected set; } + + public bool IsStringProperty { get; protected set; } + + public bool IsBooleanProperty { get; protected set; } + + public string Name { get; protected set; } + + public string TypeName { get; protected set; } + + public string Documentation { get; protected set; } + + public string DisplayName { get; protected set; } + + public bool CaseSensitive { get; protected set; } + + public IReadOnlyList Diagnostics { get; protected set; } + + public IReadOnlyDictionary Metadata { get; protected set; } + + public bool HasErrors + { + get + { + var errors = Diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); + + return errors; + } + } + + public override string ToString() + { + return DisplayName ?? base.ToString(); + } + + public bool Equals(BoundAttributeParameterDescriptor other) + { + return BoundAttributeParameterDescriptorComparer.Default.Equals(this, other); + } + + public override bool Equals(object obj) + { + return Equals(obj as BoundAttributeParameterDescriptor); + } + + public override int GetHashCode() + { + return BoundAttributeParameterDescriptorComparer.Default.GetHashCode(this); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorBuilder.cs new file mode 100644 index 0000000000..64ab98a6ed --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorBuilder.cs @@ -0,0 +1,24 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public abstract class BoundAttributeParameterDescriptorBuilder + { + public abstract string Name { get; set; } + + public abstract string TypeName { get; set; } + + public abstract bool IsEnum { get; set; } + + public abstract string Documentation { get; set; } + + public abstract string DisplayName { get; set; } + + public abstract IDictionary Metadata { get; } + + public abstract RazorDiagnosticCollection Diagnostics { get; } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs new file mode 100644 index 0000000000..6cbc01017c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs @@ -0,0 +1,60 @@ +// 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.Extensions.Internal; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class BoundAttributeParameterDescriptorComparer : IEqualityComparer + { + /// + /// A default instance of the . + /// + public static readonly BoundAttributeParameterDescriptorComparer Default = new BoundAttributeParameterDescriptorComparer(); + + private BoundAttributeParameterDescriptorComparer() + { + } + + public virtual bool Equals(BoundAttributeParameterDescriptor descriptorX, BoundAttributeParameterDescriptor descriptorY) + { + if (object.ReferenceEquals(descriptorX, descriptorY)) + { + return true; + } + + if (descriptorX == null ^ descriptorY == null) + { + return false; + } + + return + string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal) && + descriptorX.IsEnum == descriptorY.IsEnum && + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && + string.Equals(descriptorX.TypeName, descriptorY.TypeName, StringComparison.Ordinal) && + string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal) && + string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && + Enumerable.SequenceEqual( + descriptorX.Metadata.OrderBy(propertyX => propertyX.Key, StringComparer.Ordinal), + descriptorY.Metadata.OrderBy(propertyY => propertyY.Key, StringComparer.Ordinal)); + } + + public virtual int GetHashCode(BoundAttributeParameterDescriptor descriptor) + { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + + var hash = HashCodeCombiner.Start(); + hash.Add(descriptor.Kind); + hash.Add(descriptor.Name, StringComparer.Ordinal); + + return hash.CombinedHash; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CSharpIdentifier.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CSharpIdentifier.cs new file mode 100644 index 0000000000..b5904e6f1d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CSharpIdentifier.cs @@ -0,0 +1,58 @@ +// 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.Globalization; +using System.Text; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal static class CSharpIdentifier + { + // 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 SanitizeIdentifier(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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Checksum.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Checksum.cs new file mode 100644 index 0000000000..57834739e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Checksum.cs @@ -0,0 +1,28 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal static class Checksum + { + public 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(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ClassifiedSpanVisitor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ClassifiedSpanVisitor.cs new file mode 100644 index 0000000000..f162744130 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ClassifiedSpanVisitor.cs @@ -0,0 +1,409 @@ +// 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.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal class ClassifiedSpanVisitor : SyntaxWalker + { + private RazorSourceDocument _source; + private List _spans; + private BlockKindInternal _currentBlockKind; + private SyntaxNode _currentBlock; + + public ClassifiedSpanVisitor(RazorSourceDocument source) + { + if (source is null) + { + throw new ArgumentNullException(nameof(source)); + } + + _source = source; + _spans = new List(); + _currentBlockKind = BlockKindInternal.Markup; + } + + public IReadOnlyList ClassifiedSpans => _spans; + + public override void VisitRazorCommentBlock(RazorCommentBlockSyntax node) + { + WriteBlock(node, BlockKindInternal.Comment, razorCommentSyntax => + { + WriteSpan(razorCommentSyntax.StartCommentTransition, SpanKindInternal.Transition, AcceptedCharactersInternal.None); + WriteSpan(razorCommentSyntax.StartCommentStar, SpanKindInternal.MetaCode, AcceptedCharactersInternal.None); + + var comment = razorCommentSyntax.Comment; + if (comment.IsMissing) + { + // We need to generate a classified span at this position. So insert a marker in its place. + comment = (SyntaxToken)SyntaxFactory.Token(SyntaxKind.Marker, string.Empty).Green.CreateRed(razorCommentSyntax, razorCommentSyntax.StartCommentStar.EndPosition); + } + WriteSpan(comment, SpanKindInternal.Comment, AcceptedCharactersInternal.Any); + + WriteSpan(razorCommentSyntax.EndCommentStar, SpanKindInternal.MetaCode, AcceptedCharactersInternal.None); + WriteSpan(razorCommentSyntax.EndCommentTransition, SpanKindInternal.Transition, AcceptedCharactersInternal.None); + }); + } + + public override void VisitCSharpCodeBlock(CSharpCodeBlockSyntax node) + { + if (node.Parent is CSharpStatementBodySyntax || + node.Parent is CSharpExplicitExpressionBodySyntax || + node.Parent is CSharpImplicitExpressionBodySyntax || + node.Parent is RazorDirectiveBodySyntax || + (_currentBlockKind == BlockKindInternal.Directive && + node.Children.Count == 1 && + node.Children[0] is CSharpStatementLiteralSyntax)) + { + base.VisitCSharpCodeBlock(node); + return; + } + + WriteBlock(node, BlockKindInternal.Statement, base.VisitCSharpCodeBlock); + } + + public override void VisitCSharpStatement(CSharpStatementSyntax node) + { + WriteBlock(node, BlockKindInternal.Statement, base.VisitCSharpStatement); + } + + public override void VisitCSharpExplicitExpression(CSharpExplicitExpressionSyntax node) + { + WriteBlock(node, BlockKindInternal.Expression, base.VisitCSharpExplicitExpression); + } + + public override void VisitCSharpImplicitExpression(CSharpImplicitExpressionSyntax node) + { + WriteBlock(node, BlockKindInternal.Expression, base.VisitCSharpImplicitExpression); + } + + public override void VisitRazorDirective(RazorDirectiveSyntax node) + { + WriteBlock(node, BlockKindInternal.Directive, base.VisitRazorDirective); + } + + public override void VisitCSharpTemplateBlock(CSharpTemplateBlockSyntax node) + { + WriteBlock(node, BlockKindInternal.Template, base.VisitCSharpTemplateBlock); + } + + public override void VisitMarkupBlock(MarkupBlockSyntax node) + { + WriteBlock(node, BlockKindInternal.Markup, base.VisitMarkupBlock); + } + + public override void VisitMarkupTagHelperAttributeValue(MarkupTagHelperAttributeValueSyntax node) + { + // We don't generate a classified span when the attribute value is a simple literal value. + // This is done so we maintain the classified spans generated in 2.x which + // used ConditionalAttributeCollapser (combines markup literal attribute values into one span with no block parent). + if (node.Children.Count > 1 || + (node.Children.Count == 1 && node.Children[0] is MarkupDynamicAttributeValueSyntax)) + { + WriteBlock(node, BlockKindInternal.Markup, base.VisitMarkupTagHelperAttributeValue); + return; + } + + base.VisitMarkupTagHelperAttributeValue(node); + } + + public override void VisitMarkupStartTag(MarkupStartTagSyntax node) + { + WriteBlock(node, BlockKindInternal.Tag, n => + { + var children = GetRewrittenMarkupStartTagChildren(node); + foreach (var child in children) + { + Visit(child); + } + }); + } + + public override void VisitMarkupEndTag(MarkupEndTagSyntax node) + { + WriteBlock(node, BlockKindInternal.Tag, n => + { + var children = GetRewrittenMarkupEndTagChildren(node); + foreach (var child in children) + { + Visit(child); + } + }); + } + + public override void VisitMarkupTagHelperElement(MarkupTagHelperElementSyntax node) + { + WriteBlock(node, BlockKindInternal.Tag, base.VisitMarkupTagHelperElement); + } + + public override void VisitMarkupTagHelperStartTag(MarkupTagHelperStartTagSyntax node) + { + foreach (var child in node.Attributes) + { + if (child is MarkupTagHelperAttributeSyntax || + child is MarkupTagHelperDirectiveAttributeSyntax || + child is MarkupMinimizedTagHelperDirectiveAttributeSyntax) + { + Visit(child); + } + } + } + + public override void VisitMarkupTagHelperEndTag(MarkupTagHelperEndTagSyntax node) + { + // We don't want to generate a classified span for a tag helper end tag. Do nothing. + } + + public override void VisitMarkupAttributeBlock(MarkupAttributeBlockSyntax node) + { + WriteBlock(node, BlockKindInternal.Markup, n => + { + var equalsSyntax = SyntaxFactory.MarkupTextLiteral(new SyntaxList(node.EqualsToken)); + var mergedAttributePrefix = SyntaxUtilities.MergeTextLiterals(node.NamePrefix, node.Name, node.NameSuffix, equalsSyntax, node.ValuePrefix); + Visit(mergedAttributePrefix); + Visit(node.Value); + Visit(node.ValueSuffix); + }); + } + + public override void VisitMarkupTagHelperAttribute(MarkupTagHelperAttributeSyntax node) + { + Visit(node.Value); + } + + public override void VisitMarkupTagHelperDirectiveAttribute(MarkupTagHelperDirectiveAttributeSyntax node) + { + Visit(node.Transition); + Visit(node.Colon); + Visit(node.Value); + } + + public override void VisitMarkupMinimizedTagHelperDirectiveAttribute(MarkupMinimizedTagHelperDirectiveAttributeSyntax node) + { + Visit(node.Transition); + Visit(node.Colon); + } + + public override void VisitMarkupMinimizedAttributeBlock(MarkupMinimizedAttributeBlockSyntax node) + { + WriteBlock(node, BlockKindInternal.Markup, n => + { + var mergedAttributePrefix = SyntaxUtilities.MergeTextLiterals(node.NamePrefix, node.Name); + Visit(mergedAttributePrefix); + }); + } + + public override void VisitMarkupCommentBlock(MarkupCommentBlockSyntax node) + { + WriteBlock(node, BlockKindInternal.HtmlComment, base.VisitMarkupCommentBlock); + } + + public override void VisitMarkupDynamicAttributeValue(MarkupDynamicAttributeValueSyntax node) + { + WriteBlock(node, BlockKindInternal.Markup, base.VisitMarkupDynamicAttributeValue); + } + + public override void VisitRazorMetaCode(RazorMetaCodeSyntax node) + { + WriteSpan(node, SpanKindInternal.MetaCode); + base.VisitRazorMetaCode(node); + } + + public override void VisitCSharpTransition(CSharpTransitionSyntax node) + { + WriteSpan(node, SpanKindInternal.Transition); + base.VisitCSharpTransition(node); + } + + public override void VisitMarkupTransition(MarkupTransitionSyntax node) + { + WriteSpan(node, SpanKindInternal.Transition); + base.VisitMarkupTransition(node); + } + + public override void VisitCSharpStatementLiteral(CSharpStatementLiteralSyntax node) + { + WriteSpan(node, SpanKindInternal.Code); + base.VisitCSharpStatementLiteral(node); + } + + public override void VisitCSharpExpressionLiteral(CSharpExpressionLiteralSyntax node) + { + WriteSpan(node, SpanKindInternal.Code); + base.VisitCSharpExpressionLiteral(node); + } + + public override void VisitCSharpEphemeralTextLiteral(CSharpEphemeralTextLiteralSyntax node) + { + WriteSpan(node, SpanKindInternal.Code); + base.VisitCSharpEphemeralTextLiteral(node); + } + + public override void VisitUnclassifiedTextLiteral(UnclassifiedTextLiteralSyntax node) + { + WriteSpan(node, SpanKindInternal.None); + base.VisitUnclassifiedTextLiteral(node); + } + + public override void VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node) + { + WriteSpan(node, SpanKindInternal.Markup); + base.VisitMarkupLiteralAttributeValue(node); + } + + public override void VisitMarkupTextLiteral(MarkupTextLiteralSyntax node) + { + if (node.Parent is MarkupLiteralAttributeValueSyntax) + { + base.VisitMarkupTextLiteral(node); + return; + } + + WriteSpan(node, SpanKindInternal.Markup); + base.VisitMarkupTextLiteral(node); + } + + public override void VisitMarkupEphemeralTextLiteral(MarkupEphemeralTextLiteralSyntax node) + { + WriteSpan(node, SpanKindInternal.Markup); + base.VisitMarkupEphemeralTextLiteral(node); + } + + private void WriteBlock(TNode node, BlockKindInternal kind, Action handler) where TNode : SyntaxNode + { + var previousBlock = _currentBlock; + var previousKind = _currentBlockKind; + + _currentBlock = node; + _currentBlockKind = kind; + + handler(node); + + _currentBlock = previousBlock; + _currentBlockKind = previousKind; + } + + private void WriteSpan(SyntaxNode node, SpanKindInternal kind, AcceptedCharactersInternal? acceptedCharacters = null) + { + if (node.IsMissing) + { + return; + } + + var spanSource = node.GetSourceSpan(_source); + var blockSource = _currentBlock.GetSourceSpan(_source); + if (!acceptedCharacters.HasValue) + { + acceptedCharacters = AcceptedCharactersInternal.Any; + var context = node.GetSpanContext(); + if (context != null) + { + acceptedCharacters = context.EditHandler.AcceptedCharacters; + } + } + + var span = new ClassifiedSpanInternal(spanSource, blockSource, kind, _currentBlockKind, acceptedCharacters.Value); + _spans.Add(span); + } + + private static SyntaxList GetRewrittenMarkupStartTagChildren(MarkupStartTagSyntax node) + { + // Rewrites the children of the start tag to look like the legacy syntax tree. + if (node.IsMarkupTransition) + { + var tokens = node.DescendantNodes().Where(n => n is SyntaxToken token && !token.IsMissing).Cast().ToArray(); + var tokenBuilder = SyntaxListBuilder.Create(); + tokenBuilder.AddRange(tokens, 0, tokens.Length); + var markupTransition = SyntaxFactory.MarkupTransition(tokenBuilder.ToList()).Green.CreateRed(node, node.Position); + var spanContext = node.GetSpanContext(); + if (spanContext != null) + { + markupTransition = markupTransition.WithSpanContext(spanContext); + } + + var builder = new SyntaxListBuilder(1); + builder.Add(markupTransition); + return new SyntaxList(builder.ToListNode().CreateRed(node, node.Position)); + } + + SpanContext latestSpanContext = null; + var children = node.Children; + var newChildren = new SyntaxListBuilder(children.Count); + var literals = new List(); + foreach (var child in children) + { + if (child is MarkupTextLiteralSyntax literal) + { + literals.Add(literal); + latestSpanContext = literal.GetSpanContext() ?? latestSpanContext; + } + else if (child is MarkupMiscAttributeContentSyntax miscContent) + { + foreach (var contentChild in miscContent.Children) + { + if (contentChild is MarkupTextLiteralSyntax contentLiteral) + { + literals.Add(contentLiteral); + latestSpanContext = contentLiteral.GetSpanContext() ?? latestSpanContext; + } + else + { + // Pop stack + AddLiteralIfExists(); + newChildren.Add(contentChild); + } + } + } + else + { + AddLiteralIfExists(); + newChildren.Add(child); + } + } + + AddLiteralIfExists(); + + return new SyntaxList(newChildren.ToListNode().CreateRed(node, node.Position)); + + void AddLiteralIfExists() + { + if (literals.Count > 0) + { + var mergedLiteral = SyntaxUtilities.MergeTextLiterals(literals.ToArray()); + mergedLiteral = mergedLiteral.WithSpanContext(latestSpanContext); + literals.Clear(); + latestSpanContext = null; + newChildren.Add(mergedLiteral); + } + } + } + + private static SyntaxList GetRewrittenMarkupEndTagChildren(MarkupEndTagSyntax node) + { + // Rewrites the children of the end tag to look like the legacy syntax tree. + if (node.IsMarkupTransition) + { + var tokens = node.DescendantNodes().Where(n => n is SyntaxToken token && !token.IsMissing).Cast().ToArray(); + var tokenBuilder = SyntaxListBuilder.Create(); + tokenBuilder.AddRange(tokens, 0, tokens.Length); + var markupTransition = SyntaxFactory.MarkupTransition(tokenBuilder.ToList()).Green.CreateRed(node, node.Position); + var spanContext = node.GetSpanContext(); + if (spanContext != null) + { + markupTransition = markupTransition.WithSpanContext(spanContext); + } + + var builder = new SyntaxListBuilder(1); + builder.Add(markupTransition); + return new SyntaxList(builder.ToListNode().CreateRed(node, node.Position)); + } + + return node.Children; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeRenderingContext.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeRenderingContext.cs new file mode 100644 index 0000000000..d144558bb0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeRenderingContext.cs @@ -0,0 +1,47 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public abstract class CodeRenderingContext + { + internal static readonly object NewLineString = "NewLineString"; + + internal static readonly object SuppressUniqueIds = "SuppressUniqueIds"; + + public abstract IEnumerable Ancestors { get; } + + public abstract CodeWriter CodeWriter { get; } + + public abstract RazorDiagnosticCollection Diagnostics { get; } + + public abstract string DocumentKind { get; } + + public abstract ItemCollection Items { get; } + + public abstract IntermediateNodeWriter NodeWriter { get; } + + public abstract RazorCodeGenerationOptions Options { get; } + + public abstract IntermediateNode Parent { get; } + + public abstract RazorSourceDocument SourceDocument { get; } + + public abstract void AddSourceMappingFor(IntermediateNode node); + + public abstract void RenderNode(IntermediateNode node); + + public abstract void RenderNode(IntermediateNode node, IntermediateNodeWriter writer); + + public abstract void RenderChildren(IntermediateNode node); + + public abstract void RenderChildren(IntermediateNode node, IntermediateNodeWriter writer); + + public virtual void AddLinePragma(LinePragma linePragma) + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeTarget.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeTarget.cs new file mode 100644 index 0000000000..ba8ba8b48c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeTarget.cs @@ -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; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public abstract class CodeTarget + { + public static CodeTarget CreateDefault(RazorCodeDocument codeDocument, RazorCodeGenerationOptions options) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return CreateDefault(codeDocument, options, configure: null); + } + + public static CodeTarget CreateDefault( + RazorCodeDocument codeDocument, + RazorCodeGenerationOptions options, + Action configure) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var builder = new DefaultCodeTargetBuilder(codeDocument, options); + + if (builder.Options.DesignTime) + { + AddDesignTimeDefaults(builder); + } + else + { + AddRuntimeDefaults(builder); + } + + if (configure != null) + { + configure.Invoke(builder); + } + + return builder.Build(); + } + + public static CodeTarget CreateEmpty( + RazorCodeDocument codeDocument, + RazorCodeGenerationOptions options, + Action configure) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var builder = new DefaultCodeTargetBuilder(codeDocument, options); + configure?.Invoke(builder); + return builder.Build(); + } + + internal static void AddDesignTimeDefaults(CodeTargetBuilder builder) + { + + } + + internal static void AddRuntimeDefaults(CodeTargetBuilder builder) + { + + } + + public abstract IntermediateNodeWriter CreateNodeWriter(); + + public abstract TExtension GetExtension() where TExtension : class, ICodeTargetExtension; + + public abstract bool HasExtension() where TExtension : class, ICodeTargetExtension; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeTargetBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeTargetBuilder.cs new file mode 100644 index 0000000000..de9daf2ea6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeTargetBuilder.cs @@ -0,0 +1,18 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public abstract class CodeTargetBuilder + { + public abstract RazorCodeDocument CodeDocument { get; } + + public abstract RazorCodeGenerationOptions Options { get; } + + public abstract ICollection TargetExtensions { get; } + + public abstract CodeTarget Build(); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriter.cs new file mode 100644 index 0000000000..5b44fbc7fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriter.cs @@ -0,0 +1,207 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public sealed class CodeWriter + { + private static readonly char[] NewLineCharacters = { '\r', '\n' }; + + private readonly StringBuilder _builder; + + private string _newLine; + + private int _absoluteIndex; + private int _currentLineIndex; + private int _currentLineCharacterIndex; + + public CodeWriter() + { + NewLine = Environment.NewLine; + _builder = new StringBuilder(); + } + + public int CurrentIndent { get; set; } + + public int Length => _builder.Length; + + public string NewLine + { + get => _newLine; + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + if (value != "\r\n" && value != "\n") + { + throw new ArgumentException(Resources.FormatCodeWriter_InvalidNewLine(value), nameof(value)); + } + + _newLine = value; + } + } + + public SourceLocation Location => new SourceLocation(_absoluteIndex, _currentLineIndex, _currentLineCharacterIndex); + + public char this[int index] + { + get + { + if (index < 0 || index >= _builder.Length) + { + throw new IndexOutOfRangeException(nameof(index)); + } + + return _builder[index]; + } + } + + // Internal for testing. + internal CodeWriter Indent(int size) + { + if (Length == 0 || this[Length - 1] == '\n') + { + _builder.Append(' ', size); + + _currentLineCharacterIndex += size; + _absoluteIndex += size; + } + + return this; + } + + public CodeWriter Write(string value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + return Write(value, 0, value.Length); + } + + public CodeWriter Write(string value, int startIndex, int count) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + if (startIndex < 0) + { + throw new ArgumentOutOfRangeException(nameof(startIndex)); + } + + if (count < 0) + { + throw new ArgumentOutOfRangeException(nameof(count)); + } + + if (startIndex > value.Length - count) + { + throw new ArgumentOutOfRangeException(nameof(startIndex)); + } + + if (count == 0) + { + return this; + } + + Indent(CurrentIndent); + + _builder.Append(value, startIndex, count); + + _absoluteIndex += count; + + // The data string might contain a partial newline where the previously + // written string has part of the newline. + var i = startIndex; + int? trailingPartStart = null; + + if ( + // Check the last character of the previous write operation. + _builder.Length - count - 1 >= 0 && + _builder[_builder.Length - count - 1] == '\r' && + + // Check the first character of the current write operation. + _builder[_builder.Length - count] == '\n') + { + // This is newline that's spread across two writes. Skip the first character of the + // current write operation. + // + // We don't need to increment our newline counter because we already did that when we + // saw the \r. + i += 1; + trailingPartStart = 1; + } + + // Iterate the string, stopping at each occurrence of a newline character. This lets us count the + // newline occurrences and keep the index of the last one. + while ((i = value.IndexOfAny(NewLineCharacters, i)) >= 0) + { + // Newline found. + _currentLineIndex++; + _currentLineCharacterIndex = 0; + + i++; + + // We might have stopped at a \r, so check if it's followed by \n and then advance the index to + // start the next search after it. + if (count > i && + value[i - 1] == '\r' && + value[i] == '\n') + { + i++; + } + + // The 'suffix' of the current line starts after this newline token. + trailingPartStart = i; + } + + if (trailingPartStart == null) + { + // No newlines, just add the length of the data buffer + _currentLineCharacterIndex += count; + } + else + { + // Newlines found, add the trailing part of 'data' + _currentLineCharacterIndex += (count - trailingPartStart.Value); + } + + return this; + } + + public CodeWriter WriteLine() + { + _builder.Append(NewLine); + + _currentLineIndex++; + _currentLineCharacterIndex = 0; + _absoluteIndex += NewLine.Length; + + return this; + } + + public CodeWriter WriteLine(string value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + return Write(value).WriteLine(); + } + + public string GenerateCode() + { + return _builder.ToString(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs new file mode 100644 index 0000000000..eee9f37927 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs @@ -0,0 +1,708 @@ +// 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.Diagnostics; +using System.Globalization; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal static class CodeWriterExtensions + { + private const string InstanceMethodFormat = "{0}.{1}"; + + private static readonly char[] CStyleStringLiteralEscapeChars = + { + '\r', + '\t', + '\"', + '\'', + '\\', + '\0', + '\n', + '\u2028', + '\u2029', + }; + + public static bool IsAtBeginningOfLine(this CodeWriter writer) + { + return writer.Length == 0 || writer[writer.Length - 1] == '\n'; + } + + public static CodeWriter WritePadding(this CodeWriter writer, int offset, SourceSpan? span, CodeRenderingContext context) + { + if (span == null) + { + return writer; + } + + if (context.SourceDocument.FilePath != null && + !string.Equals(context.SourceDocument.FilePath, span.Value.FilePath, StringComparison.OrdinalIgnoreCase)) + { + // We don't want to generate padding for nodes from imports. + return writer; + } + + var basePadding = CalculatePadding(); + var resolvedPadding = Math.Max(basePadding - offset, 0); + + if (context.Options.IndentWithTabs) + { + // Avoid writing directly to the StringBuilder here, that will throw off the manual indexing + // done by the base class. + var tabs = resolvedPadding / context.Options.IndentSize; + for (var i = 0; i < tabs; i++) + { + writer.Write("\t"); + } + + var spaces = resolvedPadding % context.Options.IndentSize; + for (var i = 0; i < spaces; i++) + { + writer.Write(" "); + } + } + else + { + for (var i = 0; i < resolvedPadding; i++) + { + writer.Write(" "); + } + } + + return writer; + + int CalculatePadding() + { + var spaceCount = 0; + for (var i = span.Value.AbsoluteIndex - 1; i >= 0; i--) + { + var @char = context.SourceDocument[i]; + if (@char == '\n' || @char == '\r') + { + break; + } + else if (@char == '\t') + { + spaceCount += context.Options.IndentSize; + } + else + { + spaceCount++; + } + } + + return spaceCount; + } + } + + public static CodeWriter WriteVariableDeclaration(this CodeWriter writer, string type, string name, string value) + { + writer.Write(type).Write(" ").Write(name); + if (!string.IsNullOrEmpty(value)) + { + writer.Write(" = ").Write(value); + } + else + { + writer.Write(" = null"); + } + + writer.WriteLine(";"); + + return writer; + } + + public static CodeWriter WriteBooleanLiteral(this CodeWriter writer, bool value) + { + return writer.Write(value.ToString().ToLowerInvariant()); + } + + public static CodeWriter WriteStartAssignment(this CodeWriter writer, string name) + { + return writer.Write(name).Write(" = "); + } + + public static CodeWriter WriteParameterSeparator(this CodeWriter writer) + { + return writer.Write(", "); + } + + public static CodeWriter WriteStartNewObject(this CodeWriter writer, string typeName) + { + return writer.Write("new ").Write(typeName).Write("("); + } + + public static CodeWriter WriteStringLiteral(this CodeWriter writer, string literal) + { + if (literal.Length >= 256 && literal.Length <= 1500 && literal.IndexOf('\0') == -1) + { + WriteVerbatimStringLiteral(writer, literal); + } + else + { + WriteCStyleStringLiteral(writer, literal); + } + + return writer; + } + + public static CodeWriter WriteUsing(this CodeWriter writer, string name) + { + return WriteUsing(writer, name, endLine: true); + } + + public static CodeWriter WriteUsing(this CodeWriter writer, string name, bool endLine) + { + writer.Write("using "); + writer.Write(name); + + if (endLine) + { + writer.WriteLine(";"); + } + + return writer; + } + + public static CodeWriter WriteLineNumberDirective(this CodeWriter writer, SourceSpan span) + { + if (writer.Length >= writer.NewLine.Length && !IsAtBeginningOfLine(writer)) + { + writer.WriteLine(); + } + + var lineNumberAsString = (span.LineIndex + 1).ToString(CultureInfo.InvariantCulture); + return writer.Write("#line ").Write(lineNumberAsString).Write(" \"").Write(span.FilePath).WriteLine("\""); + } + + public static CodeWriter WriteStartMethodInvocation(this CodeWriter writer, string methodName) + { + writer.Write(methodName); + + return writer.Write("("); + } + + public static CodeWriter WriteEndMethodInvocation(this CodeWriter writer) + { + return WriteEndMethodInvocation(writer, endLine: true); + } + + public static CodeWriter WriteEndMethodInvocation(this CodeWriter writer, bool endLine) + { + writer.Write(")"); + if (endLine) + { + writer.WriteLine(";"); + } + + return writer; + } + + // Writes a method invocation for the given instance name. + public static CodeWriter WriteInstanceMethodInvocation( + this CodeWriter writer, + string instanceName, + string methodName, + params string[] parameters) + { + if (instanceName == null) + { + throw new ArgumentNullException(nameof(instanceName)); + } + + if (methodName == null) + { + throw new ArgumentNullException(nameof(methodName)); + } + + return WriteInstanceMethodInvocation(writer, instanceName, methodName, endLine: true, parameters: parameters); + } + + // Writes a method invocation for the given instance name. + public static CodeWriter WriteInstanceMethodInvocation( + this CodeWriter writer, + string instanceName, + string methodName, + bool endLine, + params string[] parameters) + { + if (instanceName == null) + { + throw new ArgumentNullException(nameof(instanceName)); + } + + if (methodName == null) + { + throw new ArgumentNullException(nameof(methodName)); + } + + return WriteMethodInvocation( + writer, + string.Format(CultureInfo.InvariantCulture, InstanceMethodFormat, instanceName, methodName), + endLine, + parameters); + } + + public static CodeWriter WriteStartInstanceMethodInvocation(this CodeWriter writer, string instanceName, string methodName) + { + if (instanceName == null) + { + throw new ArgumentNullException(nameof(instanceName)); + } + + if (methodName == null) + { + throw new ArgumentNullException(nameof(methodName)); + } + + return WriteStartMethodInvocation( + writer, + string.Format(CultureInfo.InvariantCulture, InstanceMethodFormat, instanceName, methodName)); + } + + public static CodeWriter WriteField(this CodeWriter writer, IList suppressWarnings, IList modifiers, string typeName, string fieldName) + { + if (suppressWarnings == null) + { + throw new ArgumentNullException(nameof(suppressWarnings)); + } + + if (modifiers == null) + { + throw new ArgumentNullException(nameof(modifiers)); + } + + if (typeName == null) + { + throw new ArgumentNullException(nameof(typeName)); + } + + if (fieldName == null) + { + throw new ArgumentNullException(nameof(fieldName)); + } + + for (var i = 0; i < suppressWarnings.Count; i++) + { + writer.Write("#pragma warning disable "); + writer.WriteLine(suppressWarnings[i]); + } + + for (var i = 0; i < modifiers.Count; i++) + { + writer.Write(modifiers[i]); + writer.Write(" "); + } + + writer.Write(typeName); + writer.Write(" "); + writer.Write(fieldName); + writer.Write(";"); + writer.WriteLine(); + + for (var i = suppressWarnings.Count - 1; i >= 0; i--) + { + writer.Write("#pragma warning restore "); + writer.WriteLine(suppressWarnings[i]); + } + + return writer; + } + + public static CodeWriter WriteMethodInvocation(this CodeWriter writer, string methodName, params string[] parameters) + { + return WriteMethodInvocation(writer, methodName, endLine: true, parameters: parameters); + } + + public static CodeWriter WriteMethodInvocation(this CodeWriter writer, string methodName, bool endLine, params string[] parameters) + { + return + WriteStartMethodInvocation(writer, methodName) + .Write(string.Join(", ", parameters)) + .WriteEndMethodInvocation(endLine); + } + + public static CodeWriter WriteAutoPropertyDeclaration(this CodeWriter writer, IList modifiers, string typeName, string propertyName) + { + if (modifiers == null) + { + throw new ArgumentNullException(nameof(modifiers)); + } + + if (typeName == null) + { + throw new ArgumentNullException(nameof(typeName)); + } + + if (propertyName == null) + { + throw new ArgumentNullException(nameof(propertyName)); + } + + for (var i = 0; i < modifiers.Count; i++) + { + writer.Write(modifiers[i]); + writer.Write(" "); + } + + writer.Write(typeName); + writer.Write(" "); + writer.Write(propertyName); + writer.Write(" { get; set; }"); + writer.WriteLine(); + + return writer; + } + + public static CSharpCodeWritingScope BuildScope(this CodeWriter writer) + { + return new CSharpCodeWritingScope(writer); + } + + public static CSharpCodeWritingScope BuildLambda(this CodeWriter writer, params string[] parameterNames) + { + return BuildLambda(writer, async: false, parameterNames: parameterNames); + } + + public static CSharpCodeWritingScope BuildAsyncLambda(this CodeWriter writer, params string[] parameterNames) + { + return BuildLambda(writer, async: true, parameterNames: parameterNames); + } + + private static CSharpCodeWritingScope BuildLambda(CodeWriter writer, bool async, string[] parameterNames) + { + if (async) + { + writer.Write("async"); + } + + writer.Write("(").Write(string.Join(", ", parameterNames)).Write(") => "); + + var scope = new CSharpCodeWritingScope(writer); + + return scope; + } + + public static CSharpCodeWritingScope BuildNamespace(this CodeWriter writer, string name) + { + writer.Write("namespace ").WriteLine(name); + + return new CSharpCodeWritingScope(writer); + } + + public static CSharpCodeWritingScope BuildClassDeclaration( + this CodeWriter writer, + IList modifiers, + string name, + string baseType, + IList interfaces, + IList typeParameters) + { + for (var i = 0; i < modifiers.Count; i++) + { + writer.Write(modifiers[i]); + writer.Write(" "); + } + + writer.Write("class "); + writer.Write(name); + + if (typeParameters != null && typeParameters.Count > 0) + { + writer.Write("<"); + writer.Write(string.Join(", ", typeParameters)); + writer.Write(">"); + } + + var hasBaseType = !string.IsNullOrEmpty(baseType); + var hasInterfaces = interfaces != null && interfaces.Count > 0; + + if (hasBaseType || hasInterfaces) + { + writer.Write(" : "); + + if (hasBaseType) + { + writer.Write(baseType); + + if (hasInterfaces) + { + WriteParameterSeparator(writer); + } + } + + if (hasInterfaces) + { + writer.Write(string.Join(", ", interfaces)); + } + } + + writer.WriteLine(); + + return new CSharpCodeWritingScope(writer); + } + + public static CSharpCodeWritingScope BuildMethodDeclaration( + this CodeWriter writer, + string accessibility, + string returnType, + string name, + IEnumerable> parameters) + { + writer.Write(accessibility) + .Write(" ") + .Write(returnType) + .Write(" ") + .Write(name) + .Write("(") + .Write(string.Join(", ", parameters.Select(p => p.Key + " " + p.Value))) + .WriteLine(")"); + + return new CSharpCodeWritingScope(writer); + } + + public static IDisposable BuildLinePragma(this CodeWriter writer, SourceSpan? span, CodeRenderingContext context) + { + if (string.IsNullOrEmpty(span?.FilePath)) + { + // Can't build a valid line pragma without a file path. + return NullDisposable.Default; + } + + return new LinePragmaWriter(writer, span.Value, context); + } + + private static void WriteVerbatimStringLiteral(CodeWriter writer, string literal) + { + writer.Write("@\""); + + // We need to suppress indenting during the writing of the string's content. A + // verbatim string literal could contain newlines that don't get escaped. + var indent = writer.CurrentIndent; + writer.CurrentIndent = 0; + + // We need to find the index of each '"' (double-quote) to escape it. + var start = 0; + int end; + while ((end = literal.IndexOf('\"', start)) > -1) + { + writer.Write(literal, start, end - start); + + writer.Write("\"\""); + + start = end + 1; + } + + Debug.Assert(end == -1); // We've hit all of the double-quotes. + + // Write the remainder after the last double-quote. + writer.Write(literal, start, literal.Length - start); + + writer.Write("\""); + + writer.CurrentIndent = indent; + } + + private static void WriteCStyleStringLiteral(CodeWriter writer, string literal) + { + // From CSharpCodeGenerator.QuoteSnippetStringCStyle in CodeDOM + writer.Write("\""); + + // We need to find the index of each escapable character to escape it. + var start = 0; + int end; + while ((end = literal.IndexOfAny(CStyleStringLiteralEscapeChars, start)) > -1) + { + writer.Write(literal, start, end - start); + + switch (literal[end]) + { + case '\r': + writer.Write("\\r"); + break; + case '\t': + writer.Write("\\t"); + break; + case '\"': + writer.Write("\\\""); + break; + case '\'': + writer.Write("\\\'"); + break; + case '\\': + writer.Write("\\\\"); + break; + case '\0': + writer.Write("\\\0"); + break; + case '\n': + writer.Write("\\n"); + break; + case '\u2028': + case '\u2029': + writer.Write("\\u"); + writer.Write(((int)literal[end]).ToString("X4", CultureInfo.InvariantCulture)); + break; + default: + Debug.Assert(false, "Unknown escape character."); + break; + } + + start = end + 1; + } + + Debug.Assert(end == -1); // We've hit all of chars that need escaping. + + // Write the remainder after the last escaped char. + writer.Write(literal, start, literal.Length - start); + + writer.Write("\""); + } + + public struct CSharpCodeWritingScope : IDisposable + { + private CodeWriter _writer; + private bool _autoSpace; + private int _tabSize; + private int _startIndent; + + public CSharpCodeWritingScope(CodeWriter writer, int tabSize = 4, bool autoSpace = true) + { + _writer = writer; + _autoSpace = autoSpace; + _tabSize = tabSize; + _startIndent = -1; // Set in WriteStartScope + + WriteStartScope(); + } + + public void Dispose() + { + WriteEndScope(); + } + + private void WriteStartScope() + { + TryAutoSpace(" "); + + _writer.WriteLine("{"); + _writer.CurrentIndent += _tabSize; + _startIndent = _writer.CurrentIndent; + } + + private void WriteEndScope() + { + TryAutoSpace(_writer.NewLine); + + // Ensure the scope hasn't been modified + if (_writer.CurrentIndent == _startIndent) + { + _writer.CurrentIndent -= _tabSize; + } + + _writer.WriteLine("}"); + } + + private void TryAutoSpace(string spaceCharacter) + { + if (_autoSpace && + _writer.Length > 0 && + !char.IsWhiteSpace(_writer[_writer.Length - 1])) + { + _writer.Write(spaceCharacter); + } + } + } + + private class LinePragmaWriter : IDisposable + { + private readonly CodeWriter _writer; + private readonly CodeRenderingContext _context; + private readonly int _startIndent; + private readonly int _sourceLineIndex; + private readonly int _startLineIndex; + private readonly string _sourceFilePath; + + public LinePragmaWriter( + CodeWriter writer, + SourceSpan span, + CodeRenderingContext context) + { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + _writer = writer; + _context = context; + _startIndent = _writer.CurrentIndent; + _sourceFilePath = span.FilePath; + _sourceLineIndex = span.LineIndex; + _writer.CurrentIndent = 0; + + if (!_context.Options.SuppressNullabilityEnforcement) + { + var endsWithNewline = _writer.Length > 0 && _writer[_writer.Length - 1] == '\n'; + if (!endsWithNewline) + { + _writer.WriteLine(); + } + _writer.WriteLine("#nullable restore"); + } + + WriteLineNumberDirective(writer, span); + + // Capture the line index after writing the #line directive. + _startLineIndex = writer.Location.LineIndex; + } + + public void Dispose() + { + // Need to add an additional line at the end IF there wasn't one already written. + // This is needed to work with the C# editor's handling of #line ... + var endsWithNewline = _writer.Length > 0 && _writer[_writer.Length - 1] == '\n'; + + // Always write at least 1 empty line to potentially separate code from pragmas. + _writer.WriteLine(); + + // Check if the previous empty line wasn't enough to separate code from pragmas. + if (!endsWithNewline) + { + _writer.WriteLine(); + } + + var lineCount = _writer.Location.LineIndex - _startLineIndex; + var linePragma = new LinePragma(_sourceLineIndex, lineCount, _sourceFilePath); + _context.AddLinePragma(linePragma); + + _writer + .WriteLine("#line default") + .WriteLine("#line hidden"); + + if (!_context.Options.SuppressNullabilityEnforcement) + { + _writer.WriteLine("#nullable disable"); + } + + _writer.CurrentIndent = _startIndent; + + } + } + + private class NullDisposable : IDisposable + { + public static readonly NullDisposable Default = new NullDisposable(); + + private NullDisposable() + { + } + + public void Dispose() + { + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeRenderingContext.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeRenderingContext.cs new file mode 100644 index 0000000000..afb717391a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeRenderingContext.cs @@ -0,0 +1,220 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class DefaultCodeRenderingContext : CodeRenderingContext + { + private readonly Stack _ancestors; + private readonly RazorCodeDocument _codeDocument; + private readonly DocumentIntermediateNode _documentNode; + private readonly List _scopes; + + public DefaultCodeRenderingContext( + CodeWriter codeWriter, + IntermediateNodeWriter nodeWriter, + RazorCodeDocument codeDocument, + DocumentIntermediateNode documentNode, + RazorCodeGenerationOptions options) + { + if (codeWriter == null) + { + throw new ArgumentNullException(nameof(codeWriter)); + } + + if (nodeWriter == null) + { + throw new ArgumentNullException(nameof(nodeWriter)); + } + + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (documentNode == null) + { + throw new ArgumentNullException(nameof(documentNode)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + CodeWriter = codeWriter; + _codeDocument = codeDocument; + _documentNode = documentNode; + Options = options; + + _ancestors = new Stack(); + Diagnostics = new RazorDiagnosticCollection(); + Items = new ItemCollection(); + SourceMappings = new List(); + LinePragmas = new List(); + + var diagnostics = _documentNode.GetAllDiagnostics(); + for (var i = 0; i < diagnostics.Count; i++) + { + Diagnostics.Add(diagnostics[i]); + } + + var newLineString = codeDocument.Items[NewLineString]; + if (newLineString != null) + { + // Set new line character to a specific string regardless of platform, for testing purposes. + codeWriter.NewLine = (string)newLineString; + } + + Items[NewLineString] = codeDocument.Items[NewLineString]; + Items[SuppressUniqueIds] = codeDocument.Items[SuppressUniqueIds]; + + _scopes = new List(); + _scopes.Add(new ScopeInternal(nodeWriter)); + } + + // This will be initialized by the document writer when the context is 'live'. + public IntermediateNodeVisitor Visitor { get; set; } + + public override IEnumerable Ancestors => _ancestors; + + internal Stack AncestorsInternal => _ancestors; + + public override CodeWriter CodeWriter { get; } + + public override RazorDiagnosticCollection Diagnostics { get; } + + public override string DocumentKind { get; } + + public override ItemCollection Items { get; } + + public List SourceMappings { get; } + + internal List LinePragmas { get; } + + public override IntermediateNodeWriter NodeWriter => Current.Writer; + + public override RazorCodeGenerationOptions Options { get; } + + public override IntermediateNode Parent => _ancestors.Count == 0 ? null : _ancestors.Peek(); + + public override RazorSourceDocument SourceDocument => _codeDocument.Source; + + private ScopeInternal Current => _scopes[_scopes.Count - 1]; + + public override void AddSourceMappingFor(IntermediateNode node) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.Source == null) + { + return; + } + + if (SourceDocument.FilePath != null && + !string.Equals(SourceDocument.FilePath, node.Source.Value.FilePath, StringComparison.OrdinalIgnoreCase)) + { + // We don't want to generate line mappings for imports. + return; + } + + var source = node.Source.Value; + var generatedLocation = new SourceSpan(CodeWriter.Location, source.Length); + var sourceMapping = new SourceMapping(source, generatedLocation); + + SourceMappings.Add(sourceMapping); + } + + public override void RenderChildren(IntermediateNode node) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + _ancestors.Push(node); + + for (var i = 0; i < node.Children.Count; i++) + { + Visitor.Visit(node.Children[i]); + } + + _ancestors.Pop(); + } + + public override void RenderChildren(IntermediateNode node, IntermediateNodeWriter writer) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + _scopes.Add(new ScopeInternal(writer)); + _ancestors.Push(node); + + for (var i = 0; i < node.Children.Count; i++) + { + Visitor.Visit(node.Children[i]); + } + + _ancestors.Pop(); + _scopes.RemoveAt(_scopes.Count - 1); + } + + public override void RenderNode(IntermediateNode node) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + Visitor.Visit(node); + } + + public override void RenderNode(IntermediateNode node, IntermediateNodeWriter writer) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + _scopes.Add(new ScopeInternal(writer)); + + Visitor.Visit(node); + + _scopes.RemoveAt(_scopes.Count - 1); + } + + public override void AddLinePragma(LinePragma linePragma) + { + LinePragmas.Add(linePragma); + } + + private struct ScopeInternal + { + public ScopeInternal(IntermediateNodeWriter writer) + { + Writer = writer; + } + + public IntermediateNodeWriter Writer { get; } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeTarget.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeTarget.cs new file mode 100644 index 0000000000..e9ef7d1ee7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeTarget.cs @@ -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.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class DefaultCodeTarget : CodeTarget + { + private readonly RazorCodeGenerationOptions _options; + + public DefaultCodeTarget(RazorCodeGenerationOptions options, IEnumerable extensions) + { + _options = options; + Extensions = extensions.ToArray(); + } + + public ICodeTargetExtension[] Extensions { get; } + + public override IntermediateNodeWriter CreateNodeWriter() + { + return _options.DesignTime ? (IntermediateNodeWriter)new DesignTimeNodeWriter() : new RuntimeNodeWriter(); + } + + public override TExtension GetExtension() + { + for (var i = 0; i < Extensions.Length; i++) + { + var match = Extensions[i] as TExtension; + if (match != null) + { + return match; + } + } + + return null; + } + + public override bool HasExtension() + { + for (var i = 0; i < Extensions.Length; i++) + { + var match = Extensions[i] as TExtension; + if (match != null) + { + return true; + } + } + + return false; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeTargetBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeTargetBuilder.cs new file mode 100644 index 0000000000..8ae23bddf4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultCodeTargetBuilder.cs @@ -0,0 +1,30 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class DefaultCodeTargetBuilder : CodeTargetBuilder + { + public DefaultCodeTargetBuilder(RazorCodeDocument codeDocument, RazorCodeGenerationOptions options) + { + CodeDocument = codeDocument; + Options = options; + + TargetExtensions = new List(); + } + + public override RazorCodeDocument CodeDocument { get; } + + public override RazorCodeGenerationOptions Options { get; } + + public override ICollection TargetExtensions { get; } + + public override CodeTarget Build() + { + return new DefaultCodeTarget(Options, TargetExtensions); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs new file mode 100644 index 0000000000..c5fb4de90e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs @@ -0,0 +1,318 @@ +// 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.Linq; +using System.Security.Cryptography; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class DefaultDocumentWriter : DocumentWriter + { + private readonly CodeTarget _codeTarget; + private readonly RazorCodeGenerationOptions _options; + + public DefaultDocumentWriter(CodeTarget codeTarget, RazorCodeGenerationOptions options) + { + _codeTarget = codeTarget; + _options = options; + } + + public override RazorCSharpDocument WriteDocument(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (documentNode == null) + { + throw new ArgumentNullException(nameof(documentNode)); + } + + var context = new DefaultCodeRenderingContext( + new CodeWriter(), + _codeTarget.CreateNodeWriter(), + codeDocument, + documentNode, + _options); + context.Visitor = new Visitor(_codeTarget, context); + + context.Visitor.VisitDocument(documentNode); + + var cSharp = context.CodeWriter.GenerateCode(); + + var allOrderedDiagnostics = context.Diagnostics.OrderBy(diagnostic => diagnostic.Span.AbsoluteIndex); + return new DefaultRazorCSharpDocument( + cSharp, + _options, + allOrderedDiagnostics.ToArray(), + context.SourceMappings.ToArray(), + context.LinePragmas.ToArray()); + } + + private class Visitor : IntermediateNodeVisitor + { + private readonly DefaultCodeRenderingContext _context; + private readonly CodeTarget _target; + + public Visitor(CodeTarget target, DefaultCodeRenderingContext context) + { + _target = target; + _context = context; + } + + private DefaultCodeRenderingContext Context => _context; + + public override void VisitDocument(DocumentIntermediateNode node) + { + if (!Context.Options.SuppressChecksum) + { + // See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx + // And https://github.com/dotnet/roslyn/blob/614299ff83da9959fa07131c6d0ffbc58873b6ae/src/Compilers/Core/Portable/PEWriter/DebugSourceDocument.cs#L67 + // + // We only support algorithms that the debugger understands, which is currently SHA1 and SHA256. + + string algorithmId; + var algorithm = Context.SourceDocument.GetChecksumAlgorithm(); + if (string.Equals(algorithm, HashAlgorithmName.SHA256.Name, StringComparison.Ordinal)) + { + algorithmId = "{8829d00f-11b8-4213-878b-770e8597ac16}"; + } + else if (string.Equals(algorithm, HashAlgorithmName.SHA1.Name, StringComparison.Ordinal) || + + // In 2.0, we didn't actually expose the name of the algorithm, so it's possible we could get null here. + // If that's the case, we just assume SHA1 since that's the only thing we supported in 2.0. + algorithm == null) + { + algorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; + } + else + { + var supportedAlgorithms = string.Join(" ", new string[] + { + HashAlgorithmName.SHA1.Name, + HashAlgorithmName.SHA256.Name + }); + + var message = Resources.FormatUnsupportedChecksumAlgorithm( + algorithm, + supportedAlgorithms, + nameof(RazorCodeGenerationOptions) + "." + nameof(RazorCodeGenerationOptions.SuppressChecksum), + bool.TrueString); + throw new InvalidOperationException(message); + } + + var sourceDocument = Context.SourceDocument; + + var checksum = Checksum.BytesToString(sourceDocument.GetChecksum()); + if (!string.IsNullOrEmpty(checksum)) + { + Context.CodeWriter + .Write("#pragma checksum \"") + .Write(sourceDocument.FilePath) + .Write("\" \"") + .Write(algorithmId) + .Write("\" \"") + .Write(checksum) + .WriteLine("\""); + } + } + + Context.CodeWriter + .WriteLine("// ") + .WriteLine("#pragma warning disable 1591"); + + VisitDefault(node); + + Context.CodeWriter.WriteLine("#pragma warning restore 1591"); + } + + public override void VisitUsingDirective(UsingDirectiveIntermediateNode node) + { + Context.NodeWriter.WriteUsingDirective(Context, node); + } + + public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node) + { + using (Context.CodeWriter.BuildNamespace(node.Content)) + { + Context.CodeWriter.WriteLine("#line hidden"); + VisitDefault(node); + } + } + + public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node) + { + using (Context.CodeWriter.BuildClassDeclaration( + node.Modifiers, + node.ClassName, + node.BaseType, + node.Interfaces, + node.TypeParameters.Select(p => p.ParameterName).ToArray())) + { + VisitDefault(node); + } + } + + public override void VisitMethodDeclaration(MethodDeclarationIntermediateNode node) + { + Context.CodeWriter.WriteLine("#pragma warning disable 1998"); + + for (var i = 0; i < node.Modifiers.Count; i++) + { + Context.CodeWriter.Write(node.Modifiers[i]); + Context.CodeWriter.Write(" "); + } + + Context.CodeWriter.Write(node.ReturnType); + Context.CodeWriter.Write(" "); + + Context.CodeWriter.Write(node.MethodName); + Context.CodeWriter.Write("("); + + for (var i = 0; i < node.Parameters.Count; i++) + { + var parameter = node.Parameters[i]; + + for (var j = 0; j < parameter.Modifiers.Count; j++) + { + Context.CodeWriter.Write(parameter.Modifiers[j]); + Context.CodeWriter.Write(" "); + } + + Context.CodeWriter.Write(parameter.TypeName); + Context.CodeWriter.Write(" "); + + Context.CodeWriter.Write(parameter.ParameterName); + + if (i < node.Parameters.Count - 1) + { + Context.CodeWriter.Write(", "); + } + } + + Context.CodeWriter.Write(")"); + Context.CodeWriter.WriteLine(); + + using (Context.CodeWriter.BuildScope()) + { + VisitDefault(node); + } + + Context.CodeWriter.WriteLine("#pragma warning restore 1998"); + } + + public override void VisitFieldDeclaration(FieldDeclarationIntermediateNode node) + { + Context.CodeWriter.WriteField(node.SuppressWarnings, node.Modifiers, node.FieldType, node.FieldName); + } + + public override void VisitPropertyDeclaration(PropertyDeclarationIntermediateNode node) + { + Context.CodeWriter.WriteAutoPropertyDeclaration(node.Modifiers, node.PropertyType, node.PropertyName); + } + + public override void VisitExtension(ExtensionIntermediateNode node) + { + node.WriteNode(_target, Context); + } + + public override void VisitCSharpExpression(CSharpExpressionIntermediateNode node) + { + Context.NodeWriter.WriteCSharpExpression(Context, node); + } + + public override void VisitCSharpCode(CSharpCodeIntermediateNode node) + { + Context.NodeWriter.WriteCSharpCode(Context, node); + } + + public override void VisitHtmlAttribute(HtmlAttributeIntermediateNode node) + { + Context.NodeWriter.WriteHtmlAttribute(Context, node); + } + + public override void VisitHtmlAttributeValue(HtmlAttributeValueIntermediateNode node) + { + Context.NodeWriter.WriteHtmlAttributeValue(Context, node); + } + + public override void VisitCSharpExpressionAttributeValue(CSharpExpressionAttributeValueIntermediateNode node) + { + Context.NodeWriter.WriteCSharpExpressionAttributeValue(Context, node); + } + + public override void VisitCSharpCodeAttributeValue(CSharpCodeAttributeValueIntermediateNode node) + { + Context.NodeWriter.WriteCSharpCodeAttributeValue(Context, node); + } + + public override void VisitHtml(HtmlContentIntermediateNode node) + { + Context.NodeWriter.WriteHtmlContent(Context, node); + } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + VisitDefault(node); + } + + public override void VisitComponent(ComponentIntermediateNode node) + { + Context.NodeWriter.WriteComponent(Context, node); + } + + public override void VisitComponentAttribute(ComponentAttributeIntermediateNode node) + { + Context.NodeWriter.WriteComponentAttribute(Context, node); + } + + public override void VisitComponentChildContent(ComponentChildContentIntermediateNode node) + { + Context.NodeWriter.WriteComponentChildContent(Context, node); + } + + public override void VisitComponentTypeArgument(ComponentTypeArgumentIntermediateNode node) + { + Context.NodeWriter.WriteComponentTypeArgument(Context, node); + } + + public override void VisitComponentTypeInferenceMethod(ComponentTypeInferenceMethodIntermediateNode node) + { + Context.NodeWriter.WriteComponentTypeInferenceMethod(Context, node); + } + + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + Context.NodeWriter.WriteMarkupElement(Context, node); + } + + public override void VisitMarkupBlock(MarkupBlockIntermediateNode node) + { + Context.NodeWriter.WriteMarkupBlock(Context, node); + } + + public override void VisitReferenceCapture(ReferenceCaptureIntermediateNode node) + { + Context.NodeWriter.WriteReferenceCapture(Context, node); + } + + public override void VisitSetKey(SetKeyIntermediateNode node) + { + Context.NodeWriter.WriteSetKey(Context, node); + } + + public override void VisitSplat(SplatIntermediateNode node) + { + Context.NodeWriter.WriteSplat(Context, node); + } + + public override void VisitDefault(IntermediateNode node) + { + Context.RenderChildren(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DesignTimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DesignTimeNodeWriter.cs new file mode 100644 index 0000000000..9bf56e2eec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DesignTimeNodeWriter.cs @@ -0,0 +1,259 @@ +// 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.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public class DesignTimeNodeWriter : IntermediateNodeWriter + { + public override void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node) + { + if (node.Source.HasValue) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + context.AddSourceMappingFor(node); + context.CodeWriter.WriteUsing(node.Content); + } + } + else + { + context.CodeWriter.WriteUsing(node.Content); + } + } + + public override void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.Children.Count == 0) + { + return; + } + + if (node.Source != null) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + var offset = DesignTimeDirectivePass.DesignTimeVariable.Length + " = ".Length; + context.CodeWriter.WritePadding(offset, node.Source, context); + context.CodeWriter.WriteStartAssignment(DesignTimeDirectivePass.DesignTimeVariable); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + + context.CodeWriter.WriteLine(";"); + } + } + else + { + context.CodeWriter.WriteStartAssignment(DesignTimeDirectivePass.DesignTimeVariable); + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + context.CodeWriter.WriteLine(";"); + } + } + + public override void WriteCSharpCode(CodeRenderingContext context, CSharpCodeIntermediateNode node) + { + IDisposable linePragmaScope = null; + if (node.Source != null) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value, context); + + context.CodeWriter.WritePadding(0, node.Source.Value, context); + } + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the statement like an extension node. + context.RenderNode(node.Children[i]); + } + } + + if (linePragmaScope != null) + { + linePragmaScope.Dispose(); + } + else + { + context.CodeWriter.WriteLine(); + } + } + + public override void WriteHtmlAttribute(CodeRenderingContext context, HtmlAttributeIntermediateNode node) + { + context.RenderChildren(node); + } + + public override void WriteHtmlAttributeValue(CodeRenderingContext context, HtmlAttributeValueIntermediateNode node) + { + context.RenderChildren(node); + } + + public override void WriteCSharpExpressionAttributeValue(CodeRenderingContext context, CSharpExpressionAttributeValueIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.Children.Count == 0) + { + return; + } + + var firstChild = node.Children[0]; + if (firstChild.Source != null) + { + using (context.CodeWriter.BuildLinePragma(firstChild.Source.Value, context)) + { + var offset = DesignTimeDirectivePass.DesignTimeVariable.Length + " = ".Length; + context.CodeWriter.WritePadding(offset, firstChild.Source, context); + context.CodeWriter.WriteStartAssignment(DesignTimeDirectivePass.DesignTimeVariable); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + + context.CodeWriter.WriteLine(";"); + } + } + else + { + context.CodeWriter.WriteStartAssignment(DesignTimeDirectivePass.DesignTimeVariable); + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + if (token.Source != null) + { + context.AddSourceMappingFor(token); + } + + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + context.CodeWriter.WriteLine(";"); + } + } + + public override void WriteCSharpCodeAttributeValue(CodeRenderingContext context, CSharpCodeAttributeValueIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + IDisposable linePragmaScope = null; + var isWhitespaceStatement = string.IsNullOrWhiteSpace(token.Content); + + if (token.Source != null) + { + if (!isWhitespaceStatement) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(token.Source.Value, context); + } + + context.CodeWriter.WritePadding(0, token.Source.Value, context); + } + else if (isWhitespaceStatement) + { + // Don't write whitespace if there is no line mapping for it. + continue; + } + + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + + if (linePragmaScope != null) + { + linePragmaScope.Dispose(); + } + else + { + context.CodeWriter.WriteLine(); + } + } + else + { + // There may be something else inside the statement like an extension node. + context.RenderNode(node.Children[i]); + } + } + } + + public override void WriteHtmlContent(CodeRenderingContext context, HtmlContentIntermediateNode node) + { + // Do nothing + } + + public override void BeginWriterScope(CodeRenderingContext context, string writer) + { + // Do nothing + } + + public override void EndWriterScope(CodeRenderingContext context) + { + // Do nothing + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DocumentWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DocumentWriter.cs new file mode 100644 index 0000000000..abe058078b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DocumentWriter.cs @@ -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 System.ComponentModel; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public abstract class DocumentWriter + { + public static DocumentWriter CreateDefault(CodeTarget codeTarget, RazorCodeGenerationOptions options) + { + if (codeTarget == null) + { + throw new ArgumentNullException(nameof(codeTarget)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return new DefaultDocumentWriter(codeTarget, options); + } + + public abstract RazorCSharpDocument WriteDocument(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/ICodeTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/ICodeTargetExtension.cs new file mode 100644 index 0000000000..c8414f1335 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/ICodeTargetExtension.cs @@ -0,0 +1,9 @@ +// 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.Razor.Language.CodeGeneration +{ + public interface ICodeTargetExtension + { + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/IntermediateNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/IntermediateNodeWriter.cs new file mode 100644 index 0000000000..5d6d116fc6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/IntermediateNodeWriter.cs @@ -0,0 +1,81 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public abstract class IntermediateNodeWriter + { + public abstract void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node); + + public abstract void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node); + + public abstract void WriteCSharpCode(CodeRenderingContext context, CSharpCodeIntermediateNode node); + + public abstract void WriteHtmlContent(CodeRenderingContext context, HtmlContentIntermediateNode node); + + public abstract void WriteHtmlAttribute(CodeRenderingContext context, HtmlAttributeIntermediateNode node); + + public abstract void WriteHtmlAttributeValue(CodeRenderingContext context, HtmlAttributeValueIntermediateNode node); + + public abstract void WriteCSharpExpressionAttributeValue(CodeRenderingContext context, CSharpExpressionAttributeValueIntermediateNode node); + + public abstract void WriteCSharpCodeAttributeValue(CodeRenderingContext context, CSharpCodeAttributeValueIntermediateNode node); + + public virtual void WriteComponent(CodeRenderingContext context, ComponentIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteComponentChildContent(CodeRenderingContext context, ComponentChildContentIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteComponentTypeInferenceMethod(CodeRenderingContext context, ComponentTypeInferenceMethodIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteMarkupElement(CodeRenderingContext context, MarkupElementIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteMarkupBlock(CodeRenderingContext context, MarkupBlockIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteSetKey(CodeRenderingContext context, SetKeyIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public virtual void WriteSplat(CodeRenderingContext context, SplatIntermediateNode node) + { + throw new NotSupportedException("This writer does not support components."); + } + + public abstract void BeginWriterScope(CodeRenderingContext context, string writer); + + public abstract void EndWriterScope(CodeRenderingContext context); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/LinePragma.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/LinePragma.cs new file mode 100644 index 0000000000..70ce098758 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/LinePragma.cs @@ -0,0 +1,63 @@ +// 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 Microsoft.Extensions.Internal; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public readonly struct LinePragma : IEquatable + { + public LinePragma(int startLineIndex, int lineCount, string filePath) + { + if (startLineIndex < 0) + { + throw new ArgumentOutOfRangeException(nameof(startLineIndex)); + } + + if (lineCount < 0) + { + throw new ArgumentOutOfRangeException(nameof(lineCount)); + } + + StartLineIndex = startLineIndex; + LineCount = lineCount; + FilePath = filePath; + } + + public int StartLineIndex { get; } + + public int EndLineIndex => StartLineIndex + LineCount; + + public int LineCount { get; } + + public string FilePath { get; } + + public override bool Equals(object obj) + { + return obj is LinePragma other ? Equals(other) : false; + } + + public bool Equals(LinePragma other) + { + return StartLineIndex == other.StartLineIndex && + LineCount == other.LineCount && + string.Equals(FilePath, other.FilePath, StringComparison.Ordinal); + } + + public override int GetHashCode() + { + var hash = HashCodeCombiner.Start(); + hash.Add(StartLineIndex); + hash.Add(LineCount); + hash.Add(FilePath); + return hash; + } + + public override string ToString() + { + return string.Format(CultureInfo.CurrentCulture, "Line index {0}, Count {1} - {2}", StartLineIndex, LineCount, FilePath); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/LiteralRuntimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/LiteralRuntimeNodeWriter.cs new file mode 100644 index 0000000000..21d542f663 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/LiteralRuntimeNodeWriter.cs @@ -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.Razor.Language.CodeGeneration +{ + internal class LiteralRuntimeNodeWriter : RuntimeNodeWriter + { + public override string WriteCSharpExpressionMethod { get; set; } = "WriteLiteral"; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/RuntimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/RuntimeNodeWriter.cs new file mode 100644 index 0000000000..9d4561e84d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/RuntimeNodeWriter.cs @@ -0,0 +1,391 @@ +// 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.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public class RuntimeNodeWriter : IntermediateNodeWriter + { + public virtual string WriteCSharpExpressionMethod { get; set; } = "Write"; + + public virtual string WriteHtmlContentMethod { get; set; } = "WriteLiteral"; + + public virtual string BeginWriteAttributeMethod { get; set; } = "BeginWriteAttribute"; + + public virtual string EndWriteAttributeMethod { get; set; } = "EndWriteAttribute"; + + public virtual string WriteAttributeValueMethod { get; set; } = "WriteAttributeValue"; + + public virtual string PushWriterMethod { get; set; } = "PushWriter"; + + public virtual string PopWriterMethod { get; set; } = "PopWriter"; + + public string TemplateTypeName { get; set; } = "Microsoft.AspNetCore.Mvc.Razor.HelperResult"; + + public override void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node) + { + if (node.Source.HasValue) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + context.CodeWriter.WriteUsing(node.Content); + } + } + else + { + context.CodeWriter.WriteUsing(node.Content); + } + } + + public override void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + IDisposable linePragmaScope = null; + if (node.Source != null) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value, context); + context.CodeWriter.WritePadding(WriteCSharpExpressionMethod.Length + 1, node.Source, context); + } + + context.CodeWriter.WriteStartMethodInvocation(WriteCSharpExpressionMethod); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + + context.CodeWriter.WriteEndMethodInvocation(); + + linePragmaScope?.Dispose(); + } + + public override void WriteCSharpCode(CodeRenderingContext context, CSharpCodeIntermediateNode node) + { + var isWhitespaceStatement = true; + for (var i = 0; i < node.Children.Count; i++) + { + var token = node.Children[i] as IntermediateToken; + if (token == null || !string.IsNullOrWhiteSpace(token.Content)) + { + isWhitespaceStatement = false; + break; + } + } + + if (isWhitespaceStatement) + { + return; + } + + IDisposable linePragmaScope = null; + if (node.Source != null) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value, context); + context.CodeWriter.WritePadding(0, node.Source.Value, context); + } + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the statement like an extension node. + context.RenderNode(node.Children[i]); + } + } + + if (linePragmaScope == null) + { + context.CodeWriter.WriteLine(); + } + + linePragmaScope?.Dispose(); + } + + public override void WriteHtmlAttribute(CodeRenderingContext context, HtmlAttributeIntermediateNode node) + { + var valuePieceCount = node + .Children + .Count(child => + child is HtmlAttributeValueIntermediateNode || + child is CSharpExpressionAttributeValueIntermediateNode || + child is CSharpCodeAttributeValueIntermediateNode || + child is ExtensionIntermediateNode); + + var prefixLocation = node.Source.Value.AbsoluteIndex; + var suffixLocation = node.Source.Value.AbsoluteIndex + node.Source.Value.Length - node.Suffix.Length; + context.CodeWriter + .WriteStartMethodInvocation(BeginWriteAttributeMethod) + .WriteStringLiteral(node.AttributeName) + .WriteParameterSeparator() + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteStringLiteral(node.Suffix) + .WriteParameterSeparator() + .Write(suffixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valuePieceCount.ToString(CultureInfo.InvariantCulture)) + .WriteEndMethodInvocation(); + + context.RenderChildren(node); + + context.CodeWriter + .WriteStartMethodInvocation(EndWriteAttributeMethod) + .WriteEndMethodInvocation(); + } + + public override void WriteHtmlAttributeValue(CodeRenderingContext context, HtmlAttributeValueIntermediateNode node) + { + var prefixLocation = node.Source.Value.AbsoluteIndex; + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length; + context.CodeWriter + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator(); + + // Write content + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsHtml) + { + context.CodeWriter.WriteStringLiteral(token.Content); + } + else + { + // There may be something else inside the attribute value like an extension node. + context.RenderNode(node.Children[i]); + } + } + + context.CodeWriter + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(true) + .WriteEndMethodInvocation(); + } + + public override void WriteCSharpExpressionAttributeValue(CodeRenderingContext context, CSharpExpressionAttributeValueIntermediateNode node) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + var prefixLocation = node.Source.Value.AbsoluteIndex; + context.CodeWriter + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator(); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like an extension node. + context.RenderNode(node.Children[i]); + } + } + + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length - node.Prefix.Length; + context.CodeWriter + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(false) + .WriteEndMethodInvocation(); + } + } + + public override void WriteCSharpCodeAttributeValue(CodeRenderingContext context, CSharpCodeAttributeValueIntermediateNode node) + { + const string ValueWriterName = "__razor_attribute_value_writer"; + + var prefixLocation = node.Source.Value.AbsoluteIndex; + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length - node.Prefix.Length; + context.CodeWriter + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator(); + + context.CodeWriter.WriteStartNewObject(TemplateTypeName); + + using (context.CodeWriter.BuildAsyncLambda(ValueWriterName)) + { + BeginWriterScope(context, ValueWriterName); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + var isWhitespaceStatement = string.IsNullOrWhiteSpace(token.Content); + IDisposable linePragmaScope = null; + if (token.Source != null) + { + if (!isWhitespaceStatement) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(token.Source.Value, context); + } + + context.CodeWriter.WritePadding(0, token.Source.Value, context); + } + else if (isWhitespaceStatement) + { + // Don't write whitespace if there is no line mapping for it. + continue; + } + + context.CodeWriter.Write(token.Content); + + if (linePragmaScope != null) + { + linePragmaScope.Dispose(); + } + else + { + context.CodeWriter.WriteLine(); + } + } + else + { + // There may be something else inside the statement like an extension node. + context.RenderNode(node.Children[i]); + } + } + + EndWriterScope(context); + } + + context.CodeWriter.WriteEndMethodInvocation(false); + + context.CodeWriter + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(false) + .WriteEndMethodInvocation(); + } + + public override void WriteHtmlContent(CodeRenderingContext context, HtmlContentIntermediateNode node) + { + const int MaxStringLiteralLength = 1024; + + var builder = new StringBuilder(); + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsHtml) + { + builder.Append(token.Content); + } + } + + var content = builder.ToString(); + + WriteHtmlLiteral(context, MaxStringLiteralLength, content); + } + + // Internal for testing + internal void WriteHtmlLiteral(CodeRenderingContext context, int maxStringLiteralLength, string literal) + { + if (literal.Length <= maxStringLiteralLength) + { + WriteLiteral(literal); + return; + } + + // String is too large, render the string in pieces to avoid Roslyn OOM exceptions at compile time: https://github.com/aspnet/External/issues/54 + var charactersConsumed = 0; + do + { + var charactersRemaining = literal.Length - charactersConsumed; + var charactersToSubstring = Math.Min(maxStringLiteralLength, charactersRemaining); + var lastCharBeforeSplitIndex = charactersConsumed + charactersToSubstring - 1; + var lastCharBeforeSplit = literal[lastCharBeforeSplitIndex]; + + if (char.IsHighSurrogate(lastCharBeforeSplit)) + { + if (charactersRemaining > 1) + { + // Take one less character this iteration. We're attempting to split inbetween a surrogate pair. + // This can happen when something like an emoji sits on the barrier between splits; if we were to + // split the emoji we'd end up with invalid bytes in our output. + charactersToSubstring--; + } + else + { + // The user has an invalid file with a partial surrogate a the splitting point. + // We'll let the invalid character flow but we'll explode later on. + } + } + + var textToRender = literal.Substring(charactersConsumed, charactersToSubstring); + + WriteLiteral(textToRender); + + charactersConsumed += textToRender.Length; + } while (charactersConsumed < literal.Length); + + void WriteLiteral(string content) + { + context.CodeWriter + .WriteStartMethodInvocation(WriteHtmlContentMethod) + .WriteStringLiteral(content) + .WriteEndMethodInvocation(); + } + } + + public override void BeginWriterScope(CodeRenderingContext context, string writer) + { + context.CodeWriter.WriteMethodInvocation(PushWriterMethod, writer); + } + + public override void EndWriterScope(CodeRenderingContext context) + { + context.CodeWriter.WriteMethodInvocation(PopWriterMethod); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/TagHelperHtmlAttributeRuntimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/TagHelperHtmlAttributeRuntimeNodeWriter.cs new file mode 100644 index 0000000000..eec5a76575 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/TagHelperHtmlAttributeRuntimeNodeWriter.cs @@ -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.Razor.Language.CodeGeneration +{ + internal class TagHelperHtmlAttributeRuntimeNodeWriter : RuntimeNodeWriter + { + public override string WriteAttributeValueMethod { get; set; } = "AddHtmlAttributeValue"; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/TagHelperRenderingContext.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/TagHelperRenderingContext.cs new file mode 100644 index 0000000000..a8cbe5c96c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/TagHelperRenderingContext.cs @@ -0,0 +1,40 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class TagHelperRenderingContext + { + private Dictionary _renderedBoundAttributes; + private HashSet _verifiedPropertyDictionaries; + + public Dictionary RenderedBoundAttributes + { + get + { + if (_renderedBoundAttributes == null) + { + _renderedBoundAttributes = new Dictionary(StringComparer.OrdinalIgnoreCase); + } + + return _renderedBoundAttributes; + } + } + + public HashSet VerifiedPropertyDictionaries + { + get + { + if (_verifiedPropertyDictionaries == null) + { + _verifiedPropertyDictionaries = new HashSet(StringComparer.Ordinal); + } + + return _verifiedPropertyDictionaries; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx new file mode 100644 index 0000000000..b457a1f9f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The C# attribute that will be applied to the current class. + + + Attribute + + + Specifies the C# attribute that will be applied to the current class. + + + Binds the provided expression to the '{0}' property and a change event delegate to the '{1}' property of the component. + + + Specifies the culture to use for conversions. + + + Binds the provided expression to the '{0}' attribute and a change event delegate to the '{1}' attribute. + + + Specifies the event handler name to attach for change notifications for the value provided by the '{0}' attribute. + + + Specifies a format to convert the value specified by the '{0}' attribute. The format string can currently only be used with expressions of type <code>DateTime</code>. + + + Binds the provided expression to an attribute and a change event, based on the naming of the bind attribute. For example: <code>@bind-value="..."</code> and <code>@bind-value:event="onchange"</code> will assign the current value of the expression to the 'value' attribute, and assign a delegate that attempts to set the value to the 'onchange' attribute. + + + Specifies the event handler name to attach for change notifications for the value provided by the '{0}' attribute. + + + Specifies a format to convert the value specified by the corresponding bind attribute. For example: <code>@bind-value:format="..."</code> will apply a format string to the value specified in <code>@bind-value="..."</code>. The format string can currently only be used with expressions of type <code>DateTime</code>. + + + Specifies the parameter name for the '{0}' child content expression. + + + Specifies the parameter name for all child content expressions. + + + Specifies the type of the type parameter {0} for the {1} component. + + + Sets the '{0}' attribute to the provided string or delegate value. A delegate value should be of type '{1}'. + + + Specifies whether to cancel (if cancelable) the default action that belongs to the '{0}' event. + + + Specifies whether to prevent further propagation of the '{0}' event in the capturing and bubbling phases. + + + Declares an interface implementation for the current class. + + + The interface type implemented by the current class. + + + TypeName + + + Ensures that the component or element will be preserved across renders if (and only if) the supplied key value matches. + + + Declares a layout type for the current document. + + + The interface type implemented by the current document. + + + TypeName + + + The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor file + + + Mark the page as a routable component. + + + An optional route template for the component. + + + route template + + + Populates the specified field or property with a reference to the element or component. + + + Merges a collection of attributes into the current element or component. + + + Declares a generic type parameter for the generated component class. + + + The name of the type parameter. + + + type parameter + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs new file mode 100644 index 0000000000..8d3166a88e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -0,0 +1,840 @@ +// 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.Globalization; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentBindLoweringPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Run after event handler pass + public override int Order => 100; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + 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; + } + + // For each @bind *usage* we need to rewrite the tag helper node to map to basic constructs. + var references = documentNode.FindDescendantReferences(); + var parameterReferences = documentNode.FindDescendantReferences(); + + var parents = new HashSet(); + for (var i = 0; i < references.Count; i++) + { + parents.Add(references[i].Parent); + } + for (var i = 0; i < parameterReferences.Count; i++) + { + parents.Add(parameterReferences[i].Parent); + } + + foreach (var parent in parents) + { + ProcessDuplicates(parent); + } + + // First, collect all the non-parameterized @bind or @bind-* attributes. + // The dict key is a tuple of (parent, attributeName) to differentiate attributes with the same name in two different elements. + // We don't have to worry about duplicate bound attributes in the same element + // like, , because IR lowering takes care of that. + var bindEntries = new Dictionary<(IntermediateNode, string), BindEntry>(); + for (var i = 0; i < references.Count; i++) + { + var reference = references[i]; + var parent = reference.Parent; + var node = (TagHelperDirectiveAttributeIntermediateNode)reference.Node; + + if (!parent.Children.Contains(node)) + { + // This node was removed as a duplicate, skip it. + continue; + } + + if (node.TagHelper.IsBindTagHelper()) + { + bindEntries[(parent, node.AttributeName)] = new BindEntry(reference); + } + } + + // Now collect all the parameterized attributes and store them along with their corresponding @bind or @bind-* attributes. + for (var i = 0; i < parameterReferences.Count; i++) + { + var parameterReference = parameterReferences[i]; + var parent = parameterReference.Parent; + var node = (TagHelperDirectiveAttributeParameterIntermediateNode)parameterReference.Node; + + if (!parent.Children.Contains(node)) + { + // This node was removed as a duplicate, skip it. + continue; + } + + if (node.TagHelper.IsBindTagHelper()) + { + // Check if this tag contains a corresponding non-parameterized bind node. + if (!bindEntries.TryGetValue((parent, node.AttributeNameWithoutParameter), out var entry)) + { + // There is no corresponding bind node. Add a diagnostic and move on. + parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_MissingBind( + node.Source, + node.AttributeName)); + } + else if (node.BoundAttributeParameter.Name == "event") + { + entry.BindEventNode = node; + } + else if (node.BoundAttributeParameter.Name == "format") + { + entry.BindFormatNode = node; + } + else if (node.BoundAttributeParameter.Name == "culture") + { + entry.BindCultureNode = node; + } + else + { + // Unsupported bind attribute parameter. This can only happen if bound attribute descriptor + // is configured to expect a parameter other than 'event' and 'format'. + } + + // We've extracted what we need from the parameterized bind node. Remove it. + parameterReference.Remove(); + } + } + + // We now have all the info we need to rewrite the tag helper. + foreach (var entry in bindEntries) + { + var reference = entry.Value.BindNodeReference; + var rewritten = RewriteUsage(reference.Parent, entry.Value); + reference.Remove(); + + for (var j = 0; j < rewritten.Length; j++) + { + reference.Parent.Children.Add(rewritten[j]); + } + } + } + + private void ProcessDuplicates(IntermediateNode node) + { + // Reverse order because we will remove nodes. + // + // Each 'property' node could be duplicated if there are multiple tag helpers that match that + // particular attribute. This is common in our approach, which relies on 'fallback' tag helpers + // that overlap with more specific ones. + for (var i = node.Children.Count - 1; i >= 0; i--) + { + // For each usage of the general 'fallback' bind tag helper, it could duplicate + // the usage of a more specific one. Look for duplicates and remove the fallback. + TagHelperDescriptor tagHelper = null; + string attributeName = null; + var attribute = node.Children[i]; + if (attribute is TagHelperDirectiveAttributeIntermediateNode directiveAttribute) + { + attributeName = directiveAttribute.AttributeName; + tagHelper = directiveAttribute.TagHelper; + } + else if (attribute is TagHelperDirectiveAttributeParameterIntermediateNode parameterAttribute) + { + attributeName = parameterAttribute.AttributeName; + tagHelper = parameterAttribute.TagHelper; + } + if (attribute != null && + tagHelper != null && + tagHelper.IsFallbackBindTagHelper()) + { + for (var j = 0; j < node.Children.Count; j++) + { + TagHelperDescriptor duplicateTagHelper = null; + string duplicateAttributeName = null; + var duplicate = node.Children[j]; + if (duplicate is TagHelperDirectiveAttributeIntermediateNode duplicateDirectiveAttribute) + { + duplicateAttributeName = duplicateDirectiveAttribute.AttributeName; + duplicateTagHelper = duplicateDirectiveAttribute.TagHelper; + } + else if (duplicate is TagHelperDirectiveAttributeParameterIntermediateNode duplicateParameterAttribute) + { + duplicateAttributeName = duplicateParameterAttribute.AttributeName; + duplicateTagHelper = duplicateParameterAttribute.TagHelper; + } + if (duplicate != null && + duplicateTagHelper != null && + duplicateTagHelper.IsBindTagHelper() && + duplicateAttributeName == attributeName && + !object.ReferenceEquals(attribute, duplicate)) + { + // Found a duplicate - remove the 'fallback' in favor of the + // more specific tag helper. + node.Children.RemoveAt(i); + break; + } + } + } + + // Also treat the general as a 'fallback' for that case and remove it. + // This is a workaround for a limitation where you can't write a tag helper that binds only + // when a specific attribute is **not** present. + if (attribute != null && + tagHelper != null && + tagHelper.IsInputElementFallbackBindTagHelper()) + { + for (var j = 0; j < node.Children.Count; j++) + { + TagHelperDescriptor duplicateTagHelper = null; + string duplicateAttributeName = null; + var duplicate = node.Children[j]; + if (duplicate is TagHelperDirectiveAttributeIntermediateNode duplicateDirectiveAttribute) + { + duplicateAttributeName = duplicateDirectiveAttribute.AttributeName; + duplicateTagHelper = duplicateDirectiveAttribute.TagHelper; + } + else if (duplicate is TagHelperDirectiveAttributeParameterIntermediateNode duplicateParameterAttribute) + { + duplicateAttributeName = duplicateParameterAttribute.AttributeName; + duplicateTagHelper = duplicateParameterAttribute.TagHelper; + } + if (duplicate != null && + duplicateTagHelper != null && + duplicateTagHelper.IsInputElementBindTagHelper() && + duplicateAttributeName == attributeName && + !object.ReferenceEquals(attribute, duplicate)) + { + // Found a duplicate - remove the 'fallback' input tag helper in favor of the + // more specific tag helper. + node.Children.RemoveAt(i); + break; + } + } + } + } + + // If we still have duplicates at this point then they are genuine conflicts. + var duplicates = node.Children + .OfType() + .GroupBy(p => p.AttributeName) + .Where(g => g.Count() > 1); + + foreach (var duplicate in duplicates) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttribute_Duplicates( + node.Source, + duplicate.First().OriginalAttributeName, + duplicate.ToArray())); + foreach (var property in duplicate) + { + node.Children.Remove(property); + } + } + } + + private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindEntry) + { + // Bind works similarly to a macro, it always expands to code that the user could have written. + // + // For the nodes that are related to the bind-attribute rewrite them to look like a set of + // 'normal' HTML attributes similar to the following transformation. + // + // Input: + // Output: + // + // This means that the expression that appears inside of '@bind' must be an LValue or else + // there will be errors. In general the errors that come from C# in this case are good enough + // to understand the problem. + // + // We also support and encourage the use of EventCallback<> with bind. So in the above example + // the ValueChanged property could be an Action<> or an EventCallback<>. + // + // The BindMethods calls are required with Action<> because to give us a good experience. They + // use overloading to ensure that can get an Action that will convert and set an arbitrary + // value. We have a similar set of APIs to use with EventCallback<>. + // + // We also assume that the element will be treated as a component for now because + // multiple passes handle 'special' tag helpers. We have another pass that translates + // a tag helper node back into 'regular' element when it doesn't have an associated component + var node = bindEntry.BindNode; + if (!TryComputeAttributeNames( + parent, + bindEntry, + out var valueAttributeName, + out var changeAttributeName, + out var expressionAttributeName, + out var changeAttributeNode, + out var valueAttribute, + out var changeAttribute, + out var expressionAttribute)) + { + // Skip anything we can't understand. It's important that we don't crash, that will bring down + // the build. + node.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttribute_InvalidSyntax( + node.Source, + node.AttributeName)); + return new[] { node }; + } + + var original = GetAttributeContent(node); + if (string.IsNullOrEmpty(original.Content)) + { + // This can happen in error cases, the parser will already have flagged this + // as an error, so ignore it. + return new[] { node }; + } + + // Look for a format. If we find one then we need to pass the format into the + // two nodes we generate. + IntermediateToken format = null; + if (bindEntry.BindFormatNode != null) + { + format = GetAttributeContent(bindEntry.BindFormatNode); + } + else if (node.TagHelper?.GetFormat() != null) + { + // We may have a default format if one is associated with the field type. + format = new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = "\"" + node.TagHelper.GetFormat() + "\"", + }; + } + + // Look for a culture. If we find one then we need to pass the culture into the + // two nodes we generate. + IntermediateToken culture = null; + if (bindEntry.BindCultureNode != null) + { + culture = GetAttributeContent(bindEntry.BindCultureNode); + } + else if (node.TagHelper?.IsInvariantCultureBindTagHelper() == true) + { + // We may have a default invariant culture if one is associated with the field type. + culture = new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"global::{typeof(CultureInfo).FullName}.{nameof(CultureInfo.InvariantCulture)}", + }; + } + + var valueExpressionTokens = new List(); + var changeExpressionTokens = new List(); + + // There are a few cases to handle for @bind: + // 1. This is a component using a delegate (int Value & Action Value) + // 2. This is a component using EventCallback (int value & EventCallback) + // 3. This is an element + if (parent is ComponentIntermediateNode && changeAttribute != null && changeAttribute.IsDelegateProperty()) + { + RewriteNodesForComponentDelegateBind( + original, + valueExpressionTokens, + changeExpressionTokens); + } + else if (parent is ComponentIntermediateNode) + { + RewriteNodesForComponentEventCallbackBind( + original, + valueExpressionTokens, + changeExpressionTokens); + } + else + { + RewriteNodesForElementEventCallbackBind( + original, + format, + culture, + valueExpressionTokens, + changeExpressionTokens); + } + + if (parent is MarkupElementIntermediateNode) + { + var valueNode = new HtmlAttributeIntermediateNode() + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = valueAttributeName, + Source = node.Source, + + Prefix = valueAttributeName + "=\"", + Suffix = "\"", + }; + + for (var i = 0; i < node.Diagnostics.Count; i++) + { + valueNode.Diagnostics.Add(node.Diagnostics[i]); + } + + valueNode.Children.Add(new CSharpExpressionAttributeValueIntermediateNode()); + for (var i = 0; i < valueExpressionTokens.Count; i++) + { + valueNode.Children[0].Children.Add(valueExpressionTokens[i]); + } + + var changeNode = new HtmlAttributeIntermediateNode() + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = changeAttributeName, + AttributeNameExpression = changeAttributeNode, + Source = node.Source, + + Prefix = changeAttributeName + "=\"", + Suffix = "\"", + + EventUpdatesAttributeName = valueAttributeName, + }; + + changeNode.Children.Add(new CSharpExpressionAttributeValueIntermediateNode()); + for (var i = 0; i < changeExpressionTokens.Count; i++) + { + changeNode.Children[0].Children.Add(changeExpressionTokens[i]); + } + + return new[] { valueNode, changeNode }; + } + else + { + var valueNode = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = valueAttributeName, + BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute + PropertyName = valueAttribute?.GetPropertyName(), + TagHelper = valueAttribute == null ? null : node.TagHelper, + TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null, + }; + + valueNode.Children.Clear(); + valueNode.Children.Add(new CSharpExpressionIntermediateNode()); + for (var i = 0; i < valueExpressionTokens.Count; i++) + { + valueNode.Children[0].Children.Add(valueExpressionTokens[i]); + } + + var changeNode = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = changeAttributeName, + BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute + PropertyName = changeAttribute?.GetPropertyName(), + TagHelper = changeAttribute == null ? null : node.TagHelper, + TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null, + }; + + changeNode.Children.Clear(); + changeNode.Children.Add(new CSharpExpressionIntermediateNode()); + for (var i = 0; i < changeExpressionTokens.Count; i++) + { + changeNode.Children[0].Children.Add(changeExpressionTokens[i]); + } + + // Finally, also emit a node for the "Expression" attribute, but only if the target + // component is defined to accept one + ComponentAttributeIntermediateNode expressionNode = null; + if (expressionAttribute != null) + { + expressionNode = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = expressionAttributeName, + BoundAttribute = expressionAttribute, + PropertyName = expressionAttribute.GetPropertyName(), + TagHelper = node.TagHelper, + TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName, + }; + + expressionNode.Children.Clear(); + expressionNode.Children.Add(new CSharpExpressionIntermediateNode()); + expressionNode.Children[0].Children.Add(new IntermediateToken() + { + Content = $"() => {original.Content}", + Kind = TokenKind.CSharp + }); + } + + return expressionNode == null + ? new[] { valueNode, changeNode } + : new[] { valueNode, changeNode, expressionNode }; + } + } + + private bool TryParseBindAttribute(BindEntry bindEntry, out string valueAttributeName) + { + var attributeName = bindEntry.BindNode.AttributeName; + valueAttributeName = null; + + if (attributeName == "bind") + { + return true; + } + + if (!attributeName.StartsWith("bind-")) + { + return false; + } + + valueAttributeName = attributeName.Substring("bind-".Length); + return true; + } + + // Attempts to compute the attribute names that should be used for an instance of 'bind'. + private bool TryComputeAttributeNames( + IntermediateNode parent, + BindEntry bindEntry, + out string valueAttributeName, + out string changeAttributeName, + out string expressionAttributeName, + out CSharpExpressionIntermediateNode changeAttributeNode, + out BoundAttributeDescriptor valueAttribute, + out BoundAttributeDescriptor changeAttribute, + out BoundAttributeDescriptor expressionAttribute) + { + valueAttributeName = null; + changeAttributeName = null; + expressionAttributeName = null; + changeAttributeNode = null; + valueAttribute = null; + changeAttribute = null; + expressionAttribute = null; + + // The tag helper specifies attribute names, they should win. + // + // This handles cases like where the tag helper is + // generated to match a specific tag and has metadata that identify the attributes. + // + // We expect 1 bind tag helper per-node. + var node = bindEntry.BindNode; + var attributeName = node.AttributeName; + + // Even though some of our 'bind' tag helpers specify the attribute names, they + // should still satisfy one of the valid syntaxes. + if (!TryParseBindAttribute(bindEntry, out valueAttributeName)) + { + return false; + } + + valueAttributeName = node.TagHelper.GetValueAttributeName() ?? valueAttributeName; + + // If there an attribute that specifies the event like @bind:event="oninput", + // that should be preferred. Otherwise, use the one from the tag helper. + if (bindEntry.BindEventNode == null) + { + // @bind:event not specified + changeAttributeName ??= node.TagHelper.GetChangeAttributeName(); + } + else if (TryExtractEventNodeStaticText(bindEntry.BindEventNode, out var text)) + { + // @bind:event="oninput" - change attribute is static + changeAttributeName = text; + } + else + { + // @bind:event="@someExpr" - we can't know the name of the change attribute, it's dynamic + changeAttributeNode = ExtractEventNodeExpression(bindEntry.BindEventNode); + } + + expressionAttributeName = node.TagHelper.GetExpressionAttributeName(); + + // We expect 0-1 components per-node. + var componentTagHelper = (parent as ComponentIntermediateNode)?.Component; + if (componentTagHelper == null) + { + // If it's not a component node then there isn't too much else to figure out. + return attributeName != null && (changeAttributeName != null || changeAttributeNode != null); + } + + // If this is a component, we need an attribute name for the value. + if (attributeName == null) + { + return false; + } + + // If this is a component, then we can infer 'Changed' as the name + // of the change event. + if (changeAttributeName == null) + { + changeAttributeName = valueAttributeName + "Changed"; + } + + // Likewise for the expression attribute + if (expressionAttributeName == null) + { + expressionAttributeName = valueAttributeName + "Expression"; + } + + for (var i = 0; i < componentTagHelper.BoundAttributes.Count; i++) + { + var attribute = componentTagHelper.BoundAttributes[i]; + + if (string.Equals(valueAttributeName, attribute.Name)) + { + valueAttribute = attribute; + } + + if (string.Equals(changeAttributeName, attribute.Name)) + { + changeAttribute = attribute; + } + + if (string.Equals(expressionAttributeName, attribute.Name)) + { + expressionAttribute = attribute; + } + } + + return true; + + static bool TryExtractEventNodeStaticText(TagHelperDirectiveAttributeParameterIntermediateNode node, out string text) + { + if (node.Children[0] is HtmlContentIntermediateNode html) + { + text = GetAttributeContent(html).Content; + return true; + } + + text = null; + return false; + } + + static CSharpExpressionIntermediateNode ExtractEventNodeExpression(TagHelperDirectiveAttributeParameterIntermediateNode node) + { + if (node.Children[0] is CSharpExpressionIntermediateNode expression) + { + return expression; + } + + return null; + } + } + + private void RewriteNodesForComponentDelegateBind( + IntermediateToken original, + List valueExpressionTokens, + List changeExpressionTokens) + { + // For a component using @bind we want to: + // - use the value as-is + // - create a delegate to handle changes + valueExpressionTokens.Add(original); + + // Now rewrite the content of the change-handler node. Since it's a component attribute, + // we don't use the 'BindMethods' wrapper. We expect component attributes to always 'match' on type. + // + // __value => = __value + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp, + }); + } + + private void RewriteNodesForComponentEventCallbackBind( + IntermediateToken original, + List valueExpressionTokens, + List changeExpressionTokens) + { + // For a component using @bind we want to: + // - use the value as-is + // - create a delegate to handle changes + valueExpressionTokens.Add(original); + + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, __value => {original.Content} = __value, {original.Content})", + Kind = TokenKind.CSharp + }); + } + + private void RewriteNodesForElementEventCallbackBind( + IntermediateToken original, + IntermediateToken format, + IntermediateToken culture, + List valueExpressionTokens, + List changeExpressionTokens) + { + // This is bind on a markup element. We use FormatValue to transform the value in the correct way + // according to format and culture. + // + // Now rewrite the content of the value node to look like: + // + // BindConverter.FormatValue(, format: , culture: ) + valueExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.BindConverter.FormatValue}(", + Kind = TokenKind.CSharp + }); + valueExpressionTokens.Add(original); + + if (!string.IsNullOrEmpty(format?.Content)) + { + valueExpressionTokens.Add(new IntermediateToken() + { + Content = ", format: ", + Kind = TokenKind.CSharp, + }); + valueExpressionTokens.Add(format); + } + + if (!string.IsNullOrEmpty(culture?.Content)) + { + valueExpressionTokens.Add(new IntermediateToken() + { + Content = ", culture: ", + Kind = TokenKind.CSharp, + }); + valueExpressionTokens.Add(culture); + } + + valueExpressionTokens.Add(new IntermediateToken() + { + Content = ")", + Kind = TokenKind.CSharp, + }); + + // Now rewrite the content of the change-handler node. There are two cases we care about + // here. If it's a component attribute, then don't use the 'CreateBinder' wrapper. We expect + // component attributes to always 'match' on type. + // + // The really tricky part of this is that we CANNOT write the type name of of the EventCallback we + // intend to create. Doing so would really complicate the story for how we deal with generic types, + // since the generic type lowering pass runs after this. To keep this simple we're relying on + // the compiler to resolve overloads for us. + // + // RuntimeHelpers.CreateInferredEventCallback(this, __value => = __value, ) + // + // For general DOM attributes, we need to be able to create a delegate that accepts UIEventArgs + // so we use 'CreateBinder' + // + // EventCallbackFactory.CreateBinder(this, __value => = __value, , format: , culture: ) + // + // Note that the linemappings here are applied to the value attribute, not the change attribute. + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateBinderMethod}(this, __value => {original.Content} = __value, ", + Kind = TokenKind.CSharp + }); + + changeExpressionTokens.Add(new IntermediateToken() + { + Content = original.Content, + Kind = TokenKind.CSharp + }); + + if (format != null) + { + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $", format: {format.Content}", + Kind = TokenKind.CSharp + }); + } + + if (culture != null) + { + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $", culture: {culture.Content}", + Kind = TokenKind.CSharp + }); + } + + changeExpressionTokens.Add(new IntermediateToken() + { + Content = ")", + Kind = TokenKind.CSharp, + }); + } + + private static IntermediateToken GetAttributeContent(IntermediateNode node) + { + var template = node.FindDescendantNodes().FirstOrDefault(); + if (template != null) + { + // See comments in TemplateDiagnosticPass + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_TemplateInvalidLocation(template.Source)); + return new IntermediateToken() { Kind = TokenKind.CSharp, Content = string.Empty, }; + } + + if (node.Children[0] is HtmlContentIntermediateNode htmlContentNode) + { + // This case can be hit for a 'string' attribute. We want to turn it into + // an expression. + var content = "\"" + string.Join(string.Empty, htmlContentNode.Children.OfType().Select(t => t.Content)) + "\""; + return new IntermediateToken() { Kind = TokenKind.CSharp, Content = content }; + } + else if (node.Children[0] is CSharpExpressionIntermediateNode cSharpNode) + { + // This case can be hit when the attribute has an explicit @ inside, which + // 'escapes' any special sugar we provide for codegen. + return GetToken(cSharpNode); + } + else + { + // This is the common case for 'mixed' content + return GetToken(node); + } + + IntermediateToken GetToken(IntermediateNode parent) + { + if (parent.Children.Count == 1 && parent.Children[0] is IntermediateToken token) + { + return token; + } + + // In error cases we won't have a single token, but we still want to generate the code. + return new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = string.Join(string.Empty, parent.Children.OfType().Select(t => t.Content)), + }; + } + } + + private class BindEntry + { + public BindEntry(IntermediateNodeReference bindNodeReference) + { + BindNodeReference = bindNodeReference; + BindNode = (TagHelperDirectiveAttributeIntermediateNode)bindNodeReference.Node; + } + + public IntermediateNodeReference BindNodeReference { get; } + + public TagHelperDirectiveAttributeIntermediateNode BindNode { get; } + + public TagHelperDirectiveAttributeParameterIntermediateNode BindEventNode { get; set; } + + public TagHelperDirectiveAttributeParameterIntermediateNode BindFormatNode { get; set; } + + public TagHelperDirectiveAttributeParameterIntermediateNode BindCultureNode { get; set; } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentChildContentDiagnosticPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentChildContentDiagnosticPass.cs new file mode 100644 index 0000000000..ea102fa9c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentChildContentDiagnosticPass.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentChildContentDiagnosticPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Runs after components/eventhandlers/ref/bind/templates. We want to validate every component + // and it's usage of ChildContent. + public override int Order => 160; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + var visitor = new Visitor(); + visitor.Visit(documentNode); + } + + private class Visitor : IntermediateNodeWalker + { + public override void VisitComponent(ComponentIntermediateNode node) + { + // Check for properties that are set by both element contents (body) and the attribute itself. + foreach (var childContent in node.ChildContents) + { + foreach (var attribute in node.Attributes) + { + if (attribute.AttributeName == childContent.AttributeName) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentSetByAttributeAndBody( + attribute.Source, + attribute.AttributeName)); + } + } + } + + base.VisitDefault(node); + } + + public override void VisitComponentChildContent(ComponentChildContentIntermediateNode node) + { + // Check that each child content has a unique parameter name within its scope. This is important + // because the parameter name can be implicit, and it doesn't work well when nested. + if (node.IsParameterized) + { + for (var i = 0; i < Ancestors.Count - 1; i++) + { + var ancestor = Ancestors[i] as ComponentChildContentIntermediateNode; + if (ancestor != null && + ancestor.IsParameterized && + string.Equals(node.ParameterName, ancestor.ParameterName, StringComparison.Ordinal)) + { + // Duplicate name. We report an error because this will almost certainly also lead to an error + // from the C# compiler that's way less clear. + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentRepeatedParameterName( + node.Source, + node, + (ComponentIntermediateNode)Ancestors[0], // Enclosing component + ancestor, // conflicting child content node + (ComponentIntermediateNode)Ancestors[i + 1])); // Enclosing component of conflicting child content node + } + } + } + + base.VisitDefault(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentCodeDirective.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentCodeDirective.cs new file mode 100644 index 0000000000..509e8928d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentCodeDirective.cs @@ -0,0 +1,28 @@ +// 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.Razor.Language.Components +{ + public static class ComponentCodeDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "code", + DirectiveKind.CodeBlock, + builder => + { + builder.Description = Resources.FunctionsDirective_Description; + }); + + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive, FileKinds.Component); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentCodeTarget.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentCodeTarget.cs new file mode 100644 index 0000000000..a106dd5d5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentCodeTarget.cs @@ -0,0 +1,58 @@ +// 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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentCodeTarget : CodeTarget + { + private readonly RazorCodeGenerationOptions _options; + + public ComponentCodeTarget(RazorCodeGenerationOptions options, IEnumerable extensions) + { + _options = options; + + // Components provide some built-in target extensions that don't apply to + // legacy documents. + Extensions = new[] { new ComponentTemplateTargetExtension(), }.Concat(extensions).ToArray(); + } + + public ICodeTargetExtension[] Extensions { get; } + + public override IntermediateNodeWriter CreateNodeWriter() + { + return _options.DesignTime ? (IntermediateNodeWriter)new ComponentDesignTimeNodeWriter() : new ComponentRuntimeNodeWriter(); + } + + public override TExtension GetExtension() + { + for (var i = 0; i < Extensions.Length; i++) + { + var match = Extensions[i] as TExtension; + if (match != null) + { + return match; + } + } + + return null; + } + + public override bool HasExtension() + { + for (var i = 0; i < Extensions.Length; i++) + { + var match = Extensions[i] as TExtension; + if (match != null) + { + return true; + } + } + + return false; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentComplexAttributeContentPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentComplexAttributeContentPass.cs new file mode 100644 index 0000000000..37d3d4ca2e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentComplexAttributeContentPass.cs @@ -0,0 +1,122 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + // We don't support 'complex' content for components (mixed C# and markup) right now. + // It's not clear yet if components will have a good scenario to use these constructs. + // + // This is where a lot of the complexity in the Razor/TagHelpers model creeps in and we + // might be able to avoid it if these features aren't needed. + internal class ComponentComplexAttributeContentPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Run before other Component passes + public override int Order => -1000; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + var nodes = documentNode.FindDescendantNodes(); + for (var i = 0; i < nodes.Count; i++) + { + ProcessAttributes(nodes[i]); + } + } + + private void ProcessAttributes(TagHelperIntermediateNode node) + { + for (var i = node.Children.Count - 1; i >= 0; i--) + { + if (node.Children[i] is TagHelperPropertyIntermediateNode propertyNode) + { + if (!TrySimplifyContent(propertyNode) && node.TagHelpers.Any(t => t.IsComponentTagHelper())) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_UnsupportedComplexContent( + propertyNode, + propertyNode.AttributeName)); + node.Children.RemoveAt(i); + continue; + } + } + else if (node.Children[i] is TagHelperHtmlAttributeIntermediateNode htmlNode) + { + if (!TrySimplifyContent(htmlNode) && node.TagHelpers.Any(t => t.IsComponentTagHelper())) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_UnsupportedComplexContent( + htmlNode, + htmlNode.AttributeName)); + node.Children.RemoveAt(i); + continue; + } + } + else if (node.Children[i] is TagHelperDirectiveAttributeIntermediateNode directiveAttributeNode) + { + if (!TrySimplifyContent(directiveAttributeNode)) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_UnsupportedComplexContent( + directiveAttributeNode, + directiveAttributeNode.OriginalAttributeName)); + node.Children.RemoveAt(i); + continue; + } + } + } + } + + private static bool TrySimplifyContent(IntermediateNode node) + { + if (node.Children.Count == 1 && + node.Children[0] is HtmlAttributeIntermediateNode htmlNode && + htmlNode.Children.Count > 1) + { + // This case can be hit for a 'string' attribute + return false; + } + else if (node.Children.Count == 1 && + node.Children[0] is CSharpExpressionIntermediateNode cSharpNode && + cSharpNode.Children.Count > 1) + { + // This case can be hit when the attribute has an explicit @ inside, which + // 'escapes' any special sugar we provide for codegen. + // + // There's a special case here for explicit expressions. See https://github.com/aspnet/Razor/issues/2203 + // handling this case as a tactical matter since it's important for lambdas. + if (cSharpNode.Children.Count == 3 && + cSharpNode.Children[0] is IntermediateToken token0 && + cSharpNode.Children[2] is IntermediateToken token2 && + token0.Content == "(" && + token2.Content == ")") + { + cSharpNode.Children.RemoveAt(2); + cSharpNode.Children.RemoveAt(0); + + // We were able to simplify it, all good. + return true; + } + + return false; + } + else if (node.Children.Count == 1 && + node.Children[0] is CSharpCodeIntermediateNode) + { + // This is the case when an attribute contains a code block @{ ... } + // We don't support this. + return false; + } + else if (node.Children.Count > 1) + { + // This is the common case for 'mixed' content + return false; + } + + return true; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs new file mode 100644 index 0000000000..c1e0c625f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs @@ -0,0 +1,991 @@ +// 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + // Based on the DesignTimeNodeWriter from Razor repo. + internal class ComponentDesignTimeNodeWriter : ComponentNodeWriter + { + private readonly ScopeStack _scopeStack = new ScopeStack(); + + private static readonly string DesignTimeVariable = "__o"; + + public override void WriteMarkupBlock(CodeRenderingContext context, MarkupBlockIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Do nothing + } + + public override void WriteMarkupElement(CodeRenderingContext context, MarkupElementIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + context.RenderChildren(node); + } + + public override void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.Source.HasValue) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + context.AddSourceMappingFor(node); + context.CodeWriter.WriteUsing(node.Content); + } + } + else + { + context.CodeWriter.WriteUsing(node.Content); + } + } + + public override void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + WriteCSharpExpressionInnards(context, node); + } + + private void WriteCSharpExpressionInnards(CodeRenderingContext context, CSharpExpressionIntermediateNode node, string type = null) + { + if (node.Children.Count == 0) + { + return; + } + + if (node.Source != null) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + var offset = DesignTimeVariable.Length + " = ".Length; + + if (type != null) + { + offset += type.Length + 2; // two parenthesis + } + + context.CodeWriter.WritePadding(offset, node.Source, context); + context.CodeWriter.WriteStartAssignment(DesignTimeVariable); + + if (type != null) + { + context.CodeWriter.Write("("); + context.CodeWriter.Write(type); + context.CodeWriter.Write(")"); + } + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + + context.CodeWriter.WriteLine(";"); + } + } + else + { + context.CodeWriter.WriteStartAssignment(DesignTimeVariable); + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + context.CodeWriter.WriteLine(";"); + } + } + + public override void WriteCSharpCode(CodeRenderingContext context, CSharpCodeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + var isWhitespaceStatement = true; + for (var i = 0; i < node.Children.Count; i++) + { + var token = node.Children[i] as IntermediateToken; + if (token == null || !string.IsNullOrWhiteSpace(token.Content)) + { + isWhitespaceStatement = false; + break; + } + } + + IDisposable linePragmaScope = null; + if (node.Source != null) + { + if (!isWhitespaceStatement) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value, context); + } + + context.CodeWriter.WritePadding(0, node.Source.Value, context); + } + else if (isWhitespaceStatement) + { + // Don't write whitespace if there is no line mapping for it. + return; + } + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the statement like an extension node. + context.RenderNode(node.Children[i]); + } + } + + if (linePragmaScope != null) + { + linePragmaScope.Dispose(); + } + else + { + context.CodeWriter.WriteLine(); + } + } + + public override void WriteHtmlAttribute(CodeRenderingContext context, HtmlAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // This expression may contain code so we have to render it or else the design-time + // exprience is broken. + if (node.AttributeNameExpression is CSharpExpressionIntermediateNode expression) + { + WriteCSharpExpressionInnards(context, expression, "string"); + } + + context.RenderChildren(node); + } + + public override void WriteHtmlAttributeValue(CodeRenderingContext context, HtmlAttributeValueIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Do nothing, this can't contain code. + } + + public override void WriteCSharpExpressionAttributeValue(CodeRenderingContext context, CSharpExpressionAttributeValueIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.Children.Count == 0) + { + return; + } + + context.CodeWriter.WriteStartAssignment(DesignTimeVariable); + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + WriteCSharpToken(context, token); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + context.CodeWriter.WriteLine(";"); + } + + public override void WriteHtmlContent(CodeRenderingContext context, HtmlContentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Do nothing + } + + protected override void BeginWriteAttribute(CodeRenderingContext context, string key) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{nameof(ComponentsApi.RenderTreeBuilder.AddAttribute)}") + .Write("-1") + .WriteParameterSeparator() + .WriteStringLiteral(key) + .WriteParameterSeparator(); + } + + protected override void BeginWriteAttribute(CodeRenderingContext context, IntermediateNode expression) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (expression == null) + { + throw new ArgumentNullException(nameof(expression)); + } + + context.CodeWriter.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddAttribute}"); + context.CodeWriter.Write("-1"); + context.CodeWriter.WriteParameterSeparator(); + + var tokens = GetCSharpTokens(expression); + for (var i = 0; i < tokens.Count; i++) + { + context.CodeWriter.Write(tokens[i].Content); + } + + context.CodeWriter.WriteParameterSeparator(); + } + + public override void WriteComponent(CodeRenderingContext context, ComponentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.TypeInferenceNode == null) + { + // Writes something like: + // + // __builder.OpenComponent(0); + // __builder.AddAttribute(1, "Foo", ...); + // __builder.AddAttribute(2, "ChildContent", ...); + // __builder.SetKey(someValue); + // __builder.AddElementCapture(3, (__value) => _field = __value); + // __builder.CloseComponent(); + + foreach (var typeArgument in node.TypeArguments) + { + context.RenderNode(typeArgument); + } + + // We need to preserve order for attibutes and attribute splats since the ordering + // has a semantic effect. + + foreach (var child in node.Children) + { + if (child is ComponentAttributeIntermediateNode attribute) + { + context.RenderNode(attribute); + } + else if (child is SplatIntermediateNode splat) + { + context.RenderNode(splat); + } + } + + if (node.ChildContents.Any()) + { + foreach (var childContent in node.ChildContents) + { + context.RenderNode(childContent); + } + } + else + { + // We eliminate 'empty' child content when building the tree so that usage like + // '\r\n' doesn't create a child content. + // + // Consider what would happen if the user's cursor was inside the element. At + // design -time we want to render an empty lambda to provide proper scoping + // for any code that the user types. + context.RenderNode(new ComponentChildContentIntermediateNode() + { + TypeName = ComponentsApi.RenderFragment.FullTypeName, + }); + } + + foreach (var setKey in node.SetKeys) + { + context.RenderNode(setKey); + } + + foreach (var capture in node.Captures) + { + context.RenderNode(capture); + } + } + else + { + // When we're doing type inference, we can't write all of the code inline to initialize + // the component on the builder. We generate a method elsewhere, and then pass all of the information + // to that method. We pass in all of the attribute values + the sequence numbers. + // + // __Blazor.MyComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, ..., 2, ..., 3, ....); + + // Preserve order of attributes + splats + var attributes = node.Children.Where(s => + { + return s is ComponentAttributeIntermediateNode || s is SplatIntermediateNode; + }).ToList(); + var childContents = node.ChildContents.ToList(); + var captures = node.Captures.ToList(); + var setKeys = node.SetKeys.ToList(); + var remaining = attributes.Count + childContents.Count + captures.Count + setKeys.Count; + + context.CodeWriter.Write(node.TypeInferenceNode.FullTypeName); + context.CodeWriter.Write("."); + context.CodeWriter.Write(node.TypeInferenceNode.MethodName); + context.CodeWriter.Write("("); + + context.CodeWriter.Write(_scopeStack.BuilderVarName); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write("-1"); + context.CodeWriter.Write(", "); + + for (var i = 0; i < attributes.Count; i++) + { + context.CodeWriter.Write("-1"); + context.CodeWriter.Write(", "); + + // Don't type check generics, since we can't actually write the type name. + // The type checking with happen anyway since we defined a method and we're generating + // a call to it. + if (attributes[i] is ComponentAttributeIntermediateNode attribute) + { + WriteComponentAttributeInnards(context, attribute, canTypeCheck: false); + } + else if (attributes[i] is SplatIntermediateNode splat) + { + WriteSplatInnards(context, splat, canTypeCheck: false); + } + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + for (var i = 0; i < childContents.Count; i++) + { + context.CodeWriter.Write("-1"); + context.CodeWriter.Write(", "); + + WriteComponentChildContentInnards(context, childContents[i]); + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + for (var i = 0; i < setKeys.Count; i++) + { + context.CodeWriter.Write("-1"); + context.CodeWriter.Write(", "); + + WriteSetKeyInnards(context, setKeys[i]); + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + for (var i = 0; i < captures.Count; i++) + { + context.CodeWriter.Write("-1"); + context.CodeWriter.Write(", "); + + WriteReferenceCaptureInnards(context, captures[i], shouldTypeCheck: false); + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + } + + // We want to generate something that references the Component type to avoid + // the "usings directive is unnecessary" message. + // Looks like: + // __o = typeof(SomeNamespace.SomeComponent); + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + context.CodeWriter.Write(DesignTimeVariable); + context.CodeWriter.Write(" = "); + context.CodeWriter.Write("typeof("); + context.CodeWriter.Write(node.TagName); + if (node.Component.IsGenericTypedComponent()) + { + context.CodeWriter.Write("<"); + var typeArgumentCount = node.Component.GetTypeParameters().Count(); + for (var i = 1; i < typeArgumentCount; i++) + { + context.CodeWriter.Write(","); + } + context.CodeWriter.Write(">"); + } + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + } + } + + public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // __o = 17; + context.CodeWriter.Write(DesignTimeVariable); + context.CodeWriter.Write(" = "); + + // Following the same design pattern as the runtime codegen + WriteComponentAttributeInnards(context, node, canTypeCheck: true); + + context.CodeWriter.Write(";"); + context.CodeWriter.WriteLine(); + } + + private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeIntermediateNode node, bool canTypeCheck) + { + // We limit component attributes to simple cases. However there is still a lot of complexity + // to handle here, since there are a few different cases for how an attribute might be structured. + // + // This roughly follows the design of the runtime writer for simplicity. + if (node.AttributeStructure == AttributeStructure.Minimized) + { + // Minimized attributes always map to 'true' + context.CodeWriter.Write("true"); + } + else if (node.Children.Count > 1) + { + // We don't expect this to happen, we just want to know if it can. + throw new InvalidOperationException("Attribute nodes should either be minimized or a single type of content." + string.Join(", ", node.Children)); + } + else if (node.Children.Count == 1 && node.Children[0] is HtmlContentIntermediateNode) + { + // We don't actually need the content at designtime, an empty string will do. + context.CodeWriter.Write("\"\""); + } + else + { + // There are a few different forms that could be used to contain all of the tokens, but we don't really care + // exactly what it looks like - we just want all of the content. + // + // This can include an empty list in some cases like the following (sic): + // + // + // Of a list of tokens directly in the attribute. + var tokens = GetCSharpTokens(node); + + if ((node.BoundAttribute?.IsDelegateProperty() ?? false) || + (node.BoundAttribute?.IsChildContentProperty() ?? false)) + { + // We always surround the expression with the delegate constructor. This makes type + // inference inside lambdas, and method group conversion do the right thing. + if (canTypeCheck) + { + context.CodeWriter.Write("new "); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write("("); + } + context.CodeWriter.WriteLine(); + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + if (canTypeCheck) + { + context.CodeWriter.Write(")"); + } + } + else if (node.BoundAttribute?.IsEventCallbackProperty() ?? false) + { + // This is the case where we are writing an EventCallback (a delegate with super-powers). + // + // An event callback can either be passed verbatim, or it can be created by the EventCallbackFactory. + // Since we don't look at the code the user typed inside the attribute value, this is always + // resolved via overloading. + + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write(">"); + context.CodeWriter.Write("("); + } + + // Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, ...) OR + // Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, ...) + + context.CodeWriter.Write(ComponentsApi.EventCallback.FactoryAccessor); + context.CodeWriter.Write("."); + context.CodeWriter.Write(ComponentsApi.EventCallbackFactory.CreateMethod); + + if (node.TryParseEventCallbackTypeArgument(out var argument)) + { + context.CodeWriter.Write("<"); + context.CodeWriter.Write(argument); + context.CodeWriter.Write(">"); + } + + context.CodeWriter.Write("("); + context.CodeWriter.Write("this"); + context.CodeWriter.Write(", "); + + context.CodeWriter.WriteLine(); + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + context.CodeWriter.Write(")"); + + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(")"); + } + } + else + { + // This is the case when an attribute contains C# code + // + // If we have a parameter type, then add a type check. + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write(">"); + context.CodeWriter.Write("("); + } + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(")"); + } + } + } + + static bool NeedsTypeCheck(ComponentAttributeIntermediateNode n) + { + // Weakly typed attributes will have their TypeName set to null. + return n.BoundAttribute != null && n.TypeName != null; + } + } + + private IReadOnlyList GetCSharpTokens(IntermediateNode node) + { + // We generally expect all children to be CSharp, this is here just in case. + return node.FindDescendantNodes().Where(t => t.IsCSharp).ToArray(); + } + + public override void WriteComponentChildContent(CodeRenderingContext context, ComponentChildContentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Writes something like: + // + // __builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... })); + // OR + // __builder.AddAttribute(1, "ChildContent", (RenderFragment)((person) => (__builder73) => { ... })); + BeginWriteAttribute(context, node.AttributeName); + context.CodeWriter.Write($"({node.TypeName})("); + + WriteComponentChildContentInnards(context, node); + + context.CodeWriter.Write(")"); + context.CodeWriter.WriteEndMethodInvocation(); + } + + private void WriteComponentChildContentInnards(CodeRenderingContext context, ComponentChildContentIntermediateNode node) + { + // Writes something like: + // + // ((__builder73) => { ... }) + // OR + // ((person) => (__builder73) => { }) + _scopeStack.OpenComponentScope( + context, + node.AttributeName, + node.IsParameterized ? node.ParameterName : null); + for (var i = 0; i < node.Children.Count; i++) + { + context.RenderNode(node.Children[i]); + } + _scopeStack.CloseScope(context); + } + + public override void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // At design type we want write the equivalent of: + // + // __o = typeof(TItem); + context.CodeWriter.Write(DesignTimeVariable); + context.CodeWriter.Write(" = "); + context.CodeWriter.Write("typeof("); + + var tokens = GetCSharpTokens(node); + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + + IReadOnlyList GetCSharpTokens(ComponentTypeArgumentIntermediateNode arg) + { + // We generally expect all children to be CSharp, this is here just in case. + return arg.FindDescendantNodes().Where(t => t.IsCSharp).ToArray(); + } + } + + public override void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // + // (__builder73) => { ... } + _scopeStack.OpenTemplateScope(context); + context.RenderChildren(node); + _scopeStack.CloseScope(context); + } + + public override void WriteSetKey(CodeRenderingContext context, SetKeyIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // + // __builder.SetKey(_keyValue); + + var codeWriter = context.CodeWriter; + + codeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.SetKey}"); + WriteSetKeyInnards(context, node); + codeWriter.WriteEndMethodInvocation(); + } + + private void WriteSetKeyInnards(CodeRenderingContext context, SetKeyIntermediateNode node) + { + WriteCSharpCode(context, new CSharpCodeIntermediateNode + { + Source = node.Source, + Children = + { + node.KeyValueToken + } + }); + } + + public override void WriteSplat(CodeRenderingContext context, SplatIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // + // __builder.AddMultipleAttributes(2, ...); + context.CodeWriter.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddMultipleAttributes}"); + context.CodeWriter.Write("-1"); + context.CodeWriter.WriteParameterSeparator(); + + WriteSplatInnards(context, node, canTypeCheck: true); + + context.CodeWriter.WriteEndMethodInvocation(); + } + + private void WriteSplatInnards(CodeRenderingContext context, SplatIntermediateNode node, bool canTypeCheck) + { + var tokens = GetCSharpTokens(node); + + if (canTypeCheck) + { + context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(ComponentsApi.AddMultipleAttributesTypeFullName); + context.CodeWriter.Write(">"); + context.CodeWriter.Write("("); + } + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + if (canTypeCheck) + { + context.CodeWriter.Write(")"); + } + } + + public override void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // + // __field = default(MyComponent); + WriteReferenceCaptureInnards(context, node, shouldTypeCheck: true); + } + + protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, ReferenceCaptureIntermediateNode node, bool shouldTypeCheck) + { + // We specialize this code based on whether or not we can type check. When we're calling into + // a type-inferenced component, we can't do the type check. See the comments in WriteTypeInferenceMethod. + if (shouldTypeCheck) + { + // The runtime node writer moves the call elsewhere. At design time we + // just want sufficiently similar code that any unknown-identifier or type + // errors will be equivalent + var captureTypeName = node.IsComponentCapture + ? node.ComponentCaptureTypeName + : ComponentsApi.ElementReference.FullTypeName; + WriteCSharpCode(context, new CSharpCodeIntermediateNode + { + Source = node.Source, + Children = + { + node.IdentifierToken, + new IntermediateToken + { + Kind = TokenKind.CSharp, + Content = $" = default({captureTypeName});" + } + } + }); + } + else + { + // Looks like: + // + // (__value) = { _field = (MyComponent)__value; } + // OR + // (__value) = { _field = (ElementRef)__value; } + const string refCaptureParamName = "__value"; + using (var lambdaScope = context.CodeWriter.BuildLambda(refCaptureParamName)) + { + WriteCSharpCode(context, new CSharpCodeIntermediateNode + { + Source = node.Source, + Children = + { + node.IdentifierToken, + new IntermediateToken + { + Kind = TokenKind.CSharp, + Content = $" = {refCaptureParamName};" + } + } + }); + } + } + } + + private void WriteCSharpToken(CodeRenderingContext context, IntermediateToken token) + { + if (string.IsNullOrWhiteSpace(token.Content)) + { + return; + } + + if (token.Source?.FilePath == null) + { + context.CodeWriter.Write(token.Content); + return; + } + + using (context.CodeWriter.BuildLinePragma(token.Source, context)) + { + context.CodeWriter.WritePadding(0, token.Source.Value, context); + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs new file mode 100644 index 0000000000..0aa49c6446 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -0,0 +1,458 @@ +// 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.Diagnostics; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal static class ComponentDiagnosticFactory + { + private const string DiagnosticPrefix = "RZ"; + + public static readonly RazorDiagnosticDescriptor UnsupportedTagHelperDirective = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9978", + () => + "The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. " + + "Use '@using ' directive instead.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnsupportedTagHelperDirective(SourceSpan? source) + { + return RazorDiagnostic.Create(UnsupportedTagHelperDirective, source ?? SourceSpan.Undefined); + } + + public static readonly RazorDiagnosticDescriptor CodeBlockInAttribute = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9979", + () => + "Code blocks delimited by '@{{...}}' like '@{{ {0} }}' for attributes are no longer supported " + + "These features have been changed to use attribute syntax. " + + "Use 'attr=\"@(x => {{... }}\"'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_CodeBlockInAttribute(SourceSpan? source, string expression) + { + var diagnostic = RazorDiagnostic.Create( + CodeBlockInAttribute, + source ?? SourceSpan.Undefined, + expression); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor UnclosedTag = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9980", + () => "Unclosed tag '{0}' with no matching end tag.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnclosedTag(SourceSpan? span, string tagName) + { + return RazorDiagnostic.Create(UnclosedTag, span ?? SourceSpan.Undefined, tagName); + } + + public static readonly RazorDiagnosticDescriptor UnexpectedClosingTag = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9981", + () => "Unexpected closing tag '{0}' with no matching start tag.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnexpectedClosingTag(SourceSpan? span, string tagName) + { + return RazorDiagnostic.Create(UnexpectedClosingTag, span ?? SourceSpan.Undefined, tagName); + } + + public static readonly RazorDiagnosticDescriptor UnexpectedClosingTagForVoidElement = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9983", + () => "Unexpected closing tag '{0}'. The element '{0}' is a void element, and should be used without a closing tag.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnexpectedClosingTagForVoidElement(SourceSpan? span, string tagName) + { + return RazorDiagnostic.Create(UnexpectedClosingTagForVoidElement, span ?? SourceSpan.Undefined, tagName); + } + + public static readonly RazorDiagnosticDescriptor InvalidHtmlContent = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9984", + () => "Found invalid HTML content. Text '{0}'", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_InvalidHtmlContent(SourceSpan? span, string text) + { + return RazorDiagnostic.Create(InvalidHtmlContent, span ?? SourceSpan.Undefined, text); + } + + public static readonly RazorDiagnosticDescriptor MultipleComponents = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9985", + () => "Multiple components use the tag '{0}'. Components: {1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_MultipleComponents(SourceSpan? span, string tagName, IEnumerable components) + { + return RazorDiagnostic.Create(MultipleComponents, span ?? SourceSpan.Undefined, tagName, string.Join(", ", components.Select(c => c.DisplayName))); + } + + public static readonly RazorDiagnosticDescriptor UnsupportedComplexContent = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9986", + () => "Component attributes do not support complex content (mixed C# and markup). Attribute: '{0}', text: '{1}'", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnsupportedComplexContent(IntermediateNode node, string attributeName) + { + var content = string.Join("", node.FindDescendantNodes().Select(t => t.Content)); + return RazorDiagnostic.Create(UnsupportedComplexContent, node.Source ?? SourceSpan.Undefined, attributeName, content); + } + + public static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9987", + () => ComponentResources.PageDirectiveCannotBeImported, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_CannotBeImported(SourceSpan source) + { + var fileName = Path.GetFileName(source.FilePath); + var diagnostic = RazorDiagnostic.Create(PageDirective_CannotBeImported, source, "page", fileName); + + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor PageDirective_MustSpecifyRoute = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9988", + () => "The @page directive must specify a route template. The route template must be enclosed in quotes and begin with the '/' character.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_MustSpecifyRoute(SourceSpan? source) + { + var diagnostic = RazorDiagnostic.Create(PageDirective_MustSpecifyRoute, source ?? SourceSpan.Undefined); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttribute_Duplicates = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9989", + () => "The attribute '{0}' was matched by multiple bind attributes. Duplicates:{1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttribute_Duplicates(SourceSpan? source, string attribute, TagHelperDirectiveAttributeIntermediateNode[] attributes) + { + var diagnostic = RazorDiagnostic.Create( + BindAttribute_Duplicates, + source ?? SourceSpan.Undefined, + attribute, + Environment.NewLine + string.Join(Environment.NewLine, attributes.Select(p => p.TagHelper.DisplayName))); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor EventHandler_Duplicates = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9990", + () => "The attribute '{0}' was matched by multiple event handler attributes. Duplicates:{1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateEventHandler_Duplicates(SourceSpan? source, string attribute, TagHelperDirectiveAttributeIntermediateNode[] attributes) + { + var diagnostic = RazorDiagnostic.Create( + EventHandler_Duplicates, + source ?? SourceSpan.Undefined, + attribute, + Environment.NewLine + string.Join(Environment.NewLine, attributes.Select(p => p.TagHelper.DisplayName))); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttribute_InvalidSyntax = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9991", + () => "The attribute names could not be inferred from bind attribute '{0}'. Bind attributes should be of the form " + + "'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttribute_InvalidSyntax(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttribute_InvalidSyntax, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor DisallowedScriptTag = new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9992", + () => "Script tags should not be placed inside components because they cannot be updated dynamically. To fix this, move the script tag to the 'index.html' file or another static location. For more information see https://go.microsoft.com/fwlink/?linkid=872131", + RazorDiagnosticSeverity.Error); + + // Reserved: BL9993 Component parameters should not be public + + public static RazorDiagnostic Create_DisallowedScriptTag(SourceSpan? source) + { + var diagnostic = RazorDiagnostic.Create(DisallowedScriptTag, source ?? SourceSpan.Undefined); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor TemplateInvalidLocation = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9994", + () => "Razor templates cannot be used in attributes.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_TemplateInvalidLocation(SourceSpan? source) + { + return RazorDiagnostic.Create(TemplateInvalidLocation, source ?? SourceSpan.Undefined); + } + + public static readonly RazorDiagnosticDescriptor ChildContentSetByAttributeAndBody = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9995", + () => "The child content property '{0}' is set by both the attribute and the element contents.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentSetByAttributeAndBody(SourceSpan? source, string attribute) + { + return RazorDiagnostic.Create(ChildContentSetByAttributeAndBody, source ?? SourceSpan.Undefined, attribute); + } + + public static readonly RazorDiagnosticDescriptor ChildContentMixedWithExplicitChildContent = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9996", + () => "Unrecognized child content inside component '{0}'. The component '{0}' accepts child content through the " + + "following top-level items: {1}.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentMixedWithExplicitChildContent(SourceSpan? source, ComponentIntermediateNode component) + { + var supportedElements = string.Join(", ", component.Component.GetChildContentProperties().Select(p => $"'{p.Name}'")); + return RazorDiagnostic.Create(ChildContentMixedWithExplicitChildContent, source ?? SourceSpan.Undefined, component.TagName, supportedElements); + } + + public static readonly RazorDiagnosticDescriptor ChildContentHasInvalidAttribute = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9997", + () => "Unrecognized attribute '{0}' on child content element '{1}'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentHasInvalidAttribute(SourceSpan? source, string attribute, string element) + { + return RazorDiagnostic.Create(ChildContentHasInvalidAttribute, source ?? SourceSpan.Undefined, attribute, element); + } + + public static readonly RazorDiagnosticDescriptor ChildContentHasInvalidParameter = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9998", + () => "Invalid parameter name. The parameter name attribute '{0}' on child content element '{1}' can only include literal text.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentHasInvalidParameter(SourceSpan? source, string attribute, string element) + { + return RazorDiagnostic.Create(ChildContentHasInvalidParameter, source ?? SourceSpan.Undefined, attribute, element); + } + + public static readonly RazorDiagnosticDescriptor ChildContentRepeatedParameterName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}9999", + () => "The child content element '{0}' of component '{1}' uses the same parameter name ('{2}') as enclosing child content " + + "element '{3}' of component '{4}'. Specify the parameter name like: '<{0} Context=\"another_name\"> to resolve the ambiguity", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentRepeatedParameterName( + SourceSpan? source, + ComponentChildContentIntermediateNode childContent1, + ComponentIntermediateNode component1, + ComponentChildContentIntermediateNode childContent2, + ComponentIntermediateNode component2) + { + Debug.Assert(childContent1.ParameterName == childContent2.ParameterName); + Debug.Assert(childContent1.IsParameterized); + Debug.Assert(childContent2.IsParameterized); + + return RazorDiagnostic.Create( + ChildContentRepeatedParameterName, + source ?? SourceSpan.Undefined, + childContent1.AttributeName, + component1.TagName, + childContent1.ParameterName, + childContent2.AttributeName, + component2.TagName); + } + + public static readonly RazorDiagnosticDescriptor GenericComponentMissingTypeArgument = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10000", + () => "The component '{0}' is missing required type arguments. Specify the missing types using the attributes: {1}.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_GenericComponentMissingTypeArgument( + SourceSpan? source, + ComponentIntermediateNode component, + IEnumerable attributes) + { + Debug.Assert(component.Component.IsGenericTypedComponent()); + + var attributesText = string.Join(", ", attributes.Select(a => $"'{a.Name}'")); + return RazorDiagnostic.Create(GenericComponentMissingTypeArgument, source ?? SourceSpan.Undefined, component.TagName, attributesText); + } + + public static readonly RazorDiagnosticDescriptor GenericComponentTypeInferenceUnderspecified = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10001", + () => "The type of component '{0}' cannot be inferred based on the values provided. Consider specifying the type arguments " + + "directly using the following attributes: {1}.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_GenericComponentTypeInferenceUnderspecified( + SourceSpan? source, + ComponentIntermediateNode component, + IEnumerable attributes) + { + Debug.Assert(component.Component.IsGenericTypedComponent()); + + var attributesText = string.Join(", ", attributes.Select(a => $"'{a.Name}'")); + return RazorDiagnostic.Create(GenericComponentTypeInferenceUnderspecified, source ?? SourceSpan.Undefined, component.TagName, attributesText); + } + + public static readonly RazorDiagnosticDescriptor ChildContentHasInvalidParameterOnComponent = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10002", + () => "Invalid parameter name. The parameter name attribute '{0}' on component '{1}' can only include literal text.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentHasInvalidParameterOnComponent(SourceSpan? source, string attribute, string element) + { + return RazorDiagnostic.Create(ChildContentHasInvalidParameterOnComponent, source ?? SourceSpan.Undefined, attribute, element); + } + + public static readonly RazorDiagnosticDescriptor UnsupportedComponentImportContent = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10003", + () => "Markup, code and block directives are not valid in component imports.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnsupportedComponentImportContent(SourceSpan? source) + { + return RazorDiagnostic.Create(UnsupportedComponentImportContent, source ?? SourceSpan.Undefined); + } + + public static readonly RazorDiagnosticDescriptor BindAttributeParameter_MissingBind = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10004", + () => "Could not find the non-parameterized bind attribute that corresponds to the attribute '{0}'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttributeParameter_MissingBind(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttributeParameter_MissingBind, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor DuplicateMarkupAttribute = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10007", + () => "The attribute '{0}' is used two or more times for this element. Attributes must be unique (case-insensitive).", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateMarkupAttribute(string attributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateMarkupAttribute, source ?? SourceSpan.Undefined, attributeName); + } + + public static readonly RazorDiagnosticDescriptor DuplicateMarkupAttributeDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10008", + () => + "The attribute '{0}' is used two or more times for this element. Attributes must be unique (case-insensitive). " + + "The attribute '{0}' is used by the '{1}' directive attribute.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateMarkupAttributeDirective(string attributeName, string directiveAttributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateMarkupAttributeDirective, source ?? SourceSpan.Undefined, attributeName, directiveAttributeName); + } + + public static readonly RazorDiagnosticDescriptor DuplicateComponentParameter = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10009", + () => "The component parameter '{0}' is used two or more times for this component. Parameters must be unique (case-insensitive).", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateComponentParameter(string attributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateComponentParameter, source ?? SourceSpan.Undefined, attributeName); + } + + public static readonly RazorDiagnosticDescriptor DuplicateComponentParameterDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10010", + () => + "The component parameter '{0}' is used two or more times for this component. Parameters must be unique (case-insensitive). " + + "The component parameter '{0}' is generated by the '{1}' directive attribute.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateComponentParameterDirective(string attributeName, string directiveAttributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateComponentParameterDirective, source ?? SourceSpan.Undefined, attributeName, directiveAttributeName); + } + + public static readonly RazorDiagnosticDescriptor ComponentNamesCannotStartWithLowerCase = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10011", + () => "Component '{0}' starts with a lowercase character. Component names cannot start with a lowercase character.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ComponentNamesCannotStartWithLowerCase(string componentName, SourceSpan? source = null) + { + return RazorDiagnostic.Create( + ComponentNamesCannotStartWithLowerCase, + source ?? SourceSpan.Undefined, + componentName); + } + + public static readonly RazorDiagnosticDescriptor UnexpectedMarkupElement = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10012", + () => "Found markup element with unexpected name '{0}'. If this is intended to be a component, add a @using directive for its namespace.", + RazorDiagnosticSeverity.Warning); + + public static RazorDiagnostic Create_UnexpectedMarkupElement(string elementName, SourceSpan? source = null) + { + return RazorDiagnostic.Create( + UnexpectedMarkupElement, + source ?? SourceSpan.Undefined, + elementName); + } + + public static readonly RazorDiagnosticDescriptor InconsistentStartAndEndTagName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10013", + () => "The start tag name '{0}' does not match the end tag name '{1}'. Components must have matching start and end tag names (case-sensitive).", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_InconsistentStartAndEndTagName(string startTagName, string endTagName, SourceSpan? source = null) + { + return RazorDiagnostic.Create( + InconsistentStartAndEndTagName, + source ?? SourceSpan.Undefined, + startTagName, + endTagName); + } + + public static readonly RazorDiagnosticDescriptor EventHandlerParameter_Duplicates = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10014", + () => "The attribute '{0}' was matched by multiple event handlers parameter attributes. Duplicates:{1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateEventHandlerParameter_Duplicates(SourceSpan? source, string attribute, TagHelperDirectiveAttributeParameterIntermediateNode[] attributes) + { + var diagnostic = RazorDiagnostic.Create( + EventHandlerParameter_Duplicates, + source ?? SourceSpan.Undefined, + attribute, + Environment.NewLine + string.Join(Environment.NewLine, attributes.Select(p => p.TagHelper.DisplayName))); + return diagnostic; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs new file mode 100644 index 0000000000..d1828ca044 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs @@ -0,0 +1,150 @@ +// 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.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentDocumentClassifierPass : DocumentClassifierPassBase + { + public static readonly string ComponentDocumentKind = "component.1.0"; + + /// + /// The fallback value of the root namespace. Only used if the fallback root namespace + /// was not passed in. + /// + public string FallbackRootNamespace { get; set; } = "__GeneratedComponent"; + + /// + /// Gets or sets whether to mangle class names. + /// + /// Set to true in the IDE so we can generated mangled class names. This is needed + /// to avoid conflicts between generated design-time code and the code in the editor. + /// + /// A better workaround for this would be to create a singlefilegenerator that overrides + /// the codegen process when a document is open, but this is more involved, so hacking + /// it for now. + /// + public bool MangleClassNames { get; set; } = false; + + protected override string DocumentKind => ComponentDocumentKind; + + // Ensure this runs before the MVC classifiers which have Order = 0 + public override int Order => -100; + + protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + return FileKinds.IsComponent(codeDocument.GetFileKind()); + } + + protected override CodeTarget CreateTarget(RazorCodeDocument codeDocument, RazorCodeGenerationOptions options) + { + return new ComponentCodeTarget(options, TargetExtensions); + } + + /// + protected override void OnDocumentStructureCreated( + RazorCodeDocument codeDocument, + NamespaceDeclarationIntermediateNode @namespace, + ClassDeclarationIntermediateNode @class, + MethodDeclarationIntermediateNode method) + { + if (!codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var computedNamespace) || + !TryComputeClassName(codeDocument, out var computedClass)) + { + // If we can't compute a nice namespace (no relative path) then just generate something + // mangled. + computedNamespace = FallbackRootNamespace; + var checksum = Checksum.BytesToString(codeDocument.Source.GetChecksum()); + computedClass = $"AspNetCore_{checksum}"; + } + + var documentNode = codeDocument.GetDocumentIntermediateNode(); + if (char.IsLower(computedClass, 0)) + { + // We don't allow component names to start with a lowercase character. + documentNode.Diagnostics.Add( + ComponentDiagnosticFactory.Create_ComponentNamesCannotStartWithLowerCase(computedClass, documentNode.Source)); + } + + if (MangleClassNames) + { + computedClass = ComponentMetadata.MangleClassName(computedClass); + } + + @namespace.Content = computedNamespace; + @class.ClassName = computedClass; + @class.Modifiers.Clear(); + @class.Modifiers.Add("public"); + @class.Modifiers.Add("partial"); + + if (FileKinds.IsComponentImport(codeDocument.GetFileKind())) + { + // We don't want component imports to be considered as real component. + // But we still want to generate code for it so we can get diagnostics. + @class.BaseType = typeof(object).FullName; + + method.ReturnType = "void"; + method.MethodName = "Execute"; + method.Modifiers.Clear(); + method.Modifiers.Add("protected"); + + method.Parameters.Clear(); + } + else + { + @class.BaseType = ComponentsApi.ComponentBase.FullTypeName; + + var typeParamReferences = documentNode.FindDirectiveReferences(ComponentTypeParamDirective.Directive); + for (var i = 0; i < typeParamReferences.Count; i++) + { + var typeParamNode = (DirectiveIntermediateNode)typeParamReferences[i].Node; + if (typeParamNode.HasDiagnostics) + { + continue; + } + + @class.TypeParameters.Add(new TypeParameter() { ParameterName = typeParamNode.Tokens.First().Content, }); + } + + method.ReturnType = "void"; + method.MethodName = ComponentsApi.ComponentBase.BuildRenderTree; + method.Modifiers.Clear(); + method.Modifiers.Add("protected"); + method.Modifiers.Add("override"); + + method.Parameters.Clear(); + method.Parameters.Add(new MethodParameter() + { + ParameterName = ComponentsApi.RenderTreeBuilder.BuilderParameter, + TypeName = ComponentsApi.RenderTreeBuilder.FullTypeName, + }); + } + } + + private bool TryComputeClassName(RazorCodeDocument codeDocument, out string className) + { + className = null; + if (codeDocument.Source.FilePath == null || codeDocument.Source.RelativePath == null) + { + return false; + } + + var relativePath = NormalizePath(codeDocument.Source.RelativePath); + className = CSharpIdentifier.SanitizeIdentifier(Path.GetFileNameWithoutExtension(relativePath)); + return true; + } + + private static string NormalizePath(string path) + { + path = path.Replace('\\', '/'); + + return path; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs new file mode 100644 index 0000000000..83936bf28d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs @@ -0,0 +1,113 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal sealed class ComponentMarkupDiagnosticPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + public static readonly int DefaultOrder = 10000; + + public override int Order => DefaultOrder; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + var visitor = new Visitor(); + visitor.Visit(documentNode); + } + + private class Visitor : IntermediateNodeWalker + { + private Dictionary _attributes = new Dictionary(StringComparer.OrdinalIgnoreCase); + + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is HtmlAttributeIntermediateNode attribute && attribute.AttributeName != null) + { + if (_attributes.TryGetValue(attribute.AttributeName, out var other)) + { + // As a special case we want to point it out explicitly where a directive or other construct + // has emitted an attribute that causes a conflict. We're already looking at the lowered version + // of this construct, so it's easy to detect. We just need the original name to report the issue. + // + // Example: `bind-value` will set `value` and `onchange`. + + var originalAttributeName = + attribute.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string ?? + other.node.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string; + if (originalAttributeName != null) + { + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateMarkupAttributeDirective( + other.name, + originalAttributeName, + other.node.Source ?? node.Source)); + } + else + { + // This is a conflict in the code the user wrote. + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateMarkupAttribute( + other.name, + other.node.Source ?? node.Source)); + } + } + + // Replace the attribute we were previously tracking. Then if you have three, the two on the left will have + // diagnostics. + _attributes[attribute.AttributeName] = (attribute.AttributeName, attribute); + } + } + + _attributes.Clear(); + base.VisitMarkupElement(node); + } + + public override void VisitComponent(ComponentIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + // Note that we don't handle ChildContent cases here. Those have their own pass for diagnostics. + if (node.Children[i] is ComponentAttributeIntermediateNode attribute && attribute.AttributeName != null) + { + if (_attributes.TryGetValue(attribute.AttributeName, out var other)) + { + // As a special case we want to point it out explicitly where a directive or other construct + // has emitted an attribute that causes a conflict. We're already looking at the lowered version + // of this construct, so it's easy to detect. We just need the original name to report the issue. + // + // Example: `bind-Value` will set `Value` and `ValueChanged`. + var originalAttributeName = + attribute.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string ?? + other.node.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string; + if (originalAttributeName != null) + { + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateComponentParameterDirective( + other.name, + originalAttributeName, + other.node.Source ?? node.Source)); + } + else + { + // This is a conflict in the code the user wrote. + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateComponentParameter( + other.name, + other.node.Source ?? node.Source)); + } + } + + // Replace the attribute we were previously tracking. Then if you have three, the two on the left will have + // diagnostics. + _attributes[attribute.AttributeName] = (attribute.AttributeName, attribute); + } + } + + _attributes.Clear(); + base.VisitComponent(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs new file mode 100644 index 0000000000..2e72dfe397 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs @@ -0,0 +1,312 @@ +// 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.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentEventHandlerLoweringPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + public override int Order => 50; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + 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; + } + + // For each event handler *usage* we need to rewrite the tag helper node to map to basic constructs. + // Each usage will be represented by a tag helper property that is a descendant of either + // a component or element. + var references = documentNode.FindDescendantReferences(); + var parents = new HashSet(); + for (var i = 0; i < references.Count; i++) + { + parents.Add(references[i].Parent); + } + + // We need to do something similar for directive attribute parameters like @onclick:preventDefault. + var parameterReferences = documentNode.FindDescendantReferences(); + for (var i = 0; i < parameterReferences.Count; i++) + { + parents.Add(parameterReferences[i].Parent); + } + + foreach (var parent in parents) + { + ProcessDuplicates(parent); + } + + for (var i = 0; i < references.Count; i++) + { + var reference = references[i]; + var node = (TagHelperDirectiveAttributeIntermediateNode)reference.Node; + + if (!reference.Parent.Children.Contains(node)) + { + // This node was removed as a duplicate, skip it. + continue; + } + + if (node.TagHelper.IsEventHandlerTagHelper()) + { + reference.Replace(RewriteUsage(reference.Parent, node)); + } + } + + for (var i = 0; i < parameterReferences.Count; i++) + { + var reference = parameterReferences[i]; + var node = (TagHelperDirectiveAttributeParameterIntermediateNode)reference.Node; + + if (!reference.Parent.Children.Contains(node)) + { + // This node was removed as a duplicate, skip it. + continue; + } + + if (node.TagHelper.IsEventHandlerTagHelper()) + { + reference.Replace(RewriteParameterUsage(reference.Parent, node)); + } + } + } + + private void ProcessDuplicates(IntermediateNode parent) + { + // Reverse order because we will remove nodes. + // + // Each 'property' node could be duplicated if there are multiple tag helpers that match that + // particular attribute. This is likely to happen when a component also defines something like + // OnClick. We want to remove the 'onclick' and let it fall back to be handled by the component. + for (var i = parent.Children.Count - 1; i >= 0; i--) + { + var eventHandler = parent.Children[i] as TagHelperPropertyIntermediateNode; + if (eventHandler != null && + eventHandler.TagHelper != null && + eventHandler.TagHelper.IsEventHandlerTagHelper()) + { + for (var j = 0; j < parent.Children.Count; j++) + { + var componentAttribute = parent.Children[j] as ComponentAttributeIntermediateNode; + if (componentAttribute != null && + componentAttribute.TagHelper != null && + componentAttribute.TagHelper.IsComponentTagHelper() && + componentAttribute.AttributeName == eventHandler.AttributeName) + { + // Found a duplicate - remove the 'fallback' in favor of the component's own handling. + parent.Children.RemoveAt(i); + break; + } + } + } + } + + // If we still have duplicates at this point then they are genuine conflicts. + var duplicates = parent.Children + .OfType() + .Where(p => p.TagHelper?.IsEventHandlerTagHelper() ?? false) + .GroupBy(p => p.AttributeName) + .Where(g => g.Count() > 1); + + foreach (var duplicate in duplicates) + { + parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateEventHandler_Duplicates( + parent.Source, + duplicate.Key, + duplicate.ToArray())); + foreach (var property in duplicate) + { + parent.Children.Remove(property); + } + } + + var parameterDuplicates = parent.Children + .OfType() + .Where(p => p.TagHelper?.IsEventHandlerTagHelper() ?? false) + .GroupBy(p => p.AttributeName) + .Where(g => g.Count() > 1); + + foreach (var duplicate in parameterDuplicates) + { + parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateEventHandlerParameter_Duplicates( + parent.Source, + duplicate.Key, + duplicate.ToArray())); + foreach (var property in duplicate) + { + parent.Children.Remove(property); + } + } + } + + private IntermediateNode RewriteUsage(IntermediateNode parent, TagHelperDirectiveAttributeIntermediateNode node) + { + var original = GetAttributeContent(node); + if (original.Count == 0) + { + // This can happen in error cases, the parser will already have flagged this + // as an error, so ignore it. + return node; + } + + // Now rewrite the content of the value node to look like: + // + // EventCallback.Factory.Create(this, ) + // + // This method is overloaded on string and T, which means that it will put the code in the + // correct context for intellisense when typing in the attribute. + var eventArgsType = node.TagHelper.GetEventArgsType(); + var tokens = new List() + { + new IntermediateToken() + { + Content = $"{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}<{eventArgsType}>(this, ", + Kind = TokenKind.CSharp + }, + new IntermediateToken() + { + Content = $")", + Kind = TokenKind.CSharp + } + }; + + for (var i = 0; i < original.Count; i++) + { + tokens.Insert(i + 1, original[i]); + } + + var attributeName = node.AttributeName; + + if (parent is MarkupElementIntermediateNode) + { + var result = new HtmlAttributeIntermediateNode() + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = attributeName, + Source = node.Source, + + Prefix = attributeName + "=\"", + Suffix = "\"", + }; + + for (var i = 0; i < node.Diagnostics.Count; i++) + { + result.Diagnostics.Add(node.Diagnostics[i]); + } + + result.Children.Add(new CSharpExpressionAttributeValueIntermediateNode()); + for (var i = 0; i < tokens.Count; i++) + { + result.Children[0].Children.Add(tokens[i]); + } + + return result; + } + else + { + var result = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + }; + + result.Children.Clear(); + result.Children.Add(new CSharpExpressionIntermediateNode()); + for (var i = 0; i < tokens.Count; i++) + { + result.Children[0].Children.Add(tokens[i]); + } + + return result; + } + } + + private static IReadOnlyList GetAttributeContent(IntermediateNode node) + { + var template = node.FindDescendantNodes().FirstOrDefault(); + if (template != null) + { + // See comments in TemplateDiagnosticPass + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_TemplateInvalidLocation(template.Source)); + return new[] { new IntermediateToken() { Kind = TokenKind.CSharp, Content = string.Empty, }, }; + } + + if (node.Children.Count == 1 && node.Children[0] is HtmlContentIntermediateNode htmlContentNode) + { + // This case can be hit for a 'string' attribute. We want to turn it into + // an expression. + var tokens = htmlContentNode.FindDescendantNodes(); + + var content = "\"" + string.Join(string.Empty, tokens.Select(t => t.Content.Replace("\"", "\\\""))) + "\""; + return new[] { new IntermediateToken() { Content = content, Kind = TokenKind.CSharp, } }; + } + else + { + return node.FindDescendantNodes(); + } + } + + private IntermediateNode RewriteParameterUsage(IntermediateNode parent, TagHelperDirectiveAttributeParameterIntermediateNode node) + { + // Now rewrite the node to look like: + // + // builder.AddEventPreventDefaultAttribute(2, "onclick", true); // If minimized. + // or + // builder.AddEventPreventDefaultAttribute(2, "onclick", someBoolExpression); // If a bool expression is provided in the value. + + string eventHandlerMethod; + if (node.BoundAttributeParameter.Name == "preventDefault") + { + eventHandlerMethod = ComponentsApi.RenderTreeBuilder.AddEventPreventDefaultAttribute; + } + else if (node.BoundAttributeParameter.Name == "stopPropagation") + { + eventHandlerMethod = ComponentsApi.RenderTreeBuilder.AddEventStopPropagationAttribute; + } + else + { + // Unsupported event handler attribute parameter. This can only happen if bound attribute descriptor + // is configured to expect a parameter other than 'preventDefault' and 'stopPropagation'. + return node; + } + + var result = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + [ComponentMetadata.Common.AddAttributeMethodName] = eventHandlerMethod, + }, + }; + + result.Children.Clear(); + if (node.AttributeStructure != AttributeStructure.Minimized) + { + var tokens = GetAttributeContent(node); + result.Children.Add(new CSharpExpressionIntermediateNode()); + result.Children[0].Children.AddRange(tokens); + } + + return result; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs new file mode 100644 index 0000000000..09ba98516f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentGenericTypePass.cs @@ -0,0 +1,341 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + // This pass: + // 1. Adds diagnostics for missing generic type arguments + // 2. Rewrites the type name of the component to substitute generic type arguments + // 3. Rewrites the type names of parameters/child content to substitute generic type arguments + internal class ComponentGenericTypePass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + private TypeNameFeature _typeNameFeature; + + // Runs after components/eventhandlers/ref/bind/templates. We want to validate every component + // and it's usage of ChildContent. + public override int Order => 160; + + private TypeNameFeature TypeNameFeature + { + get + { + // Doing lazy intialization here to avoid making things really complicated when we don't + // need to exercise this code in tests. + if (_typeNameFeature == null) + { + _typeNameFeature = GetRequiredFeature(); + } + + return _typeNameFeature; + } + } + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + var visitor = new Visitor(this); + visitor.Visit(documentNode); + } + + private class Visitor : IntermediateNodeWalker + { + private readonly ComponentGenericTypePass _pass; + + // Incrementing ID for type inference method names + private int _id; + + public Visitor(ComponentGenericTypePass pass) + { + _pass = pass; + } + + public override void VisitComponent(ComponentIntermediateNode node) + { + if (node.Component.IsGenericTypedComponent()) + { + // Not generic, ignore. + Process(node); + } + + base.VisitDefault(node); + } + + private void Process(ComponentIntermediateNode node) + { + // First collect all of the information we have about each type parameter + // + // Listing all type parameters that exist + var bindings = new Dictionary(); + foreach (var attribute in node.Component.GetTypeParameters()) + { + bindings.Add(attribute.Name, new Binding() { Attribute = attribute, }); + } + + // Listing all type arguments that have been specified. + var hasTypeArgumentSpecified = false; + foreach (var typeArgumentNode in node.TypeArguments) + { + hasTypeArgumentSpecified = true; + + var binding = bindings[typeArgumentNode.TypeParameterName]; + binding.Node = typeArgumentNode; + binding.Content = GetContent(typeArgumentNode); + } + + if (hasTypeArgumentSpecified) + { + // OK this means that the developer has specified at least one type parameter. + // Either they specified everything and its OK to rewrite, or its an error. + if (ValidateTypeArguments(node, bindings)) + { + var mappings = bindings.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Content); + RewriteTypeNames(_pass.TypeNameFeature.CreateGenericTypeRewriter(mappings), node); + } + + return; + } + + // OK if we get here that means that no type arguments were specified, so we will try to infer + // the type. + // + // The actual inference is done by the C# compiler, we just emit an a method that represents the + // use of this component. + + // Since we're generating code in a different namespace, we need to 'global qualify' all of the types + // to avoid clashes with our generated code. + RewriteTypeNames(_pass.TypeNameFeature.CreateGlobalQualifiedTypeNameRewriter(bindings.Keys), node); + + // + // We need to verify that an argument was provided that 'covers' each type parameter. + // + // For example, consider a repeater where the generic type is the 'item' type, but the developer has + // not set the items. We won't be able to do type inference on this and so it will just be nonsense. + var attributes = node.Attributes.Select(a => a.BoundAttribute).Concat(node.ChildContents.Select(c => c.BoundAttribute)); + foreach (var attribute in attributes) + { + if (attribute == null) + { + // Will be null for attributes set on the component that don't match a declared component parameter + continue; + } + + // Now we need to parse the type name and extract the generic parameters. + // + // Two cases; + // 1. name is a simple identifier like TItem + // 2. name contains type parameters like Dictionary + if (!attribute.IsGenericTypedProperty()) + { + continue; + } + + var typeParameters = _pass.TypeNameFeature.ParseTypeParameters(attribute.TypeName); + if (typeParameters.Count == 0) + { + bindings.Remove(attribute.TypeName); + } + else + { + for (var i = 0; i < typeParameters.Count; i++) + { + var typeParameter = typeParameters[i]; + bindings.Remove(typeParameter.ToString()); + } + } + } + + // If any bindings remain then this means we would never be able to infer the arguments of this + // component usage because the user hasn't set properties that include all of the types. + if (bindings.Count > 0) + { + // However we still want to generate 'type inference' code because we want the errors to be as + // helpful as possible. So let's substitute 'object' for all of those type parameters, and add + // an error. + var mappings = bindings.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Content); + RewriteTypeNames(_pass.TypeNameFeature.CreateGenericTypeRewriter(mappings), node); + + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_GenericComponentTypeInferenceUnderspecified(node.Source, node, node.Component.GetTypeParameters())); + } + + // Next we need to generate a type inference 'method' node. This represents a method that we will codegen that + // contains all of the operations on the render tree building. Calling a method to operate on the builder + // will allow the C# compiler to perform type inference. + var documentNode = (DocumentIntermediateNode)Ancestors[Ancestors.Count - 1]; + CreateTypeInferenceMethod(documentNode, node); + } + + private string GetContent(ComponentTypeArgumentIntermediateNode node) + { + return string.Join(string.Empty, node.FindDescendantNodes().Where(t => t.IsCSharp).Select(t => t.Content)); + } + + private static bool ValidateTypeArguments(ComponentIntermediateNode node, Dictionary bindings) + { + var missing = new List(); + foreach (var binding in bindings) + { + if (binding.Value.Node == null || string.IsNullOrWhiteSpace(binding.Value.Content)) + { + missing.Add(binding.Value.Attribute); + } + } + + if (missing.Count > 0) + { + // We add our own error for this because its likely the user will see other errors due + // to incorrect codegen without the types. Our errors message will pretty clearly indicate + // what to do, whereas the other errors might be confusing. + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_GenericComponentMissingTypeArgument(node.Source, node, missing)); + return false; + } + + return true; + } + + private void RewriteTypeNames(TypeNameRewriter rewriter, ComponentIntermediateNode node) + { + // Rewrite the component type name + node.TypeName = rewriter.Rewrite(node.TypeName); + + foreach (var attribute in node.Attributes) + { + string globallyQualifiedTypeName = null; + + if (attribute.TypeName != null) + { + globallyQualifiedTypeName = rewriter.Rewrite(attribute.TypeName); + attribute.GloballyQualifiedTypeName = globallyQualifiedTypeName; + } + + if (attribute.BoundAttribute?.IsGenericTypedProperty() ?? false && attribute.TypeName != null) + { + // If we know the type name, then replace any generic type parameter inside it with + // the known types. + attribute.TypeName = globallyQualifiedTypeName; + } + else if (attribute.TypeName == null && (attribute.BoundAttribute?.IsDelegateProperty() ?? false)) + { + // This is a weakly typed delegate, treat it as Action + attribute.TypeName = "System.Action"; + } + else if (attribute.TypeName == null && (attribute.BoundAttribute?.IsEventCallbackProperty() ?? false)) + { + // This is a weakly typed event-callback, treat it as EventCallback (non-generic) + attribute.TypeName = ComponentsApi.EventCallback.FullTypeName; + } + else if (attribute.TypeName == null) + { + // This is a weakly typed attribute, treat it as System.Object + attribute.TypeName = "System.Object"; + } + } + + foreach (var capture in node.Captures) + { + if (capture.IsComponentCapture && capture.ComponentCaptureTypeName != null) + { + capture.ComponentCaptureTypeName = rewriter.Rewrite(capture.ComponentCaptureTypeName); + } + else if (capture.IsComponentCapture) + { + capture.ComponentCaptureTypeName = "System.Object"; + } + } + + foreach (var childContent in node.ChildContents) + { + if (childContent.BoundAttribute?.IsGenericTypedProperty() ?? false && childContent.TypeName != null) + { + // If we know the type name, then replace any generic type parameter inside it with + // the known types. + childContent.TypeName = rewriter.Rewrite(childContent.TypeName); + } + else if (childContent.IsParameterized) + { + // This is a non-generic parameterized child content like RenderFragment, leave it as is. + } + else + { + // This is a weakly typed child content, treat it as RenderFragment + childContent.TypeName = ComponentsApi.RenderFragment.FullTypeName; + } + } + } + + private void CreateTypeInferenceMethod(DocumentIntermediateNode documentNode, ComponentIntermediateNode node) + { + var @namespace = documentNode.FindPrimaryNamespace().Content; + @namespace = string.IsNullOrEmpty(@namespace) ? "__Blazor" : "__Blazor." + @namespace; + @namespace += "." + documentNode.FindPrimaryClass().ClassName; + + var typeInferenceNode = new ComponentTypeInferenceMethodIntermediateNode() + { + Component = node, + + // Method name is generated and guaranteed not to collide, since it's unique for each + // component call site. + MethodName = $"Create{CSharpIdentifier.SanitizeIdentifier(node.TagName)}_{_id++}", + FullTypeName = @namespace + ".TypeInference", + }; + + node.TypeInferenceNode = typeInferenceNode; + + // Now we need to insert the type inference node into the tree. + var namespaceNode = documentNode.Children + .OfType() + .Where(n => n.Annotations.Contains(new KeyValuePair(ComponentMetadata.Component.GenericTypedKey, bool.TrueString))) + .FirstOrDefault(); + if (namespaceNode == null) + { + namespaceNode = new NamespaceDeclarationIntermediateNode() + { + Annotations = + { + { ComponentMetadata.Component.GenericTypedKey, bool.TrueString }, + }, + Content = @namespace, + }; + + documentNode.Children.Add(namespaceNode); + } + + var classNode = namespaceNode.Children + .OfType() + .Where(n => n.ClassName == "TypeInference") + .FirstOrDefault(); + if (classNode == null) + { + classNode = new ClassDeclarationIntermediateNode() + { + ClassName = "TypeInference", + Modifiers = + { + "internal", + "static", + }, + }; + namespaceNode.Children.Add(classNode); + } + + classNode.Children.Add(typeInferenceNode); + } + } + + private class Binding + { + public BoundAttributeDescriptor Attribute { get; set; } + + public string Content { get; set; } + + public ComponentTypeArgumentIntermediateNode Node { get; set; } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentImportProjectFeature.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentImportProjectFeature.cs new file mode 100644 index 0000000000..2e689044de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentImportProjectFeature.cs @@ -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.IO; +using System.Linq; +using System.Text; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentImportProjectFeature : IImportProjectFeature + { + private static readonly char[] PathSeparators = new char[]{ '/', '\\' }; + + // Using explicit newlines here to avoid fooling our baseline tests + private readonly static string DefaultUsingImportContent = + "\r\n" + + "@using System\r\n" + + "@using System.Collections.Generic\r\n" + + "@using System.Linq\r\n" + + "@using System.Threading.Tasks\r\n" + + "@using " + ComponentsApi.RenderFragment.Namespace + "\r\n"; // Microsoft.AspNetCore.Components + + public RazorProjectEngine ProjectEngine { get; set; } + + public IReadOnlyList GetImports(RazorProjectItem projectItem) + { + if (projectItem == null) + { + throw new ArgumentNullException(nameof(projectItem)); + } + + // Don't add Component imports for a non-component. + if (!FileKinds.IsComponent(projectItem.FileKind)) + { + return Array.Empty(); + } + + var imports = new List() + { + new VirtualProjectItem(DefaultUsingImportContent), + }; + + // We add hierarchical imports second so any default directive imports can be overridden. + imports.AddRange(GetHierarchicalImports(ProjectEngine.FileSystem, projectItem)); + + return imports; + } + + // Temporary API until we fully convert to RazorProjectEngine + public IEnumerable GetHierarchicalImports(RazorProject project, RazorProjectItem projectItem) + { + // We want items in descending order. FindHierarchicalItems returns items in ascending order. + return project.FindHierarchicalItems(projectItem.FilePath, ComponentMetadata.ImportsFileName).Reverse(); + } + + private class VirtualProjectItem : RazorProjectItem + { + private readonly byte[] _bytes; + + public VirtualProjectItem(string content) + { + var preamble = Encoding.UTF8.GetPreamble(); + var contentBytes = Encoding.UTF8.GetBytes(content); + + _bytes = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(_bytes, 0); + contentBytes.CopyTo(_bytes, preamble.Length); + } + + public override string BasePath => null; + + public override string FilePath => null; + + public override string PhysicalPath => null; + + public override bool Exists => true; + + public override string FileKind => FileKinds.ComponentImport; + + public override Stream Read() => new MemoryStream(_bytes); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectDirective.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectDirective.cs new file mode 100644 index 0000000000..1af26eb508 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectDirective.cs @@ -0,0 +1,36 @@ +// 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.Razor.Language.Components +{ + // Much of the following is equivalent to Microsoft.AspNetCore.Mvc.Razor.Extensions's InjectDirective, + // but this one outputs properties annotated for Components's property injector, plus it doesn't need to + // support multiple CodeTargets. + + internal class ComponentInjectDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "inject", + DirectiveKind.SingleLine, + builder => + { + builder.AddTypeToken("TypeName", "The type of the service to inject."); + builder.AddMemberToken("PropertyName", "The name of the property."); + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.Description = "Inject a service from the application's service container into a property."; + }); + + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive, FileKinds.Component, FileKinds.ComponentImport); + builder.Features.Add(new ComponentInjectDirectivePass()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectDirectivePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectDirectivePass.cs new file mode 100644 index 0000000000..6ad554b03a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectDirectivePass.cs @@ -0,0 +1,58 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentInjectDirectivePass : IntermediateNodePassBase, IRazorDirectiveClassifierPass + { + protected override void ExecuteCore( + RazorCodeDocument codeDocument, + DocumentIntermediateNode documentNode) + { + var visitor = new Visitor(); + visitor.Visit(documentNode); + + var properties = new HashSet(StringComparer.Ordinal); + var classNode = documentNode.FindPrimaryClass(); + + 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; + } + + classNode.Children.Add(new ComponentInjectIntermediateNode(typeName, memberName)); + } + } + + private class Visitor : IntermediateNodeWalker + { + public IList Directives { get; } + = new List(); + + public override void VisitDirective(DirectiveIntermediateNode node) + { + if (node.Directive == ComponentInjectDirective.Directive) + { + Directives.Add(node); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectIntermediateNode.cs new file mode 100644 index 0000000000..ee0363fd7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentInjectIntermediateNode.cs @@ -0,0 +1,60 @@ +// 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentInjectIntermediateNode : ExtensionIntermediateNode + { + private static readonly IList _injectedPropertyModifiers = new[] + { + $"[global::{ComponentsApi.InjectAttribute.FullTypeName}]", + "private" // Encapsulation is the default + }; + + public ComponentInjectIntermediateNode(string typeName, string memberName) + { + TypeName = typeName; + MemberName = memberName; + } + + public string TypeName { get; } + + public string MemberName { get; } + + public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; + + + public override void Accept(IntermediateNodeVisitor visitor) + { + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(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)); + } + + context.CodeWriter.WriteAutoPropertyDeclaration( + _injectedPropertyModifiers, + TypeName, + MemberName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentIntermediateNodePassBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentIntermediateNodePassBase.cs new file mode 100644 index 0000000000..5aa169ff4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentIntermediateNodePassBase.cs @@ -0,0 +1,21 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal abstract class ComponentIntermediateNodePassBase : IntermediateNodePassBase + { + protected bool IsComponentDocument(DocumentIntermediateNode document) + { + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + + return string.Equals(document.DocumentKind, ComponentDocumentClassifierPass.ComponentDocumentKind, StringComparison.Ordinal); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentKeyLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentKeyLoweringPass.cs new file mode 100644 index 0000000000..1787003101 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentKeyLoweringPass.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentKeyLoweringPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Run after component lowering pass + public override int Order => 50; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + 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 references = documentNode.FindDescendantReferences(); + for (var i = 0; i < references.Count; i++) + { + var reference = references[i]; + var node = (TagHelperDirectiveAttributeIntermediateNode)reference.Node; + + if (node.TagHelper.IsKeyTagHelper()) + { + reference.Replace(RewriteUsage(reference.Parent, node)); + } + } + } + + private IntermediateNode RewriteUsage(IntermediateNode parent, TagHelperDirectiveAttributeIntermediateNode node) + { + // If we can't get a nonempty attribute value, do nothing because there will + // already be a diagnostic for empty values + var keyValueToken = DetermineKeyValueToken(node); + if (keyValueToken == null) + { + return node; + } + + return new SetKeyIntermediateNode(keyValueToken); + } + + private IntermediateToken DetermineKeyValueToken(TagHelperDirectiveAttributeIntermediateNode attributeNode) + { + IntermediateToken foundToken = null; + + if (attributeNode.Children.Count == 1) + { + if (attributeNode.Children[0] is IntermediateToken token) + { + foundToken = token; + } + else if (attributeNode.Children[0] is CSharpExpressionIntermediateNode csharpNode) + { + if (csharpNode.Children.Count == 1) + { + foundToken = csharpNode.Children[0] as IntermediateToken; + } + } + } + + return !string.IsNullOrWhiteSpace(foundToken?.Content) ? foundToken : null; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLayoutDirective.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLayoutDirective.cs new file mode 100644 index 0000000000..394bed3b56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLayoutDirective.cs @@ -0,0 +1,31 @@ +// 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.Razor.Language.Components +{ + internal static class ComponentLayoutDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "layout", + DirectiveKind.SingleLine, + builder => + { + builder.AddTypeToken(ComponentResources.LayoutDirective_TypeToken_Name, ComponentResources.LayoutDirective_TypeToken_Description); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.Description = ComponentResources.LayoutDirective_Description; + }); + + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive, FileKinds.Component, FileKinds.ComponentImport); + builder.Features.Add(new ComponentLayoutDirectivePass()); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLayoutDirectivePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLayoutDirectivePass.cs new file mode 100644 index 0000000000..244c95df78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLayoutDirectivePass.cs @@ -0,0 +1,51 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentLayoutDirectivePass : IntermediateNodePassBase, IRazorDirectiveClassifierPass + { + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + var @namespace = documentNode.FindPrimaryNamespace(); + var @class = documentNode.FindPrimaryClass(); + if (@namespace == null || @class == null) + { + return; + } + + var directives = documentNode.FindDirectiveReferences(ComponentLayoutDirective.Directive); + if (directives.Count == 0) + { + return; + } + + var token = ((DirectiveIntermediateNode)directives[0].Node).Tokens.FirstOrDefault(); + if (token == null) + { + return; + } + + var attributeNode = new CSharpCodeIntermediateNode(); + attributeNode.Children.Add(new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"[{ComponentsApi.LayoutAttribute.FullTypeName}(typeof({token.Content}))]", + }); + + // Insert the new attribute on top of the class + for (var i = 0; i < @namespace.Children.Count; i++) + { + if (object.ReferenceEquals(@namespace.Children[i], @class)) + { + @namespace.Children.Insert(i, attributeNode); + break; + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs new file mode 100644 index 0000000000..3a7e3c748e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs @@ -0,0 +1,520 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentLoweringPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // This pass runs earlier than our other passes that 'lower' specific kinds of attributes. + public override int Order => 0; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + 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; + } + + // For each component *usage* we need to rewrite the tag helper node to map to the relevant component + // APIs. + var references = documentNode.FindDescendantReferences(); + for (var i = 0; i < references.Count; i++) + { + var reference = references[i]; + var node = (TagHelperIntermediateNode)reference.Node; + if (node.TagHelpers.Any(t => t.IsChildContentTagHelper())) + { + // This is a child content tag helper. This will be rewritten when we visit its parent. + continue; + } + + // The element didn't match any child content descriptors. Look for any matching component descriptors. + var count = 0; + for (var j = 0; j < node.TagHelpers.Count; j++) + { + if (node.TagHelpers[j].IsComponentTagHelper()) + { + // Only allow a single component tag helper per element. If there are multiple, we'll just consider + // the first one and ignore the others. + if (++count > 1) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.Create_MultipleComponents(node.Source, node.TagName, node.TagHelpers)); + break; + } + } + } + + if (count >= 1) + { + reference.Replace(RewriteAsComponent(node, node.TagHelpers.First(t => t.IsComponentTagHelper()))); + } + else + { + reference.Replace(RewriteAsElement(node)); + } + } + } + + private ComponentIntermediateNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper) + { + var component = new ComponentIntermediateNode() + { + Component = tagHelper, + Source = node.Source, + TagName = node.TagName, + TypeName = tagHelper.GetTypeName(), + }; + + for (var i = 0; i < node.Diagnostics.Count; i++) + { + component.Diagnostics.Add(node.Diagnostics[i]); + } + + var visitor = new ComponentRewriteVisitor(component); + visitor.Visit(node); + + // Fixup the parameter names of child content elements. We can't do this during the rewrite + // because we see the nodes in the wrong order. + foreach (var childContent in component.ChildContents) + { + childContent.ParameterName = childContent.ParameterName ?? component.ChildContentParameterName ?? ComponentMetadata.ChildContent.DefaultParameterName; + } + + return component; + } + + private MarkupElementIntermediateNode RewriteAsElement(TagHelperIntermediateNode node) + { + var result = new MarkupElementIntermediateNode() + { + Source = node.Source, + TagName = node.TagName, + }; + + for (var i = 0; i < node.Diagnostics.Count; i++) + { + result.Diagnostics.Add(node.Diagnostics[i]); + } + + var visitor = new ElementRewriteVisitor(result.Children); + visitor.Visit(node); + + return result; + } + + private class ComponentRewriteVisitor : IntermediateNodeWalker + { + private readonly ComponentIntermediateNode _component; + private readonly IntermediateNodeCollection _children; + + public ComponentRewriteVisitor(ComponentIntermediateNode component) + { + _component = component; + _children = component.Children; + } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + // Visit children, we're replacing this node. + base.VisitDefault(node); + } + + public override void VisitTagHelperBody(TagHelperBodyIntermediateNode node) + { + // Wrap the component's children in a ChildContent node if we have some significant + // content. + if (node.Children.Count == 0) + { + return; + } + + // If we get a single HTML content node containing only whitespace, + // then this is probably a tag that looks like ' + // + // We don't want to create a child content for this case, because it can conflict + // with a child content that's set via an attribute. We don't want the formatting + // of insignificant whitespace to be annoying when setting attributes directly. + if (node.Children.Count == 1 && IsIgnorableWhitespace(node.Children[0])) + { + return; + } + + // From here we fork and behave differently based on whether the component's child content is + // implicit or explicit. + // + // Explicit child content will look like:
...
+ // compared with implicit:
+ // + // Using implicit child content: + // 1. All content is grouped into a single child content lambda, and assigned to the property 'ChildContent' + // + // Using explicit child content: + // 1. All content must be contained within 'child content' elements that are direct children + // 2. Whitespace outside of 'child content' elements will be ignored (not an error) + // 3. Non-whitespace outside of 'child content' elements will cause an error + // 4. All 'child content' elements must match parameters on the component (exception for ChildContent, + // which is always allowed. + // 5. Each 'child content' element will generate its own lambda, and be assigned to the property + // that matches the element name. + if (!node.Children.OfType().Any(t => t.TagHelpers.Any(th => th.IsChildContentTagHelper()))) + { + // This node has implicit child content. It may or may not have an attribute that matches. + var attribute = _component.Component.BoundAttributes + .Where(a => string.Equals(a.Name, ComponentsApi.RenderTreeBuilder.ChildContent, StringComparison.Ordinal)) + .FirstOrDefault(); + _children.Add(RewriteChildContent(attribute, node.Source, node.Children)); + return; + } + + // OK this node has explicit child content, we can rewrite it by visiting each node + // in sequence, since we: + // a) need to rewrite each child content element + // b) any significant content outside of a child content is an error + for (var i = 0; i < node.Children.Count; i++) + { + var child = node.Children[i]; + if (IsIgnorableWhitespace(child)) + { + continue; + } + + if (child is TagHelperIntermediateNode tagHelperNode && + tagHelperNode.TagHelpers.Any(th => th.IsChildContentTagHelper())) + { + // This is a child content element + var attribute = _component.Component.BoundAttributes + .Where(a => string.Equals(a.Name, tagHelperNode.TagName, StringComparison.Ordinal)) + .FirstOrDefault(); + _children.Add(RewriteChildContent(attribute, child.Source, child.Children)); + continue; + } + + // If we get here then this is significant content inside a component with explicit child content. + child.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentMixedWithExplicitChildContent(child.Source, _component)); + _children.Add(child); + } + + bool IsIgnorableWhitespace(IntermediateNode n) + { + if (n is HtmlContentIntermediateNode html && + html.Children.Count == 1 && + html.Children[0] is IntermediateToken token && + string.IsNullOrWhiteSpace(token.Content)) + { + return true; + } + + return false; + } + } + + private ComponentChildContentIntermediateNode RewriteChildContent(BoundAttributeDescriptor attribute, SourceSpan? source, IntermediateNodeCollection children) + { + var childContent = new ComponentChildContentIntermediateNode() + { + BoundAttribute = attribute, + Source = source, + TypeName = attribute?.TypeName ?? ComponentsApi.RenderFragment.FullTypeName, + }; + + // There are two cases here: + // 1. Implicit child content - the children will be non-taghelper nodes, just accept them + // 2. Explicit child content - the children will be various tag helper nodes, that need special processing. + for (var i = 0; i < children.Count; i++) + { + var child = children[i]; + if (child is TagHelperBodyIntermediateNode body) + { + // The body is all of the content we want to render, the rest of the children will + // be the attributes. + for (var j = 0; j < body.Children.Count; j++) + { + childContent.Children.Add(body.Children[j]); + } + } + else if (child is TagHelperPropertyIntermediateNode property) + { + if (property.BoundAttribute.IsChildContentParameterNameProperty()) + { + // Check for each child content with a parameter name, that the parameter name is specified + // with literal text. For instance, the following is not allowed and should generate a diagnostic. + // + // ... + if (TryGetAttributeStringContent(property, out var parameterName)) + { + childContent.ParameterName = parameterName; + continue; + } + + // The parameter name is invalid. + childContent.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentHasInvalidParameter(property.Source, property.AttributeName, attribute.Name)); + continue; + } + + // This is an unrecognized tag helper bound attribute. This will practically never happen unless the child content descriptor was misconfigured. + childContent.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentHasInvalidAttribute(property.Source, property.AttributeName, attribute.Name)); + } + else if (child is TagHelperHtmlAttributeIntermediateNode a) + { + // This is an HTML attribute on a child content. + childContent.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentHasInvalidAttribute(a.Source, a.AttributeName, attribute.Name)); + } + else if (child is TagHelperDirectiveAttributeIntermediateNode directiveAttribute) + { + // We don't support directive attributes inside child content, this is possible if you try to do something like put '@ref' on a child content. + childContent.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentHasInvalidAttribute(directiveAttribute.Source, directiveAttribute.OriginalAttributeName, attribute.Name)); + } + else + { + // This is some other kind of node (likely an implicit child content) + childContent.Children.Add(child); + } + } + + return childContent; + } + + private bool TryGetAttributeStringContent(TagHelperPropertyIntermediateNode property, out string content) + { + // The success path looks like - a single HTML Attribute Value node with tokens + if (property.Children.Count == 1 && + property.Children[0] is HtmlContentIntermediateNode html) + { + content = string.Join(string.Empty, html.Children.OfType().Select(n => n.Content)); + return true; + } + + content = null; + return false; + } + + public override void VisitTagHelperHtmlAttribute(TagHelperHtmlAttributeIntermediateNode node) + { + var attribute = new ComponentAttributeIntermediateNode(node); + _children.Add(attribute); + + // Since we don't support complex content, we can rewrite the inside of this + // node to the rather simpler form that property nodes usually have. + for (var i = 0; i < attribute.Children.Count; i++) + { + if (attribute.Children[i] is HtmlAttributeValueIntermediateNode htmlValue) + { + var newNode = new HtmlContentIntermediateNode() + { + Source = htmlValue.Source, + }; + for (var j = 0; j < htmlValue.Children.Count; j++) + { + newNode.Children.Add(htmlValue.Children[j]); + } + + attribute.Children[i] = newNode; + } + else if (attribute.Children[i] is CSharpExpressionAttributeValueIntermediateNode expressionValue) + { + var newNode = new CSharpExpressionIntermediateNode() + { + Source = expressionValue.Source, + }; + for (var j = 0; j < expressionValue.Children.Count; j++) + { + newNode.Children.Add(expressionValue.Children[j]); + } + + attribute.Children[i] = newNode; + } + else if (attribute.Children[i] is CSharpCodeAttributeValueIntermediateNode codeValue) + { + var newNode = new CSharpExpressionIntermediateNode() + { + Source = codeValue.Source, + }; + for (var j = 0; j < codeValue.Children.Count; j++) + { + newNode.Children.Add(codeValue.Children[j]); + } + + attribute.Children[i] = newNode; + } + } + } + + public override void VisitTagHelperProperty(TagHelperPropertyIntermediateNode node) + { + // Each 'tag helper property' belongs to a specific tag helper. We want to handle + // the cases for components, but leave others alone. This allows our other passes + // to handle those cases. + if (!node.TagHelper.IsComponentTagHelper()) + { + _children.Add(node); + return; + } + + // Another special case here - this might be a type argument. These don't represent 'real' parameters + // that get passed to the component, it needs special code generation support. + if (node.TagHelper.IsGenericTypedComponent() && node.BoundAttribute.IsTypeParameterProperty()) + { + _children.Add(new ComponentTypeArgumentIntermediateNode(node)); + return; + } + + // Another special case here -- this might be a 'Context' parameter, which specifies the name + // for lambda parameter for parameterized child content + if (node.BoundAttribute.IsChildContentParameterNameProperty()) + { + // Check for each child content with a parameter name, that the parameter name is specified + // with literal text. For instance, the following is not allowed and should generate a diagnostic. + // + // ... + if (TryGetAttributeStringContent(node, out var parameterName)) + { + _component.ChildContentParameterName = parameterName; + return; + } + + // The parameter name is invalid. + _component.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentHasInvalidParameterOnComponent(node.Source, node.AttributeName, _component.TagName)); + return; + } + + _children.Add(new ComponentAttributeIntermediateNode(node)); + } + + public override void VisitTagHelperDirectiveAttribute(TagHelperDirectiveAttributeIntermediateNode node) + { + // We don't want to do anything special with directive attributes here. + // Let their corresponding lowering pass take care of processing them. + _children.Add(node); + } + + public override void VisitDefault(IntermediateNode node) + { + _children.Add(node); + } + } + + private class ElementRewriteVisitor : IntermediateNodeWalker + { + private readonly IntermediateNodeCollection _children; + + public ElementRewriteVisitor(IntermediateNodeCollection children) + { + _children = children; + } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + // Visit children, we're replacing this node. + for (var i = 0; i < node.Children.Count; i++) + { + Visit(node.Children[i]); + } + } + + public override void VisitTagHelperBody(TagHelperBodyIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + _children.Add(node.Children[i]); + } + } + + public override void VisitTagHelperHtmlAttribute(TagHelperHtmlAttributeIntermediateNode node) + { + var attribute = new HtmlAttributeIntermediateNode() + { + AttributeName = node.AttributeName, + Source = node.Source, + }; + _children.Add(attribute); + + for (var i = 0; i < node.Diagnostics.Count; i++) + { + attribute.Diagnostics.Add(node.Diagnostics[i]); + } + + switch (node.AttributeStructure) + { + case AttributeStructure.Minimized: + + attribute.Prefix = node.AttributeName; + attribute.Suffix = string.Empty; + break; + + case AttributeStructure.NoQuotes: + case AttributeStructure.SingleQuotes: + case AttributeStructure.DoubleQuotes: + + // We're ignoring attribute structure here for simplicity, it doesn't effect us. + attribute.Prefix = node.AttributeName + "=\""; + attribute.Suffix = "\""; + + for (var i = 0; i < node.Children.Count; i++) + { + attribute.Children.Add(RewriteAttributeContent(node.Children[i])); + } + + break; + } + + IntermediateNode RewriteAttributeContent(IntermediateNode content) + { + if (content is HtmlContentIntermediateNode html) + { + var value = new HtmlAttributeValueIntermediateNode() + { + Source = content.Source, + }; + + for (var i = 0; i < html.Children.Count; i++) + { + value.Children.Add(html.Children[i]); + } + + for (var i = 0; i < html.Diagnostics.Count; i++) + { + value.Diagnostics.Add(html.Diagnostics[i]); + } + + return value; + } + + + return content; + } + } + + public override void VisitTagHelperProperty(TagHelperPropertyIntermediateNode node) + { + // Each 'tag helper property' belongs to a specific tag helper. We want to handle + // the cases for components, but leave others alone. This allows our other passes + // to handle those cases. + _children.Add(node.TagHelper.IsComponentTagHelper() ? (IntermediateNode)new ComponentAttributeIntermediateNode(node) : node); + } + + public override void VisitTagHelperDirectiveAttribute(TagHelperDirectiveAttributeIntermediateNode node) + { + // We don't want to do anything special with directive attributes here. + // Let their corresponding lowering pass take care of processing them. + _children.Add(node); + } + + public override void VisitDefault(IntermediateNode node) + { + _children.Add(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs new file mode 100644 index 0000000000..dc26b140b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs @@ -0,0 +1,363 @@ +// 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 System.Text; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + // Rewrites contiguous subtrees of HTML into a special node type to reduce the + // size of the Render tree. + // + // Does not preserve insignificant details of the HTML, like tag closing style + // or quote style. + internal class ComponentMarkupBlockPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Runs LATE because we want to destroy structure. + // + // We also need to run after ComponentMarkupDiagnosticPass to avoid destroying diagnostics + // added in that pass. + public override int Order => ComponentMarkupDiagnosticPass.DefaultOrder + 10; + + protected override void ExecuteCore( + RazorCodeDocument codeDocument, + DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + if (documentNode.Options.DesignTime) + { + // Nothing to do during design time. + return; + } + + var findVisitor = new FindHtmlTreeVisitor(); + findVisitor.Visit(documentNode); + + var trees = findVisitor.Trees; + var rewriteVisitor = new RewriteVisitor(trees); + while (trees.Count > 0) + { + // Walk backwards since we did a postorder traversal. + var reference = trees[trees.Count - 1]; + + // Forcibly remove a node to prevent infinite loops. + trees.RemoveAt(trees.Count - 1); + + // We want to fold together siblings where possible. To do this, first we find + // the index of the node we're looking at now - then we need to walk backwards + // and identify a set of contiguous nodes we can merge. + var start = reference.Parent.Children.Count - 1; + for (; start >= 0; start--) + { + if (ReferenceEquals(reference.Node, reference.Parent.Children[start])) + { + break; + } + } + + // This is the current node. Check if the left sibling is always a candidate + // for rewriting. Due to the order we processed the nodes, we know that the + // left sibling is next in the list to process if it's a candidate. + var end = start; + while (start - 1 >= 0) + { + var candidate = reference.Parent.Children[start - 1]; + if (trees.Count == 0 || !ReferenceEquals(trees[trees.Count - 1].Node, candidate)) + { + // This means the we're out of nodes, or the left sibling is not in the list. + break; + } + + // This means that the left sibling is valid to merge. + start--; + + // Remove this since we're combining it. + trees.RemoveAt(trees.Count - 1); + } + + // As a degenerate case, don't bother rewriting an single HtmlContent node + // It doesn't add any value. + if (end - start == 0 && reference.Node is HtmlContentIntermediateNode) + { + continue; + } + + // Now we know the range of nodes to rewrite (end is inclusive) + var length = end + 1 - start; + while (length > 0) + { + // Keep using start since we're removing nodes. + var node = reference.Parent.Children[start]; + reference.Parent.Children.RemoveAt(start); + + rewriteVisitor.Visit(node); + + length--; + } + + reference.Parent.Children.Insert(start, new MarkupBlockIntermediateNode() + { + Content = rewriteVisitor.Builder.ToString(), + }); + + rewriteVisitor.Builder.Clear(); + } + } + + // Finds HTML-blocks using a postorder traversal. We store nodes in an + // ordered list so we can avoid redundant rewrites. + // + // Consider a case like: + //
+ // click me + //
+ // + // We would store both the div and a tag in a list, but make sure to visit + // the div first. Then when we process the div (recursively), we would remove + // the a from the list. + private class FindHtmlTreeVisitor : IntermediateNodeWalker + { + private bool _foundNonHtml; + + public List Trees { get; } = new List(); + + public override void VisitDefault(IntermediateNode node) + { + // If we get here, we found a non-HTML node. Keep traversing. + _foundNonHtml = true; + base.VisitDefault(node); + } + + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + // We need to restore the state after processing this node. + // We might have found a leaf-block of HTML, but that shouldn't + // affect our parent's state. + var originalState = _foundNonHtml; + + _foundNonHtml = false; + + if (node.HasDiagnostics) + { + // Treat node with errors as non-HTML - don't let the parent rewrite this either. + _foundNonHtml = true; + } + + if (string.Equals("script", node.TagName, StringComparison.OrdinalIgnoreCase)) + { + // Treat script tags as non-HTML - we trigger errors for script tags + // later. + _foundNonHtml = true; + } + else if (string.Equals("option", node.TagName, StringComparison.OrdinalIgnoreCase)) + { + // Also, treat as non-HTML - we don't want it to be coalesced so that we can support setting "selected" attribute on it. + // We only care about option tags that are nested under a select tag. + foreach (var ancestor in Ancestors) + { + if (ancestor is MarkupElementIntermediateNode element && + string.Equals("select", element.TagName, StringComparison.OrdinalIgnoreCase)) + { + _foundNonHtml = true; + break; + } + } + } + + base.VisitDefault(node); + + if (!_foundNonHtml) + { + Trees.Add(new IntermediateNodeReference(Parent, node)); + } + + _foundNonHtml = originalState |= _foundNonHtml; + } + + public override void VisitHtmlAttribute(HtmlAttributeIntermediateNode node) + { + if (node.HasDiagnostics) + { + // Treat node with errors as non-HTML + _foundNonHtml = true; + } + + // Visit Children + base.VisitDefault(node); + } + + public override void VisitHtmlAttributeValue(HtmlAttributeValueIntermediateNode node) + { + if (node.HasDiagnostics) + { + // Treat node with errors as non-HTML + _foundNonHtml = true; + } + + // Visit Children + base.VisitDefault(node); + } + + public override void VisitHtml(HtmlContentIntermediateNode node) + { + // We need to restore the state after processing this node. + // We might have found a leaf-block of HTML, but that shouldn't + // affect our parent's state. + var originalState = _foundNonHtml; + + _foundNonHtml = false; + + if (node.HasDiagnostics) + { + // Treat node with errors as non-HTML + _foundNonHtml = true; + } + + // Visit Children + base.VisitDefault(node); + + if (!_foundNonHtml) + { + Trees.Add(new IntermediateNodeReference(Parent, node)); + } + + _foundNonHtml = originalState |= _foundNonHtml; + } + + public override void VisitToken(IntermediateToken node) + { + if (node.HasDiagnostics) + { + // Treat node with errors as non-HTML + _foundNonHtml = true; + } + + if (node.IsCSharp) + { + _foundNonHtml = true; + } + } + } + + private class RewriteVisitor : IntermediateNodeWalker + { + private readonly StringBuilder _encodingBuilder; + + private readonly List _trees; + + public RewriteVisitor(List trees) + { + _trees = trees; + + _encodingBuilder = new StringBuilder(); + } + + public StringBuilder Builder { get; } = new StringBuilder(); + + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + for (var i = 0; i < _trees.Count; i++) + { + // Remove this node if it's in the list. This ensures that we don't + // do redundant operations. + if (ReferenceEquals(_trees[i].Node, node)) + { + _trees.RemoveAt(i); + break; + } + } + + var isVoid = Legacy.ParserHelpers.VoidElements.Contains(node.TagName); + var hasBodyContent = node.Body.Any(); + + Builder.Append("<"); + Builder.Append(node.TagName); + + foreach (var attribute in node.Attributes) + { + Visit(attribute); + } + + // If for some reason a void element contains body, then treat it as a + // start/end tag. + if (!hasBodyContent && isVoid) + { + // void + Builder.Append(">"); + return; + } + else if (!hasBodyContent) + { + // In HTML5, we can't have self-closing non-void elements, so explicitly + // add a close tag + Builder.Append(">"); + return; + } + + // start/end tag with body. + Builder.Append(">"); + + foreach (var item in node.Body) + { + Visit(item); + } + + Builder.Append(""); + } + + public override void VisitHtmlAttribute(HtmlAttributeIntermediateNode node) + { + Builder.Append(" "); + Builder.Append(node.AttributeName); + + if (node.Children.Count == 0) + { + // Minimized attribute + return; + } + + Builder.Append("=\""); + + // Visit Children + base.VisitDefault(node); + + Builder.Append("\""); + } + + public override void VisitHtmlAttributeValue(HtmlAttributeValueIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + Builder.Append(node.Prefix); + + if (node.Children[i] is IntermediateToken token) + { + Builder.Append(token.Content); + } + } + } + + public override void VisitHtml(HtmlContentIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token) + { + Builder.Append(token.Content); + } + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs new file mode 100644 index 0000000000..186743e5b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs @@ -0,0 +1,214 @@ +// 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.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentMarkupEncodingPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Runs after ComponentMarkupBlockPass + public override int Order => ComponentMarkupDiagnosticPass.DefaultOrder + 20; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + if (documentNode.Options.DesignTime) + { + // Nothing to do during design time. + return; + } + + var rewriter = new Rewriter(); + rewriter.Visit(documentNode); + } + + private class Rewriter : IntermediateNodeWalker + { + // Markup content in components are rendered in one of the following two ways, + // AddContent - we encode it when used with prerendering and inserted into the DOM in a safe way (low perf impact) + // AddMarkupContent - renders the content directly as markup (high perf impact) + // Because of this, we want to use AddContent as much as possible. + // + // We want to use AddMarkupContent to avoid aggresive encoding during prerendering. + // Specifically, when one of the following characters are in the content, + // 1. New lines (\r, \n), tabs(\t) - so they get rendered as actual new lines, tabs instead of + // 2. Any character outside the ASCII range + + private static readonly char[] EncodedCharacters = new[] { '\r', '\n', '\t' }; + + private readonly Dictionary _seenEntities = new Dictionary(StringComparer.Ordinal); + + public override void VisitHtml(HtmlContentIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + var child = node.Children[i]; + if (!(child is IntermediateToken token) || !token.IsHtml || string.IsNullOrEmpty(token.Content)) + { + // We only care about Html tokens. + continue; + } + + for (var j = 0; j < token.Content.Length; j++) + { + var ch = token.Content[j]; + // ASCII range is 0 - 127 + if (ch > 127 || EncodedCharacters.Contains(ch)) + { + node.SetEncoded(); + return; + } + } + } + + // If we reach here, we don't have newlines, tabs or non-ascii characters in this node. + // If we can successfully decode all HTML entities(if any) in this node, we can safely let it call AddContent. + var decodedContent = new string[node.Children.Count]; + for (var i = 0; i < node.Children.Count; i++) + { + var child = node.Children[i]; + if (!(child is IntermediateToken token) || !token.IsHtml || string.IsNullOrEmpty(token.Content)) + { + // We only care about Html tokens. + continue; + } + + if (TryDecodeHtmlEntities(token.Content, out var decoded)) + { + decodedContent[i] = decoded; + } + else + { + node.SetEncoded(); + return; + } + } + + // If we reach here, it means we have successfully decoded all content. + // Replace all token content with the decoded value. + for (var i = 0; i < node.Children.Count; i++) + { + var child = node.Children[i]; + if (!(child is IntermediateToken token) || !token.IsHtml || string.IsNullOrEmpty(token.Content)) + { + // We only care about Html tokens. + continue; + } + + token.Content = decodedContent[i]; + } + } + + private bool TryDecodeHtmlEntities(string content, out string decoded) + { + _seenEntities.Clear(); + decoded = content; + var i = 0; + while (i < content.Length) + { + var ch = content[i]; + if (ch == '&') + { + if (TryGetHtmlEntity(content, i, out var entity, out var replacement)) + { + if (!_seenEntities.ContainsKey(entity)) + { + _seenEntities.Add(entity, replacement); + } + + i += entity.Length; + } + else + { + // We found a '&' that we don't know what to do with. Don't try to decode further. + return false; + } + } + else + { + i++; + } + } + + foreach (var entity in _seenEntities) + { + decoded = decoded.Replace(entity.Key, entity.Value); + } + + return true; + } + + private bool TryGetHtmlEntity(string content, int position, out string entity, out string replacement) + { + // We're at '&'. Check if it is the start of an HTML entity. + entity = null; + replacement = null; + var endPosition = -1; + for (var i = position + 1; i < content.Length; i++) + { + var ch = content[i]; + if (char.IsLetterOrDigit(ch) || ch == '#') + { + continue; + } + else if (ch == ';') + { + endPosition = i; + } + + break; + } + + if (endPosition != -1) + { + entity = content.Substring(position, endPosition - position + 1); + if (entity.StartsWith("&#")) + { + // Extract the codepoint and map it to an entity. + + // `entity` is guaranteed to be of the format &#****; + var entityValue = entity.Substring(2, entity.Length - 3); + var codePoint = -1; + if (!int.TryParse(entityValue, out codePoint)) + { + // If it is not an integer, check if it is hexadecimal like 0x00CD + try + { + codePoint = Convert.ToInt32(entityValue, 16); + } + catch (FormatException) + { + // Do nothing. + } + } + + if (ParserHelpers.HtmlEntityCodePoints.TryGetValue(codePoint, out replacement)) + { + // This is a known html entity unicode codepoint. + return true; + } + + // Unknown entity. + return false; + } + else if (ParserHelpers.NamedHtmlEntities.TryGetValue(entity, out replacement)) + { + return true; + } + } + + // The '&' is not part of an HTML entity. + return false; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs new file mode 100644 index 0000000000..6a2dd46d29 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs @@ -0,0 +1,144 @@ +// 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.Razor.Language.Components +{ + // Metadata used for Components interactions with the tag helper system + internal static class ComponentMetadata + { + private static readonly string MangledClassNamePrefix = "__generated__"; + + // There's a bug in the 15.7 preview 1 Razor that prevents 'Kind' from being serialized + // this affects both tooling and build. For now our workaround is to ignore 'Kind' and + // use our own metadata entry to denote non-Component tag helpers. + public static readonly string SpecialKindKey = "Components.IsSpecialKind"; + + public static readonly string ImportsFileName = "_Imports.razor"; + + public static string MangleClassName(string className) + { + if (string.IsNullOrEmpty(className)) + { + return string.Empty; + } + + return MangledClassNamePrefix + className; + } + + public static bool IsMangledClass(string className) + { + if (string.IsNullOrEmpty(className)) + { + return false; + } + + return className.StartsWith(MangledClassNamePrefix, StringComparison.Ordinal); + } + + public static class Common + { + public static readonly string OriginalAttributeName = "Common.OriginalAttributeName"; + + public static readonly string DirectiveAttribute = "Common.DirectiveAttribute"; + + public static readonly string AddAttributeMethodName = "Common.AddAttributeMethodName"; + } + + public static class Bind + { + public static readonly string RuntimeName = "Components.None"; + + public readonly static string TagHelperKind = "Components.Bind"; + + public readonly static string FallbackKey = "Components.Bind.Fallback"; + + public readonly static string TypeAttribute = "Components.Bind.TypeAttribute"; + + public readonly static string ValueAttribute = "Components.Bind.ValueAttribute"; + + public readonly static string ChangeAttribute = "Components.Bind.ChangeAttribute"; + + public readonly static string ExpressionAttribute = "Components.Bind.ExpressionAttribute"; + + public readonly static string IsInvariantCulture = "Components.Bind.IsInvariantCulture"; + + public readonly static string Format = "Components.Bind.Format"; + } + + public static class ChildContent + { + public static readonly string RuntimeName = "Components.None"; + + public static readonly string TagHelperKind = "Components.ChildContent"; + + public static readonly string ParameterNameBoundAttributeKind = "Components.ChildContentParameterName"; + + /// + /// The name of the synthesized attribute used to set a child content parameter. + /// + public static readonly string ParameterAttributeName = "Context"; + + /// + /// The default name of the child content parameter (unless set by a Context attribute). + /// + public static readonly string DefaultParameterName = "context"; + } + + public static class Component + { + public static readonly string ChildContentKey = "Components.ChildContent"; + + public static readonly string ChildContentParameterNameKey = "Components.ChildContentParameterName"; + + public static readonly string DelegateSignatureKey = "Components.DelegateSignature"; + + public static readonly string EventCallbackKey = "Components.EventCallback"; + + public static readonly string WeaklyTypedKey = "Components.IsWeaklyTyped"; + + public static readonly string RuntimeName = "Components.IComponent"; + + public readonly static string TagHelperKind = "Components.Component"; + + public readonly static string GenericTypedKey = "Components.GenericTyped"; + + public readonly static string TypeParameterKey = "Components.TypeParameter"; + + public readonly static string NameMatchKey = "Components.NameMatch"; + + public readonly static string FullyQualifiedNameMatch = "Components.FullyQualifiedNameMatch"; + } + + public static class EventHandler + { + public static readonly string EventArgsType = "Components.EventHandler.EventArgs"; + + public static readonly string RuntimeName = "Components.None"; + + public readonly static string TagHelperKind = "Components.EventHandler"; + } + + public static class Key + { + public readonly static string TagHelperKind = "Components.Key"; + + public static readonly string RuntimeName = "Components.None"; + } + + public static class Splat + { + public readonly static string TagHelperKind = "Components.Splat"; + + public static readonly string RuntimeName = "Components.None"; + } + + public static class Ref + { + public readonly static string TagHelperKind = "Components.Ref"; + + public static readonly string RuntimeName = "Components.None"; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs new file mode 100644 index 0000000000..df21a531fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs @@ -0,0 +1,263 @@ +// 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal abstract class ComponentNodeWriter : IntermediateNodeWriter, ITemplateTargetExtension + { + protected abstract void BeginWriteAttribute(CodeRenderingContext context, string key); + + protected abstract void BeginWriteAttribute(CodeRenderingContext context, IntermediateNode expression); + + protected abstract void WriteReferenceCaptureInnards(CodeRenderingContext context, ReferenceCaptureIntermediateNode node, bool shouldTypeCheck); + + public abstract void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node); + + public sealed override void BeginWriterScope(CodeRenderingContext context, string writer) + { + throw new NotImplementedException(nameof(BeginWriterScope)); + } + + public sealed override void EndWriterScope(CodeRenderingContext context) + { + throw new NotImplementedException(nameof(EndWriterScope)); + } + + public sealed override void WriteCSharpCodeAttributeValue(CodeRenderingContext context, CSharpCodeAttributeValueIntermediateNode node) + { + // We used to support syntaxes like but this is no longer the + // case. + // + // We provide an error for this case just to be friendly. + var content = string.Join("", node.Children.OfType().Select(t => t.Content)); + context.Diagnostics.Add(ComponentDiagnosticFactory.Create_CodeBlockInAttribute(node.Source, content)); + return; + } + + // Currently the same for design time and runtime + public override void WriteComponentTypeInferenceMethod(CodeRenderingContext context, ComponentTypeInferenceMethodIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // This is ugly because CodeWriter doesn't allow us to erase, but we need to comma-delimit. So we have to + // materizalize something can iterate, or use string.Join. We'll need this multiple times, so materializing + // it. + var parameters = GetParameterDeclarations(); + + // This is really similar to the code in WriteComponentAttribute and WriteComponentChildContent - except simpler because + // attributes and child contents look like variables. + // + // Looks like: + // + // public static void CreateFoo_0(RenderTreeBuilder __builder, int seq, int __seq0, T1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, string __arg2) + // { + // builder.OpenComponent>(); + // builder.AddAttribute(__seq0, "Attr0", __arg0); + // builder.AddAttribute(__seq1, "Attr1", __arg1); + // builder.AddAttribute(__seq2, "Attr2", __arg2); + // builder.CloseComponent(); + // } + // + // As a special case, we need to generate a thunk for captures in this block instead of using + // them verbatim. + // + // The problem is that RenderTreeBuilder wants an Action. The caller can't write the type + // name if it contains generics, and we can't write the variable they want to assign to. + var writer = context.CodeWriter; + + writer.Write("public static void "); + writer.Write(node.MethodName); + + writer.Write("<"); + writer.Write(string.Join(", ", node.Component.Component.GetTypeParameters().Select(a => a.Name))); + writer.Write(">"); + + writer.Write("("); + writer.Write("global::"); + writer.Write(ComponentsApi.RenderTreeBuilder.FullTypeName); + writer.Write(" "); + writer.Write(ComponentsApi.RenderTreeBuilder.BuilderParameter); + writer.Write(", "); + writer.Write("int seq"); + + if (parameters.Count > 0) + { + writer.Write(", "); + } + + for (var i = 0; i < parameters.Count; i++) + { + writer.Write("int "); + writer.Write(parameters[i].seqName); + + writer.Write(", "); + writer.Write(parameters[i].typeName); + writer.Write(" "); + writer.Write(parameters[i].parameterName); + + if (i < parameters.Count - 1) + { + writer.Write(", "); + } + } + + writer.Write(")"); + writer.WriteLine(); + + writer.WriteLine("{"); + + // _builder.OpenComponent(42); + context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.BuilderParameter); + context.CodeWriter.Write("."); + context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.OpenComponent); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(node.Component.TypeName); + context.CodeWriter.Write(">("); + context.CodeWriter.Write("seq"); + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + + var index = 0; + + // Preserve order of attributes and splat. + foreach (var child in node.Component.Children) + { + if (child is ComponentAttributeIntermediateNode attribute) + { + context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.AddAttribute); + context.CodeWriter.Write(parameters[index].seqName); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write($"\"{attribute.AttributeName}\""); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write(parameters[index].parameterName); + context.CodeWriter.WriteEndMethodInvocation(); + index++; + } + else if (child is SplatIntermediateNode) + { + context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.AddMultipleAttributes); + context.CodeWriter.Write(parameters[index].seqName); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write(parameters[index].parameterName); + context.CodeWriter.WriteEndMethodInvocation(); + index++; + } + } + + foreach (var childContent in node.Component.ChildContents) + { + context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.AddAttribute); + context.CodeWriter.Write(parameters[index].seqName); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write($"\"{childContent.AttributeName}\""); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write(parameters[index].parameterName); + context.CodeWriter.WriteEndMethodInvocation(); + + index++; + } + + foreach (var setKey in node.Component.SetKeys) + { + context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.SetKey); + context.CodeWriter.Write(parameters[index].parameterName); + context.CodeWriter.WriteEndMethodInvocation(); + + index++; + } + + foreach (var capture in node.Component.Captures) + { + context.CodeWriter.WriteStartInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, capture.IsComponentCapture ? ComponentsApi.RenderTreeBuilder.AddComponentReferenceCapture : ComponentsApi.RenderTreeBuilder.AddElementReferenceCapture); + context.CodeWriter.Write(parameters[index].seqName); + context.CodeWriter.Write(", "); + + var cast = capture.IsComponentCapture ? $"({capture.ComponentCaptureTypeName})" : string.Empty; + context.CodeWriter.Write($"(__value) => {{ {parameters[index].parameterName}({cast}__value); }}"); + context.CodeWriter.WriteEndMethodInvocation(); + + index++; + } + + context.CodeWriter.WriteInstanceMethodInvocation(ComponentsApi.RenderTreeBuilder.BuilderParameter, ComponentsApi.RenderTreeBuilder.CloseComponent); + + writer.WriteLine("}"); + + List<(string seqName, string typeName, string parameterName)> GetParameterDeclarations() + { + var p = new List<(string seqName, string typeName, string parameterName)>(); + + // Preserve order between attributes and splats + foreach (var child in node.Component.Children) + { + if (child is ComponentAttributeIntermediateNode attribute) + { + string typeName; + if (attribute.GloballyQualifiedTypeName != null) + { + typeName = attribute.GloballyQualifiedTypeName; + } + else + { + typeName = attribute.TypeName; + if (attribute.BoundAttribute != null && !attribute.BoundAttribute.IsGenericTypedProperty()) + { + typeName = "global::" + typeName; + } + } + + p.Add(($"__seq{p.Count}", typeName, $"__arg{p.Count}")); + } + else if (child is SplatIntermediateNode splat) + { + var typeName = ComponentsApi.AddMultipleAttributesTypeFullName; + p.Add(($"__seq{p.Count}", typeName, $"__arg{p.Count}")); + } + } + + foreach (var childContent in node.Component.ChildContents) + { + var typeName = childContent.TypeName; + if (childContent.BoundAttribute != null && !childContent.BoundAttribute.IsGenericTypedProperty()) + { + typeName = "global::" + typeName; + } + p.Add(($"__seq{p.Count}", typeName, $"__arg{p.Count}")); + } + + foreach (var capture in node.Component.SetKeys) + { + p.Add(($"__seq{p.Count}", "object", $"__arg{p.Count}")); + } + + foreach (var capture in node.Component.Captures) + { + // The capture type name should already contain the global:: prefix. + p.Add(($"__seq{p.Count}", capture.TypeName, $"__arg{p.Count}")); + } + + return p; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPageDirective.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPageDirective.cs new file mode 100644 index 0000000000..8fefd172f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPageDirective.cs @@ -0,0 +1,43 @@ +// 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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentPageDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "page", + DirectiveKind.SingleLine, + builder => + { + builder.AddStringToken(ComponentResources.PageDirective_RouteToken_Name, ComponentResources.PageDirective_RouteToken_Description); + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.Description = ComponentResources.PageDirective_Description; + }); + + private ComponentPageDirective(string routeTemplate, IntermediateNode directiveNode) + { + RouteTemplate = routeTemplate; + DirectiveNode = directiveNode; + } + + public string RouteTemplate { get; } + + public IntermediateNode DirectiveNode { get; } + + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive, FileKinds.Component, FileKinds.ComponentImport); + builder.Features.Add(new ComponentPageDirectivePass()); + return builder; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPageDirectivePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPageDirectivePass.cs new file mode 100644 index 0000000000..c751dd57b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPageDirectivePass.cs @@ -0,0 +1,80 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentPageDirectivePass : IntermediateNodePassBase, IRazorDirectiveClassifierPass + { + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (documentNode == null) + { + throw new ArgumentNullException(nameof(documentNode)); + } + + var @namespace = documentNode.FindPrimaryNamespace(); + var @class = documentNode.FindPrimaryClass(); + if (@namespace == null || @class == null) + { + return; + } + + var directives = documentNode.FindDirectiveReferences(ComponentPageDirective.Directive); + if (directives.Count == 0) + { + return; + } + + // We don't allow @page directives in imports + for (var i = 0; i < directives.Count; i++) + { + var directive = directives[i]; + if (FileKinds.IsComponentImport(codeDocument.GetFileKind()) || directive.Node.IsImported()) + { + directive.Node.Diagnostics.Add(ComponentDiagnosticFactory.CreatePageDirective_CannotBeImported(directive.Node.Source.Value)); + } + } + + // Insert the attributes 'on-top' of the class declaration, since classes don't directly support attributes. + var index = 0; + for (; index < @namespace.Children.Count; index++) + { + if (object.ReferenceEquals(@class, @namespace.Children[index])) + { + break; + } + } + + for (var i = 0; i < directives.Count; i++) + { + var pageDirective = (DirectiveIntermediateNode)directives[i].Node; + + // The parser also adds errors for invalid syntax, we just need to not crash. + var routeToken = pageDirective.Tokens.FirstOrDefault(); + + if (routeToken != null && + routeToken.Content.Length >= 3 && + routeToken.Content[0] == '\"' && + routeToken.Content[1] == '/' && + routeToken.Content[routeToken.Content.Length - 1] == '\"') + { + var template = routeToken.Content.Substring(1, routeToken.Content.Length - 2); + @namespace.Children.Insert(index++, new RouteAttributeExtensionNode(template)); + } + else + { + pageDirective.Diagnostics.Add(ComponentDiagnosticFactory.CreatePageDirective_MustSpecifyRoute(pageDirective.Source)); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs new file mode 100644 index 0000000000..b4d776aacf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentReferenceCaptureLoweringPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + // Run after component lowering pass + public override int Order => 50; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + 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 references = documentNode.FindDescendantReferences(); + for (var i = 0; i < references.Count; i++) + { + var reference = references[i]; + var node = (TagHelperDirectiveAttributeIntermediateNode)reference.Node; + + if (node.TagHelper.IsRefTagHelper()) + { + reference.Replace(RewriteUsage(@class, reference.Parent, node)); + } + } + } + + private IntermediateNode RewriteUsage(ClassDeclarationIntermediateNode classNode, IntermediateNode parent, TagHelperDirectiveAttributeIntermediateNode node) + { + // If we can't get a nonempty attribute name, do nothing because there will + // already be a diagnostic for empty values + var identifierToken = DetermineIdentifierToken(node); + if (identifierToken == null) + { + return node; + } + + // Determine whether this is an element capture or a component capture, and + // if applicable the type name that will appear in the resulting capture code + var componentTagHelper = (parent as ComponentIntermediateNode)?.Component; + if (componentTagHelper != null) + { + return new ReferenceCaptureIntermediateNode(identifierToken, componentTagHelper.GetTypeName()); + } + else + { + return new ReferenceCaptureIntermediateNode(identifierToken); + } + } + + private IntermediateToken DetermineIdentifierToken(TagHelperDirectiveAttributeIntermediateNode attributeNode) + { + IntermediateToken foundToken = null; + + if (attributeNode.Children.Count == 1) + { + if (attributeNode.Children[0] is IntermediateToken token) + { + foundToken = token; + } + else if (attributeNode.Children[0] is CSharpExpressionIntermediateNode csharpNode) + { + if (csharpNode.Children.Count == 1) + { + foundToken = csharpNode.Children[0] as IntermediateToken; + } + } + } + + return !string.IsNullOrWhiteSpace(foundToken?.Content) ? foundToken : null; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs new file mode 100644 index 0000000000..b57552e5e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs @@ -0,0 +1,1016 @@ +// 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.Diagnostics; +using System.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + /// + /// Generates the C# code corresponding to Razor source document contents. + /// + internal class ComponentRuntimeNodeWriter : ComponentNodeWriter + { + private readonly List _currentAttributeValues = new List(); + private readonly ScopeStack _scopeStack = new ScopeStack(); + private int _sourceSequence = 0; + + public override void WriteCSharpCode(CodeRenderingContext context, CSharpCodeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + var isWhitespaceStatement = true; + for (var i = 0; i < node.Children.Count; i++) + { + var token = node.Children[i] as IntermediateToken; + if (token == null || !string.IsNullOrWhiteSpace(token.Content)) + { + isWhitespaceStatement = false; + break; + } + } + + if (isWhitespaceStatement) + { + // The runtime and design time code differ in their handling of whitespace-only + // statements. At runtime we can discard them completely. At design time we need + // to keep them for the editor. + return; + } + + IDisposable linePragmaScope = null; + if (node.Source != null) + { + linePragmaScope = context.CodeWriter.BuildLinePragma(node.Source.Value, context); + context.CodeWriter.WritePadding(0, node.Source.Value, context); + } + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + context.AddSourceMappingFor(token); + context.CodeWriter.Write(token.Content); + } + else + { + // There may be something else inside the statement like an extension node. + context.RenderNode(node.Children[i]); + } + } + + if (linePragmaScope != null) + { + linePragmaScope.Dispose(); + } + else + { + context.CodeWriter.WriteLine(); + } + } + + public override void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Since we're not in the middle of writing an element, this must evaluate as some + // text to display + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddContent}") + .Write((_sourceSequence++).ToString()) + .WriteParameterSeparator(); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is IntermediateToken token && token.IsCSharp) + { + WriteCSharpToken(context, token); + } + else + { + // There may be something else inside the expression like a Template or another extension node. + context.RenderNode(node.Children[i]); + } + } + + context.CodeWriter.WriteEndMethodInvocation(); + } + + public override void WriteCSharpExpressionAttributeValue(CodeRenderingContext context, CSharpExpressionAttributeValueIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // In cases like "somestring @variable", Razor tokenizes it as: + // [0] HtmlContent="somestring" + // [1] CsharpContent="variable" Prefix=" " + // ... so to avoid losing whitespace, convert the prefix to a further token in the list + if (!string.IsNullOrEmpty(node.Prefix)) + { + _currentAttributeValues.Add(new IntermediateToken() { Kind = TokenKind.Html, Content = node.Prefix }); + } + + for (var i = 0; i < node.Children.Count; i++) + { + _currentAttributeValues.Add((IntermediateToken)node.Children[i]); + } + } + + public override void WriteMarkupBlock(CodeRenderingContext context, MarkupBlockIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddMarkupContent}") + .Write((_sourceSequence++).ToString()) + .WriteParameterSeparator() + .WriteStringLiteral(node.Content) + .WriteEndMethodInvocation(); + } + + public override void WriteMarkupElement(CodeRenderingContext context, MarkupElementIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.OpenElement}") + .Write((_sourceSequence++).ToString()) + .WriteParameterSeparator() + .WriteStringLiteral(node.TagName) + .WriteEndMethodInvocation(); + + // Render attributes and splats (in order) before creating the scope. + foreach (var child in node.Children) + { + if (child is HtmlAttributeIntermediateNode attribute) + { + context.RenderNode(attribute); + } + else if (child is ComponentAttributeIntermediateNode componentAttribute) + { + context.RenderNode(componentAttribute); + } + else if (child is SplatIntermediateNode splat) + { + context.RenderNode(splat); + } + } + + foreach (var setKey in node.SetKeys) + { + context.RenderNode(setKey); + } + + foreach (var capture in node.Captures) + { + context.RenderNode(capture); + } + + // Render body of the tag inside the scope + foreach (var child in node.Body) + { + context.RenderNode(child); + } + + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.CloseElement}") + .WriteEndMethodInvocation(); + } + + public override void WriteHtmlAttribute(CodeRenderingContext context, HtmlAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + Debug.Assert(_currentAttributeValues.Count == 0); + context.RenderChildren(node); + + if (node.AttributeNameExpression == null) + { + WriteAttribute(context, node.AttributeName, _currentAttributeValues); + } + else + { + WriteAttribute(context, node.AttributeNameExpression, _currentAttributeValues); + } + _currentAttributeValues.Clear(); + + if (!string.IsNullOrEmpty(node.EventUpdatesAttributeName)) + { + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.SetUpdatesAttributeName}") + .WriteStringLiteral(node.EventUpdatesAttributeName) + .WriteEndMethodInvocation(); + } + } + + public override void WriteHtmlAttributeValue(CodeRenderingContext context, HtmlAttributeValueIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + var stringContent = ((IntermediateToken)node.Children.Single()).Content; + _currentAttributeValues.Add(new IntermediateToken() { Kind = TokenKind.Html, Content = node.Prefix + stringContent, }); + } + + public override void WriteHtmlContent(CodeRenderingContext context, HtmlContentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Text node + var content = GetHtmlContent(node); + var renderApi = ComponentsApi.RenderTreeBuilder.AddContent; + if (node.IsEncoded()) + { + // This content is already encoded. + renderApi = ComponentsApi.RenderTreeBuilder.AddMarkupContent; + } + + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{renderApi}") + .Write((_sourceSequence++).ToString()) + .WriteParameterSeparator() + .WriteStringLiteral(content) + .WriteEndMethodInvocation(); + } + + public override void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.Source.HasValue) + { + using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) + { + context.CodeWriter.WriteUsing(node.Content); + } + } + else + { + context.CodeWriter.WriteUsing(node.Content, endLine: true); + } + } + + public override void WriteComponent(CodeRenderingContext context, ComponentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + if (node.TypeInferenceNode == null) + { + // If the component is using not using type inference then we just write an open/close with a series + // of add attribute calls in between. + // + // Writes something like: + // + // _builder.OpenComponent(0); + // _builder.AddAttribute(1, "Foo", ...); + // _builder.AddAttribute(2, "ChildContent", ...); + // _builder.SetKey(someValue); + // _builder.AddElementCapture(3, (__value) => _field = __value); + // _builder.CloseComponent(); + + // _builder.OpenComponent(42); + context.CodeWriter.Write(_scopeStack.BuilderVarName); + context.CodeWriter.Write("."); + context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.OpenComponent); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write(">("); + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + + // We can skip type arguments during runtime codegen, they are handled in the + // type/parameter declarations. + + // Preserve order of attributes and splats + foreach (var child in node.Children) + { + if (child is ComponentAttributeIntermediateNode attribute) + { + context.RenderNode(attribute); + } + else if (child is SplatIntermediateNode splat) + { + context.RenderNode(splat); + } + } + + foreach (var childContent in node.ChildContents) + { + context.RenderNode(childContent); + } + + foreach (var setKey in node.SetKeys) + { + context.RenderNode(setKey); + } + + foreach (var capture in node.Captures) + { + context.RenderNode(capture); + } + + // _builder.CloseComponent(); + context.CodeWriter.Write(_scopeStack.BuilderVarName); + context.CodeWriter.Write("."); + context.CodeWriter.Write(ComponentsApi.RenderTreeBuilder.CloseComponent); + context.CodeWriter.Write("();"); + context.CodeWriter.WriteLine(); + } + else + { + // When we're doing type inference, we can't write all of the code inline to initialize + // the component on the builder. We generate a method elsewhere, and then pass all of the information + // to that method. We pass in all of the attribute values + the sequence numbers. + // + // __Blazor.MyComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, ..., 2, ..., 3, ...); + + // Preserve order of attributes and splats + var attributes = node.Children.Where(n => + { + return n is ComponentAttributeIntermediateNode || n is SplatIntermediateNode; + }).ToList(); + var childContents = node.ChildContents.ToList(); + var captures = node.Captures.ToList(); + var setKeys = node.SetKeys.ToList(); + var remaining = attributes.Count + childContents.Count + captures.Count + setKeys.Count; + + context.CodeWriter.Write(node.TypeInferenceNode.FullTypeName); + context.CodeWriter.Write("."); + context.CodeWriter.Write(node.TypeInferenceNode.MethodName); + context.CodeWriter.Write("("); + + context.CodeWriter.Write(_scopeStack.BuilderVarName); + context.CodeWriter.Write(", "); + + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(", "); + + for (var i = 0; i < attributes.Count; i++) + { + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(", "); + + // Don't type check generics, since we can't actually write the type name. + // The type checking with happen anyway since we defined a method and we're generating + // a call to it. + if (attributes[i] is ComponentAttributeIntermediateNode attribute) + { + WriteComponentAttributeInnards(context, attribute, canTypeCheck: false); + } + else if (attributes[i] is SplatIntermediateNode splat) + { + WriteSplatInnards(context, splat, canTypeCheck: false); + } + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + for (var i = 0; i < childContents.Count; i++) + { + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(", "); + + WriteComponentChildContentInnards(context, childContents[i]); + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + for (var i = 0; i < setKeys.Count; i++) + { + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(", "); + + WriteSetKeyInnards(context, setKeys[i]); + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + for (var i = 0; i < captures.Count; i++) + { + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(", "); + + WriteReferenceCaptureInnards(context, captures[i], shouldTypeCheck: false); + + remaining--; + if (remaining > 0) + { + context.CodeWriter.Write(", "); + } + } + + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + } + } + + public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + var addAttributeMethod = node.Annotations[ComponentMetadata.Common.AddAttributeMethodName] as string ?? ComponentsApi.RenderTreeBuilder.AddAttribute; + + // _builder.AddAttribute(1, "Foo", 42); + context.CodeWriter.Write(_scopeStack.BuilderVarName); + context.CodeWriter.Write("."); + context.CodeWriter.Write(addAttributeMethod); + context.CodeWriter.Write("("); + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.Write(", "); + context.CodeWriter.WriteStringLiteral(node.AttributeName); + context.CodeWriter.Write(", "); + + WriteComponentAttributeInnards(context, node, canTypeCheck: true); + + context.CodeWriter.Write(");"); + context.CodeWriter.WriteLine(); + } + + private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeIntermediateNode node, bool canTypeCheck) + { + if (node.AttributeStructure == AttributeStructure.Minimized) + { + // Minimized attributes always map to 'true' + context.CodeWriter.Write("true"); + } + else if (node.Children.Count > 1) + { + // We don't expect this to happen, we just want to know if it can. + throw new InvalidOperationException("Attribute nodes should either be minimized or a single type of content." + string.Join(", ", node.Children)); + } + else if (node.Children.Count == 1 && node.Children[0] is HtmlContentIntermediateNode htmlNode) + { + // This is how string attributes are lowered by default, a single HTML node with a single HTML token. + var content = string.Join(string.Empty, GetHtmlTokens(htmlNode).Select(t => t.Content)); + context.CodeWriter.WriteStringLiteral(content); + } + else + { + // See comments in ComponentDesignTimeNodeWriter for a description of the cases that are possible. + var tokens = GetCSharpTokens(node); + if ((node.BoundAttribute?.IsDelegateProperty() ?? false) || + (node.BoundAttribute?.IsChildContentProperty() ?? false)) + { + if (canTypeCheck) + { + context.CodeWriter.Write("new "); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write("("); + } + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + if (canTypeCheck) + { + context.CodeWriter.Write(")"); + } + } + else if (node.BoundAttribute?.IsEventCallbackProperty() ?? false) + { + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write(">"); + context.CodeWriter.Write("("); + } + + // Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, ...) OR + // Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, ...) + + context.CodeWriter.Write(ComponentsApi.EventCallback.FactoryAccessor); + context.CodeWriter.Write("."); + context.CodeWriter.Write(ComponentsApi.EventCallbackFactory.CreateMethod); + + if (node.TryParseEventCallbackTypeArgument(out var argument)) + { + context.CodeWriter.Write("<"); + context.CodeWriter.Write(argument); + context.CodeWriter.Write(">"); + } + + context.CodeWriter.Write("("); + context.CodeWriter.Write("this"); + context.CodeWriter.Write(", "); + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + context.CodeWriter.Write(")"); + + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(")"); + } + } + else + { + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(node.TypeName); + context.CodeWriter.Write(">"); + context.CodeWriter.Write("("); + } + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + if (canTypeCheck && NeedsTypeCheck(node)) + { + context.CodeWriter.Write(")"); + } + } + } + + IReadOnlyList GetHtmlTokens(HtmlContentIntermediateNode html) + { + // We generally expect all children to be HTML, this is here just in case. + return html.FindDescendantNodes().Where(t => t.IsHtml).ToArray(); + } + + bool NeedsTypeCheck(ComponentAttributeIntermediateNode n) + { + return node.BoundAttribute != null && !node.BoundAttribute.IsWeaklyTyped(); + } + } + + private IReadOnlyList GetCSharpTokens(IntermediateNode node) + { + // We generally expect all children to be CSharp, this is here just in case. + return node.FindDescendantNodes().Where(t => t.IsCSharp).ToArray(); + } + + public override void WriteComponentChildContent(CodeRenderingContext context, ComponentChildContentIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Writes something like: + // + // _builder.AddAttribute(1, "ChildContent", (RenderFragment)((__builder73) => { ... })); + // OR + // _builder.AddAttribute(1, "ChildContent", (RenderFragment)((person) => (__builder73) => { ... })); + BeginWriteAttribute(context, node.AttributeName); + context.CodeWriter.Write($"({node.TypeName})("); + + WriteComponentChildContentInnards(context, node); + + context.CodeWriter.Write(")"); + context.CodeWriter.WriteEndMethodInvocation(); + } + + private void WriteComponentChildContentInnards(CodeRenderingContext context, ComponentChildContentIntermediateNode node) + { + // Writes something like: + // + // ((__builder73) => { ... }) + // OR + // ((person) => (__builder73) => { }) + _scopeStack.OpenComponentScope( + context, + node.AttributeName, + node.IsParameterized ? node.ParameterName : null); + for (var i = 0; i < node.Children.Count; i++) + { + context.RenderNode(node.Children[i]); + } + _scopeStack.CloseScope(context); + } + + public override void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentIntermediateNode node) + { + // We can skip type arguments during runtime codegen, they are handled in the + // type/parameter declarations. + } + + public override void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // + // (__builder73) => { ... } + _scopeStack.OpenTemplateScope(context); + context.RenderChildren(node); + _scopeStack.CloseScope(context); + } + + public override void WriteSetKey(CodeRenderingContext context, SetKeyIntermediateNode node) + { + // Looks like: + // + // _builder.SetKey(_keyValue); + + var codeWriter = context.CodeWriter; + + codeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.SetKey}"); + WriteSetKeyInnards(context, node); + codeWriter.WriteEndMethodInvocation(); + } + + private void WriteSetKeyInnards(CodeRenderingContext context, SetKeyIntermediateNode node) + { + WriteCSharpCode(context, new CSharpCodeIntermediateNode + { + Source = node.Source, + Children = + { + node.KeyValueToken + } + }); + } + + public override void WriteSplat(CodeRenderingContext context, SplatIntermediateNode node) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (node == null) + { + throw new ArgumentNullException(nameof(node)); + } + + // Looks like: + // + // _builder.AddMultipleAttributes(2, ...); + context.CodeWriter.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddMultipleAttributes}"); + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.WriteParameterSeparator(); + + WriteSplatInnards(context, node, canTypeCheck: true); + + context.CodeWriter.WriteEndMethodInvocation(); + } + + private void WriteSplatInnards(CodeRenderingContext context, SplatIntermediateNode node, bool canTypeCheck) + { + var tokens = GetCSharpTokens(node); + + if (canTypeCheck) + { + context.CodeWriter.Write(ComponentsApi.RuntimeHelpers.TypeCheck); + context.CodeWriter.Write("<"); + context.CodeWriter.Write(ComponentsApi.AddMultipleAttributesTypeFullName); + context.CodeWriter.Write(">"); + context.CodeWriter.Write("("); + } + + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + if (canTypeCheck) + { + context.CodeWriter.Write(")"); + } + } + + public override void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node) + { + // Looks like: + // + // _builder.AddComponentReferenceCapture(2, (__value) = { _field = (MyComponent)__value; }); + // OR + // _builder.AddElementReferenceCapture(2, (__value) = { _field = (ElementReference)__value; }); + var codeWriter = context.CodeWriter; + + var methodName = node.IsComponentCapture + ? ComponentsApi.RenderTreeBuilder.AddComponentReferenceCapture + : ComponentsApi.RenderTreeBuilder.AddElementReferenceCapture; + codeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{methodName}") + .Write((_sourceSequence++).ToString()) + .WriteParameterSeparator(); + + WriteReferenceCaptureInnards(context, node, shouldTypeCheck: true); + + codeWriter.WriteEndMethodInvocation(); + } + + protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, ReferenceCaptureIntermediateNode node, bool shouldTypeCheck) + { + // Looks like: + // + // (__value) = { _field = (MyComponent)__value; } + // OR + // (__value) = { _field = (ElementRef)__value; } + const string refCaptureParamName = "__value"; + using (var lambdaScope = context.CodeWriter.BuildLambda(refCaptureParamName)) + { + var typecastIfNeeded = shouldTypeCheck && node.IsComponentCapture ? $"({node.ComponentCaptureTypeName})" : string.Empty; + WriteCSharpCode(context, new CSharpCodeIntermediateNode + { + Source = node.Source, + Children = + { + node.IdentifierToken, + new IntermediateToken + { + Kind = TokenKind.CSharp, + Content = $" = {typecastIfNeeded}{refCaptureParamName};" + } + } + }); + } + } + + private void WriteAttribute(CodeRenderingContext context, string key, IList value) + { + BeginWriteAttribute(context, key); + WriteAttributeValue(context, value); + context.CodeWriter.WriteEndMethodInvocation(); + } + + private void WriteAttribute(CodeRenderingContext context, IntermediateNode nameExpression, IList value) + { + BeginWriteAttribute(context, nameExpression); + WriteAttributeValue(context, value); + context.CodeWriter.WriteEndMethodInvocation(); + } + + protected override void BeginWriteAttribute(CodeRenderingContext context, string key) + { + context.CodeWriter + .WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddAttribute}") + .Write((_sourceSequence++).ToString()) + .WriteParameterSeparator() + .WriteStringLiteral(key) + .WriteParameterSeparator(); + } + + protected override void BeginWriteAttribute(CodeRenderingContext context, IntermediateNode nameExpression) + { + context.CodeWriter.WriteStartMethodInvocation($"{_scopeStack.BuilderVarName}.{ComponentsApi.RenderTreeBuilder.AddAttribute}"); + context.CodeWriter.Write((_sourceSequence++).ToString()); + context.CodeWriter.WriteParameterSeparator(); + + var tokens = GetCSharpTokens(nameExpression); + for (var i = 0; i < tokens.Count; i++) + { + WriteCSharpToken(context, tokens[i]); + } + + context.CodeWriter.WriteParameterSeparator(); + } + + private static string GetHtmlContent(HtmlContentIntermediateNode node) + { + var builder = new StringBuilder(); + var htmlTokens = node.Children.OfType().Where(t => t.IsHtml); + foreach (var htmlToken in htmlTokens) + { + builder.Append(htmlToken.Content); + } + return builder.ToString(); + } + + // There are a few cases here, we need to handle: + // - Pure HTML + // - Pure CSharp + // - Mixed HTML and CSharp + // + // Only the mixed case is complicated, we want to turn it into code that will concatenate + // the values into a string at runtime. + + private static void WriteAttributeValue(CodeRenderingContext context, IList tokens) + { + if (tokens == null) + { + throw new ArgumentNullException(nameof(tokens)); + } + + var writer = context.CodeWriter; + var hasHtml = false; + var hasCSharp = false; + for (var i = 0; i < tokens.Count; i++) + { + if (tokens[i].IsCSharp) + { + hasCSharp |= true; + } + else + { + hasHtml |= true; + } + } + + if (hasHtml && hasCSharp) + { + // If it's a C# expression, we have to wrap it in parens, otherwise things like ternary + // expressions don't compose with concatenation. However, this is a little complicated + // because C# tokens themselves aren't guaranteed to be distinct expressions. We want + // to treat all contiguous C# tokens as a single expression. + var insideCSharp = false; + for (var i = 0; i < tokens.Count; i++) + { + var token = tokens[i]; + if (token.IsCSharp) + { + if (!insideCSharp) + { + if (i != 0) + { + writer.Write(" + "); + } + + writer.Write("("); + insideCSharp = true; + } + + WriteCSharpToken(context, token); + } + else + { + if (insideCSharp) + { + writer.Write(")"); + insideCSharp = false; + } + + if (i != 0) + { + writer.Write(" + "); + } + + writer.WriteStringLiteral(token.Content); + } + } + + if (insideCSharp) + { + writer.Write(")"); + } + } + else if (hasCSharp) + { + foreach (var token in tokens) + { + WriteCSharpToken(context, token); + } + } + else if (hasHtml) + { + writer.WriteStringLiteral(string.Join("", tokens.Select(t => t.Content))); + } + else + { + // Minimized attributes always map to 'true' + writer.Write("true"); + } + } + + private static void WriteCSharpToken(CodeRenderingContext context, IntermediateToken token) + { + if (string.IsNullOrWhiteSpace(token.Content)) + { + return; + } + + if (token.Source?.FilePath == null) + { + context.CodeWriter.Write(token.Content); + return; + } + + using (context.CodeWriter.BuildLinePragma(token.Source, context)) + { + context.CodeWriter.WritePadding(0, token.Source.Value, context); + context.CodeWriter.Write(token.Content); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentScriptTagPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentScriptTagPass.cs new file mode 100644 index 0000000000..6fad5cfca5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentScriptTagPass.cs @@ -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.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal class ComponentScriptTagPass : ComponentIntermediateNodePassBase, IRazorDocumentClassifierPass + { + // Run as soon as possible after the Component rewrite pass + public override int Order => 5; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + if (!IsComponentDocument(documentNode)) + { + return; + } + + var visitor = new Visitor(); + visitor.Visit(documentNode); + } + + private class Visitor : IntermediateNodeWalker + { + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + // Disallow + + } +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.FindDescendantNodes()); + } + + [Fact] + public void Execute_CannotRewriteHtml_SelectOption() + { + // Arrange + var document = CreateDocument(@" + + @if (some_bool) + { + + + + } +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.FindDescendantNodes()); + } + + [Fact] + public void Execute_CanRewriteHtml_OptionWithNoSelectAncestor() + { + // Arrange + var document = CreateDocument(@" + + @if (some_bool) + { + + + + + } +"); + + var expected = NormalizeContent(@" + + + + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var block = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); + } + + // The unclosed tag will have errors, so we won't rewrite it or its parent. + [Fact] + public void Execute_CannotRewriteHtml_Errors() + { + // Arrange + var document = CreateDocument(@" + + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.FindDescendantNodes()); + } + + // We want duplicate attributes to result in an error and prevent rewriting. + // + // This is because Blazor de-duplicates attributes differently from browsers, so we don't + // want to allow any markup blocks to exist with duplicate attributes or else they will have + // the browser's behavior. + [Fact] + public void Execute_CannotRewriteHtml_DuplicateAttribute() + { + // Arrange + var document = CreateDocument(@" + + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.FindDescendantNodes()); + + var diagnostic = Assert.Single(documentNode.GetAllDiagnostics()); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + } + + [Fact] + public void Execute_RewritesHtml_MismatchedClosingTag() + { + // Arrange + var document = CreateDocument(@" + +
+
rewriteme
+ +"); + + var expected = NormalizeContent("
rewriteme
\n "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var block = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); + } + + private string NormalizeContent(string content) + { + // Test inputs frequently have leading space for readability. + content = content.TrimStart(); + + // Normalize newlines since we are testing lengths of things. + content = content.Replace("\r", ""); + content = content.Replace("\n", "\r\n"); + + return content; + } + + private RazorCodeDocument CreateDocument(string content) + { + // Normalize newlines since we are testing lengths of things. + content = content.Replace("\r", ""); + content = content.Replace("\n", "\r\n"); + + var source = RazorSourceDocument.Create(content, "test.cshtml"); + return ProjectEngine.CreateCodeDocumentCore(source, FileKinds.Component); + } + + private DocumentIntermediateNode Lower(RazorCodeDocument codeDocument) + { + for (var i = 0; i < Engine.Phases.Count; i++) + { + var phase = Engine.Phases[i]; + if (phase is IRazorCSharpLoweringPhase) + { + break; + } + + phase.Execute(codeDocument); + } + + var document = codeDocument.GetDocumentIntermediateNode(); + Engine.Features.OfType().Single().Execute(codeDocument, document); + Engine.Features.OfType().Single().Execute(codeDocument, document); + return document; + } + + private class StaticTagHelperFeature : ITagHelperFeature + { + public RazorEngine Engine { get; set; } + + public List TagHelpers { get; set; } + + public IReadOnlyList GetDescriptors() + { + return TagHelpers; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupEncodingPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupEncodingPassTest.cs new file mode 100644 index 0000000000..710d3d4457 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupEncodingPassTest.cs @@ -0,0 +1,221 @@ +// 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.Linq; +using System.Text; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + public class ComponentMarkupEncodingPassTest + { + public ComponentMarkupEncodingPassTest() + { + Pass = new ComponentMarkupEncodingPass(); + ProjectEngine = (DefaultRazorProjectEngine)RazorProjectEngine.Create( + RazorConfiguration.Default, + RazorProjectFileSystem.Create(Environment.CurrentDirectory), + b => + { + if (b.Features.OfType().Any()) + { + b.Features.Remove(b.Features.OfType().Single()); + } + }); + Engine = ProjectEngine.Engine; + + Pass.Engine = Engine; + } + + private DefaultRazorProjectEngine ProjectEngine { get; } + + private RazorEngine Engine { get; } + + private ComponentMarkupEncodingPass Pass { get; } + + [Fact] + public void Execute_StaticHtmlContent_RewrittenToBlock() + { + // Arrange + var document = CreateDocument(@" +
+  +
"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.FindDescendantNodes()); + Assert.Single(documentNode.FindDescendantNodes()); + } + + [Fact] + public void Execute_MixedHtmlContent_NoNewLineorSpecialCharacters_DoesNotSetEncoded() + { + // Arrange + var document = CreateDocument(@" +
The time is @DateTime.Now
"); + var expected = NormalizeContent("The time is "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var node = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, GetHtmlContent(node)); + Assert.False(node.IsEncoded()); + } + + [Fact] + public void Execute_MixedHtmlContent_NewLine_SetsEncoded() + { + // Arrange + var document = CreateDocument(@" +
+The time is @DateTime.Now
"); + var expected = NormalizeContent(@" +The time is "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var node = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, GetHtmlContent(node)); + Assert.True(node.IsEncoded()); + } + + [Fact] + public void Execute_MixedHtmlContent_Ampersand_SetsEncoded() + { + // Arrange + var document = CreateDocument(@" +
The time is & & @DateTime.Now
"); + var expected = NormalizeContent("The time is & & "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var node = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, GetHtmlContent(node)); + Assert.True(node.IsEncoded()); + } + + [Fact] + public void Execute_MixedHtmlContent_NonAsciiCharacter_SetsEncoded() + { + // Arrange + var document = CreateDocument(@" +
ThĖ tĨme is @DateTime.Now
"); + var expected = NormalizeContent("ThĖ tĨme is "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var node = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, GetHtmlContent(node)); + Assert.True(node.IsEncoded()); + } + + [Fact] + public void Execute_MixedHtmlContent_HTMLEntity_DoesNotSetEncoded() + { + // Arrange + var document = CreateDocument(@" +
The time = @DateTime.Now
"); + var expected = NormalizeContent("The time = "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var node = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, GetHtmlContent(node)); + Assert.False(node.IsEncoded()); + } + + [Fact] + public void Execute_MixedHtmlContent_MultipleHTMLEntities_DoesNotSetEncoded() + { + // Arrange + var document = CreateDocument(@" +
The time = =�x003D; @DateTime.Now
"); + var expected = NormalizeContent("The time =\u00A0== "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var node = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, GetHtmlContent(node)); + Assert.False(node.IsEncoded()); + } + + private string NormalizeContent(string content) + { + // Normalize newlines since we are testing lengths of things. + content = content.Replace("\r", ""); + content = content.Replace("\n", "\r\n"); + + return content; + } + + private RazorCodeDocument CreateDocument(string content) + { + // Normalize newlines since we are testing lengths of things. + content = content.Replace("\r", ""); + content = content.Replace("\n", "\r\n"); + + var source = RazorSourceDocument.Create(content, "test.cshtml"); + return ProjectEngine.CreateCodeDocumentCore(source, FileKinds.Component); + } + + private DocumentIntermediateNode Lower(RazorCodeDocument codeDocument) + { + for (var i = 0; i < Engine.Phases.Count; i++) + { + var phase = Engine.Phases[i]; + if (phase is IRazorCSharpLoweringPhase) + { + break; + } + + phase.Execute(codeDocument); + } + + var document = codeDocument.GetDocumentIntermediateNode(); + Engine.Features.OfType().Single().Execute(codeDocument, document); + return document; + } + + private static string GetHtmlContent(HtmlContentIntermediateNode node) + { + var builder = new StringBuilder(); + var htmlTokens = node.Children.OfType().Where(t => t.IsHtml); + foreach (var htmlToken in htmlTokens) + { + builder.Append(htmlToken.Content); + } + return builder.ToString(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/NodeAssert.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/NodeAssert.cs new file mode 100644 index 0000000000..aae834c256 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/NodeAssert.cs @@ -0,0 +1,126 @@ +// 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.Text; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal static class NodeAssert + { + public static HtmlAttributeIntermediateNode Attribute(IntermediateNode node, string attributeName, string attributeValue) + { + Assert.NotNull(node); + + var attributeNode = Assert.IsType(node); + Assert.Equal(attributeName, attributeNode.AttributeName); + + var attributeValueNode = Assert.IsType(Assert.Single(attributeNode.Children)); + var actual = new StringBuilder(); + for (var i = 0; i < attributeValueNode.Children.Count; i++) + { + var token = Assert.IsType(attributeValueNode.Children[i]); + Assert.Equal(TokenKind.Html, token.Kind); + actual.Append(token.Content); + } + + Assert.Equal(attributeValue, actual.ToString()); + + return attributeNode; + } + + public static HtmlAttributeIntermediateNode Attribute(IntermediateNodeCollection nodes, string attributeName, string attributeValue) + { + Assert.NotNull(nodes); + return Attribute(Assert.Single(nodes), attributeName, attributeValue); + } + + public static HtmlContentIntermediateNode Content(IntermediateNode node, string content, bool trim = true) + { + Assert.NotNull(node); + + var contentNode = Assert.IsType(node); + + var actual = new StringBuilder(); + for (var i = 0; i < contentNode.Children.Count; i++) + { + var token = Assert.IsType(contentNode.Children[i]); + Assert.Equal(TokenKind.Html, token.Kind); + actual.Append(token.Content); + } + + Assert.Equal(content, trim ? actual.ToString().Trim() : actual.ToString()); + return contentNode; + } + + public static HtmlContentIntermediateNode Content(IntermediateNodeCollection nodes, string content, bool trim = true) + { + Assert.NotNull(nodes); + return Content(Assert.Single(nodes), content, trim); + } + + public static HtmlAttributeIntermediateNode CSharpAttribute(IntermediateNode node, string attributeName, string attributeValue) + { + Assert.NotNull(node); + + var attributeNode = Assert.IsType(node); + Assert.Equal(attributeName, attributeNode.AttributeName); + + var attributeValueNode = Assert.IsType(Assert.Single(attributeNode.Children)); + var actual = new StringBuilder(); + for (var i = 0; i < attributeValueNode.Children.Count; i++) + { + var token = Assert.IsType(attributeValueNode.Children[i]); + Assert.Equal(TokenKind.CSharp, token.Kind); + actual.Append(token.Content); + } + + Assert.Equal(attributeValue, actual.ToString()); + + return attributeNode; + } + + public static HtmlAttributeIntermediateNode CSharpAttribute(IntermediateNodeCollection nodes, string attributeName, string attributeValue) + { + Assert.NotNull(nodes); + return Attribute(Assert.Single(nodes), attributeName, attributeValue); + } + + public static MarkupElementIntermediateNode Element(IntermediateNode node, string tagName) + { + Assert.NotNull(node); + + var elementNode = Assert.IsType(node); + Assert.Equal(tagName, elementNode.TagName); + return elementNode; + } + + public static MarkupElementIntermediateNode Element(IntermediateNodeCollection nodes, string tagName) + { + Assert.NotNull(nodes); + return Element(Assert.Single(nodes), tagName); + } + + public static HtmlContentIntermediateNode Whitespace(IntermediateNode node) + { + Assert.NotNull(node); + + var contentNode = Assert.IsType(node); + for (var i = 0; i < contentNode.Children.Count; i++) + { + var token = Assert.IsType(contentNode.Children[i]); + Assert.Equal(TokenKind.Html, token.Kind); + Assert.True(string.IsNullOrWhiteSpace(token.Content)); + } + + return contentNode; + } + + public static HtmlContentIntermediateNode Whitespace(IntermediateNodeCollection nodes) + { + Assert.NotNull(nodes); + return Whitespace(Assert.Single(nodes)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultAllowedChildTagDescriptorBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultAllowedChildTagDescriptorBuilderTest.cs new file mode 100644 index 0000000000..2a6b2a8198 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultAllowedChildTagDescriptorBuilderTest.cs @@ -0,0 +1,24 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultAllowedChildTagDescriptorBuilderTest + { + [Fact] + public void Build_DisplayNameIsName() + { + // Arrange + var builder = new DefaultAllowedChildTagDescriptorBuilder(null); + builder.Name = "foo"; + + // Act + var descriptor = builder.Build(); + + // Assert + Assert.Equal("foo", descriptor.DisplayName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultBoundAttributeDescriptorBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultBoundAttributeDescriptorBuilderTest.cs new file mode 100644 index 0000000000..52317aa157 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultBoundAttributeDescriptorBuilderTest.cs @@ -0,0 +1,47 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultBoundAttributeDescriptorBuilderTest + { + [Fact] + public void DisplayName_SetsDescriptorsDisplayName() + { + // Arrange + var expectedDisplayName = "ExpectedDisplayName"; + + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + + var builder = new DefaultBoundAttributeDescriptorBuilder(tagHelperBuilder, TagHelperConventions.DefaultKind); + builder.DisplayName(expectedDisplayName); + + // Act + var descriptor = builder.Build(); + + // Assert + Assert.Equal(expectedDisplayName, descriptor.DisplayName); + } + + [Fact] + public void DisplayName_DefaultsToPropertyLookingDisplayName() + { + // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + tagHelperBuilder.TypeName("TestTagHelper"); + + var builder = new DefaultBoundAttributeDescriptorBuilder(tagHelperBuilder, TagHelperConventions.DefaultKind); + builder + .TypeName(typeof(int).FullName) + .PropertyName("SomeProperty"); + + // Act + var descriptor = builder.Build(); + + // Assert + Assert.Equal("int TestTagHelper.SomeProperty", descriptor.DisplayName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultDocumentClassifierPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultDocumentClassifierPassTest.cs new file mode 100644 index 0000000000..218d3da90d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultDocumentClassifierPassTest.cs @@ -0,0 +1,62 @@ +// 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.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language +{ + // We're purposely lean on tests here because the functionality is well covered by + // integration tests, and is mostly implemented by the base class. + public class DefaultDocumentClassifierPassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + + [Fact] + public void Execute_IgnoresDocumentsWithDocumentKind() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + DocumentKind = "ignore", + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var pass = new DefaultDocumentClassifierPass(); + pass.Engine = CreateProjectEngine().Engine; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + Assert.Equal("ignore", documentNode.DocumentKind); + NoChildren(documentNode); + } + + [Fact] + public void Execute_CreatesClassStructure() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var pass = new DefaultDocumentClassifierPass(); + pass.Engine = CreateProjectEngine().Engine; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + Assert.Equal("default", documentNode.DocumentKind); + + var @namespace = SingleChild(documentNode); + var @class = SingleChild(@namespace); + var method = SingleChild(@class); + NoChildren(method); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultItemCollectionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultItemCollectionTest.cs new file mode 100644 index 0000000000..aee4d07fe0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultItemCollectionTest.cs @@ -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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class ItemCollectionTest + { + [Fact] + public void Get_MissingValueReturnsNull() + { + // Arrange + var items = new ItemCollection(); + + // Act + var value = items["foo"]; + + // Assert + Assert.Null(value); + } + + [Fact] + public void GetAndSet_ReturnsValue() + { + // Arrange + var items = new ItemCollection(); + + var expected = "bar"; + items["foo"] = expected; + + // Act + var value = items["foo"]; + + // Assert + Assert.Same(expected, value); + } + + [Fact] + public void Set_CanSetValueToNull() + { + // Arrange + var items = new ItemCollection(); + + items["foo"] = "bar"; + + // Act + items["foo"] = null; + + // Assert + Assert.Null(items["foo"]); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs new file mode 100644 index 0000000000..e76c97557f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCSharpLoweringPhaseTest.cs @@ -0,0 +1,87 @@ +// 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; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorCSharpLoweringPhaseTest + { + [Fact] + public void Execute_ThrowsForMissingDependency_IRDocument() + { + // Arrange + var phase = new DefaultRazorCSharpLoweringPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source)); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The '{nameof(DefaultRazorCSharpLoweringPhase)}' phase requires a '{nameof(DocumentIntermediateNode)}' " + + $"provided by the '{nameof(RazorCodeDocument)}'."); + } + + [Fact] + public void Execute_ThrowsForMissingDependency_CodeTarget() + { + // Arrange + var phase = new DefaultRazorCSharpLoweringPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source)); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + }; + codeDocument.SetDocumentIntermediateNode(irDocument); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The document of kind 'test' does not have a '{nameof(CodeTarget)}'. " + + $"The document classifier must set a value for '{nameof(DocumentIntermediateNode.Target)}'."); + } + + [Fact] + public void Execute_CollatesIRDocumentDiagnosticsFromSourceDocument() + { + // Arrange + var phase = new DefaultRazorCSharpLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + var codeDocument = TestRazorCodeDocument.Create("

"I am an error.", RazorDiagnosticSeverity.Error), + new SourceSpan("SomeFile.cshtml", 11, 0, 11, 1)); + irDocument.Diagnostics.Add(expectedDiagnostic); + codeDocument.SetDocumentIntermediateNode(irDocument); + + // Act + phase.Execute(codeDocument); + + // Assert + var csharpDocument = codeDocument.GetCSharpDocument(); + var diagnostic = Assert.Single(csharpDocument.Diagnostics); + Assert.Same(expectedDiagnostic, diagnostic); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCodeDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCodeDocumentTest.cs new file mode 100644 index 0000000000..415dcadb3b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorCodeDocumentTest.cs @@ -0,0 +1,47 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorCodeDocumentTest + { + [Fact] + public void Ctor() + { + // Arrange + var source = TestRazorSourceDocument.Create(); + + var imports = new RazorSourceDocument[] + { + TestRazorSourceDocument.Create(), + }; + + // Act + var code = new DefaultRazorCodeDocument(source, imports); + + // Assert + Assert.Same(source, code.Source); + Assert.NotNull(code.Items); + + Assert.NotSame(imports, code.Imports); + Assert.Collection(imports, d => Assert.Same(imports[0], d)); + } + + [Fact] + public void Ctor_AllowsNullForImports() + { + // Arrange + var source = TestRazorSourceDocument.Create(); + + // Act + var code = new DefaultRazorCodeDocument(source, imports: null); + + // Assert + Assert.Same(source, code.Source); + Assert.NotNull(code.Items); + Assert.Empty(code.Imports); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDiagnosticTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDiagnosticTest.cs new file mode 100644 index 0000000000..bf8f3099ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDiagnosticTest.cs @@ -0,0 +1,217 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorDiagnosticTest + { + [Fact] + public void DefaultRazorDiagnostic_Ctor() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "error", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + // Act + var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + + // Assert + Assert.Equal("RZ0000", diagnostic.Id); + Assert.Equal(RazorDiagnosticSeverity.Error, diagnostic.Severity); + Assert.Equal(span, diagnostic.Span); + } + + [Fact] + public void DefaultRazorDiagnostic_GetMessage() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "error", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + + // Act + var result = diagnostic.GetMessage(); + + // Assert + Assert.Equal("error", result); + } + + + [Fact] + public void DefaultRazorDiagnostic_GetMessage_WithArgs() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new[] { "error" }); + + // Act + var result = diagnostic.GetMessage(); + + // Assert + Assert.Equal("this is an error", result); + } + + [Fact] + public void DefaultRazorDiagnostic_GetMessage_WithArgs_FormatProvider() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m }); + + // Act + var result = diagnostic.GetMessage(new CultureInfo("fr-FR")); + + // Assert + Assert.Equal("this is an 1,3", result); + } + + + [Fact] + public void DefaultRazorDiagnostic_ToString() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an error", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + + // Act + var result = diagnostic.ToString(); + + // Assert + Assert.Equal("test.cs(2,9): Error RZ0000: this is an error", result); + } + + [Fact] + public void DefaultRazorDiagnostic_ToString_FormatProvider() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m }); + + // Act + var result = ((IFormattable)diagnostic).ToString("ignored", new CultureInfo("fr-FR")); + + // Assert + Assert.Equal("test.cs(2,9): Error RZ0000: this is an 1,3", result); + } + + [Fact] + public void DefaultRazorDiagnostic_Equals() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic1 = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + var diagnostic2 = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + + // Act + var result = diagnostic1.Equals(diagnostic2); + + // Assert + Assert.True(result); + } + + [Fact] + public void DefaultRazorDiagnostic_NotEquals_DifferentLocation() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span1 = new SourceSpan("test.cs", 15, 1, 8, 5); + var span2 = new SourceSpan("test.cs", 15, 1, 8, 3); + + var diagnostic1 = new DefaultRazorDiagnostic(descriptor, span1, new object[0]); + var diagnostic2 = new DefaultRazorDiagnostic(descriptor, span2, new object[0]); + + // Act + var result = diagnostic1.Equals(diagnostic2); + + // Assert + Assert.False(result); + } + + [Fact] + public void DefaultRazorDiagnostic_NotEquals_DifferentId() + { + // Arrange + var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var descriptor2 = new RazorDiagnosticDescriptor("RZ0002", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic1 = new DefaultRazorDiagnostic(descriptor1, span, new object[0]); + var diagnostic2 = new DefaultRazorDiagnostic(descriptor2, span, new object[0]); + + // Act + var result = diagnostic1.Equals(diagnostic2); + + // Assert + Assert.False(result); + } + + [Fact] + public void DefaultRazorDiagnostic_HashCodesEqual() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic1 = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + var diagnostic2 = new DefaultRazorDiagnostic(descriptor, span, new object[0]); + + // Act + var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); + + // Assert + Assert.True(result); + } + + [Fact] + public void DefaultRazorDiagnostic_HashCodesNotEqual_DifferentLocation() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0000", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span1 = new SourceSpan("test.cs", 15, 1, 8, 5); + var span2 = new SourceSpan("test.cs", 15, 1, 8, 3); + + var diagnostic1 = new DefaultRazorDiagnostic(descriptor, span1, new object[0]); + var diagnostic2 = new DefaultRazorDiagnostic(descriptor, span2, new object[0]); + + // Act + var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); + + // Assert + Assert.False(result); + } + + [Fact] + public void DefaultRazorDiagnostic_HashCodesNotEqual_DifferentId() + { + // Arrange + var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var descriptor2 = new RazorDiagnosticDescriptor("RZ0002", () => "this is an {0}", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + var diagnostic1 = new DefaultRazorDiagnostic(descriptor1, span, new object[0]); + var diagnostic2 = new DefaultRazorDiagnostic(descriptor2, span, new object[0]); + + // Act + var result = diagnostic1.GetHashCode() == diagnostic2.GetHashCode(); + + // Assert + Assert.False(result); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDirectiveClassifierPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDirectiveClassifierPhaseTest.cs new file mode 100644 index 0000000000..306be8c445 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDirectiveClassifierPhaseTest.cs @@ -0,0 +1,102 @@ +// 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.Intermediate; +using Microsoft.AspNetCore.Testing; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorDirectiveClassifierPhaseTest + { + [Fact] + public void OnInitialized_OrdersPassesInAscendingOrder() + { + // Arrange & Act + var phase = new DefaultRazorDirectiveClassifierPhase(); + + var first = Mock.Of(p => p.Order == 15); + var second = Mock.Of(p => p.Order == 17); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(second); + b.Features.Add(first); + }); + + // Assert + Assert.Collection( + phase.Passes, + p => Assert.Same(first, p), + p => Assert.Same(second, p)); + } + + [Fact] + public void Execute_ThrowsForMissingDependency() + { + // Arrange + var phase = new DefaultRazorDirectiveClassifierPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The '{nameof(DefaultRazorDirectiveClassifierPhase)}' phase requires a '{nameof(DocumentIntermediateNode)}' " + + $"provided by the '{nameof(RazorCodeDocument)}'."); + } + + [Fact] + public void Execute_ExecutesPhasesInOrder() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // We're going to set up mocks to simulate a sequence of passes. We don't care about + // what's in the nodes, we're just going to look at the identity via strict mocks. + var originalNode = new DocumentIntermediateNode(); + var firstPassNode = new DocumentIntermediateNode(); + var secondPassNode = new DocumentIntermediateNode(); + codeDocument.SetDocumentIntermediateNode(originalNode); + + var firstPass = new Mock(MockBehavior.Strict); + firstPass.SetupGet(m => m.Order).Returns(0); + firstPass.SetupProperty(m => m.Engine); + firstPass.Setup(m => m.Execute(codeDocument, originalNode)).Callback(() => + { + originalNode.Children.Add(firstPassNode); + }); + + var secondPass = new Mock(MockBehavior.Strict); + secondPass.SetupGet(m => m.Order).Returns(1); + secondPass.SetupProperty(m => m.Engine); + secondPass.Setup(m => m.Execute(codeDocument, originalNode)).Callback(() => + { + // Works only when the first pass has run before this. + originalNode.Children[0].Children.Add(secondPassNode); + }); + + var phase = new DefaultRazorDirectiveClassifierPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(firstPass.Object); + b.Features.Add(secondPass.Object); + }); + + // Act + phase.Execute(codeDocument); + + // Assert + Assert.Same(secondPassNode, codeDocument.GetDocumentIntermediateNode().Children[0].Children[0]); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDocumentClassifierPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDocumentClassifierPhaseTest.cs new file mode 100644 index 0000000000..0f384b851e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorDocumentClassifierPhaseTest.cs @@ -0,0 +1,102 @@ +// 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.Intermediate; +using Microsoft.AspNetCore.Testing; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorDocumentClassifierPhaseTest + { + [Fact] + public void OnInitialized_OrdersPassesInAscendingOrder() + { + // Arrange & Act + var phase = new DefaultRazorDocumentClassifierPhase(); + + var first = Mock.Of(p => p.Order == 15); + var second = Mock.Of(p => p.Order == 17); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(second); + b.Features.Add(first); + }); + + // Assert + Assert.Collection( + phase.Passes, + p => Assert.Same(first, p), + p => Assert.Same(second, p)); + } + + [Fact] + public void Execute_ThrowsForMissingDependency() + { + // Arrange + var phase = new DefaultRazorDocumentClassifierPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The '{nameof(DefaultRazorDocumentClassifierPhase)}' phase requires a '{nameof(DocumentIntermediateNode)}' " + + $"provided by the '{nameof(RazorCodeDocument)}'."); + } + + [Fact] + public void Execute_ExecutesPhasesInOrder() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // We're going to set up mocks to simulate a sequence of passes. We don't care about + // what's in the nodes, we're just going to look at the identity via strict mocks. + var originalNode = new DocumentIntermediateNode(); + var firstPassNode = new DocumentIntermediateNode(); + var secondPassNode = new DocumentIntermediateNode(); + codeDocument.SetDocumentIntermediateNode(originalNode); + + var firstPass = new Mock(MockBehavior.Strict); + firstPass.SetupGet(m => m.Order).Returns(0); + firstPass.SetupProperty(m => m.Engine); + firstPass.Setup(m => m.Execute(codeDocument, originalNode)).Callback(() => + { + originalNode.Children.Add(firstPassNode); + }); + + var secondPass = new Mock(MockBehavior.Strict); + secondPass.SetupGet(m => m.Order).Returns(1); + secondPass.SetupProperty(m => m.Engine); + secondPass.Setup(m => m.Execute(codeDocument, originalNode)).Callback(() => + { + // Works only when the first pass has run before this. + originalNode.Children[0].Children.Add(secondPassNode); + }); + + var phase = new DefaultRazorDocumentClassifierPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(firstPass.Object); + b.Features.Add(secondPass.Object); + }); + + // Act + phase.Execute(codeDocument); + + // Assert + Assert.Same(secondPassNode, codeDocument.GetDocumentIntermediateNode().Children[0].Children[0]); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorEngineBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorEngineBuilderTest.cs new file mode 100644 index 0000000000..a1c804287a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorEngineBuilderTest.cs @@ -0,0 +1,42 @@ +// 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.Linq; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorEngineBuilderTest + { + [Fact] + public void Build_AddsFeaturesAndPhases() + { + // Arrange + var builder = new DefaultRazorEngineBuilder(designTime: false); + + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + + builder.Phases.Add(Mock.Of()); + builder.Phases.Add(Mock.Of()); + + var features = builder.Features.ToArray(); + var phases = builder.Phases.ToArray(); + + // Act + var engine = builder.Build(); + + // Assert + Assert.Collection( + engine.Features, + f => Assert.Same(features[0], f), + f => Assert.Same(features[1], f)); + + Assert.Collection( + engine.Phases, + p => Assert.Same(phases[0], p), + p => Assert.Same(phases[1], p)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorEngineTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorEngineTest.cs new file mode 100644 index 0000000000..15b3122969 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorEngineTest.cs @@ -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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorEngineTest + { + [Fact] + public void Ctor_InitializesPhasesAndFeatures() + { + // Arrange + var features = new IRazorEngineFeature[] + { + Mock.Of(), + Mock.Of(), + }; + + var phases = new IRazorEnginePhase[] + { + Mock.Of(), + Mock.Of(), + }; + + // Act + var engine = new DefaultRazorEngine(features, phases); + + // Assert + for (var i = 0; i < features.Length; i++) + { + Assert.Same(engine, features[i].Engine); + } + + for (var i = 0; i < phases.Length; i++) + { + Assert.Same(engine, phases[i].Engine); + } + } + + [Fact] + public void Process_CallsAllPhases() + { + // Arrange + var features = new IRazorEngineFeature[] + { + Mock.Of(), + Mock.Of(), + }; + + var phases = new IRazorEnginePhase[] + { + Mock.Of(), + Mock.Of(), + }; + + var engine = new DefaultRazorEngine(features, phases); + var document = TestRazorCodeDocument.CreateEmpty(); + + // Act + engine.Process(document); + + // Assert + for (var i = 0; i < phases.Length; i++) + { + var mock = Mock.Get(phases[i]); + mock.Verify(p => p.Execute(document), Times.Once()); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs new file mode 100644 index 0000000000..4d008b89d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs @@ -0,0 +1,541 @@ +// 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.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Moq; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest + { + [Fact] + public void Lower_SetsOptions_Defaults() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Assert.NotNull(documentNode.Options); + Assert.False(documentNode.Options.DesignTime); + Assert.Equal(4, documentNode.Options.IndentSize); + Assert.False(documentNode.Options.IndentWithTabs); + } + + [Fact] + public void Lower_SetsOptions_RunsConfigureCallbacks() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var callback = new Mock(); + callback + .Setup(c => c.Configure(It.IsAny())) + .Callback(o => + { + o.IndentSize = 17; + o.IndentWithTabs = true; + o.SuppressChecksum = true; + }); + + // Act + var documentNode = Lower( + codeDocument, + builder: b => + { + b.Features.Add(callback.Object); + }, + designTime: true); + + // Assert + Assert.NotNull(documentNode.Options); + Assert.True(documentNode.Options.DesignTime); + Assert.Equal(17, documentNode.Options.IndentSize); + Assert.True(documentNode.Options.IndentWithTabs); + Assert.True(documentNode.Options.SuppressChecksum); + } + + [Fact] + public void Lower_HelloWorld() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create("Hello, World!"); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children(documentNode, + n => Html("Hello, World!", n)); + } + + [Fact] + public void Lower_HtmlWithDataDashAttributes() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@" + + + + +"); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children(documentNode, + n => Html( +@" + + + CSharpExpression("Hello", n), + n => Html(@""" /> + +", n)); + } + + [Fact] + public void Lower_HtmlWithConditionalAttributes() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@" + + + + +"); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children(documentNode, + n => Html( +@" + + + ConditionalAttribute( + prefix: " val=\"", + name: "val", + suffix: "\"", + node: n, + valueValidators: new Action[] + { + value => CSharpExpressionAttributeValue(string.Empty, "Hello", value), + value => LiteralAttributeValue(" ", "World", value) + }), + n => Html(@" /> + +", n)); + } + + [Fact] + public void Lower_WithFunctions() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@functions { public int Foo { get; set; }}"); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children(documentNode, + n => Directive( + "functions", + n, + c => Assert.IsType(c))); + } + + [Fact] + public void Lower_WithUsing() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@using System"); + var expectedSourceLocation = new SourceSpan(codeDocument.Source.FilePath, 1, 0, 1, 12); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children(documentNode, + n => + { + Using("System", n); + Assert.Equal(expectedSourceLocation, n.Source); + }); + } + + [Fact] + public void Lower_TagHelpers() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@addTagHelper *, TestAssembly +"); + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "span", + typeName: "SpanTagHelper", + assemblyName: "TestAssembly") + }; + + // Act + var documentNode = Lower(codeDocument, tagHelpers: tagHelpers); + + // Assert + Children(documentNode, + n => Directive( + SyntaxConstants.CSharp.AddTagHelperKeyword, + n, + v => DirectiveToken(DirectiveTokenKind.String, "*, TestAssembly", v)), + n => TagHelper( + "span", + TagMode.StartTagAndEndTag, + tagHelpers, + n, + c => Assert.IsType(c), + c => TagHelperHtmlAttribute( + "val", + AttributeStructure.DoubleQuotes, + c, + v => CSharpExpressionAttributeValue(string.Empty, "Hello", v), + v => LiteralAttributeValue(" ", "World", v)))); + } + + [Fact] + public void Lower_TagHelpers_WithPrefix() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@addTagHelper *, TestAssembly +@tagHelperPrefix cool: +"); + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "span", + typeName: "SpanTagHelper", + assemblyName: "TestAssembly") + }; + + // Act + var documentNode = Lower(codeDocument, tagHelpers: tagHelpers); + + // Assert + Children(documentNode, + n => Directive( + SyntaxConstants.CSharp.AddTagHelperKeyword, + n, + v => DirectiveToken(DirectiveTokenKind.String, "*, TestAssembly", v)), + n => Directive( + SyntaxConstants.CSharp.TagHelperPrefixKeyword, + n, + v => DirectiveToken(DirectiveTokenKind.String, "cool:", v)), + n => TagHelper( + "span", // Note: this is span not cool:span + TagMode.StartTagAndEndTag, + tagHelpers, + n, + c => Assert.IsType(c), + c => TagHelperHtmlAttribute( + "val", + AttributeStructure.DoubleQuotes, + c, + v => CSharpExpressionAttributeValue(string.Empty, "Hello", v), + v => LiteralAttributeValue(" ", "World", v)))); + } + + [Fact] + public void Lower_TagHelper_InSection() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@addTagHelper *, TestAssembly +@section test { + +}"); + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "span", + typeName: "SpanTagHelper", + assemblyName: "TestAssembly") + }; + + // Act + var documentNode = Lower(codeDocument, tagHelpers: tagHelpers); + + // Assert + Children( + documentNode, + n => Directive( + SyntaxConstants.CSharp.AddTagHelperKeyword, + n, + v => DirectiveToken(DirectiveTokenKind.String, "*, TestAssembly", v)), + n => Directive( + "section", + n, + c1 => DirectiveToken(DirectiveTokenKind.Member, "test", c1), + c1 => Html(Environment.NewLine, c1), + c1 => TagHelper( + "span", + TagMode.StartTagAndEndTag, + tagHelpers, + c1, + c2 => Assert.IsType(c2), + c2 => TagHelperHtmlAttribute( + "val", + AttributeStructure.DoubleQuotes, + c2, + v => CSharpExpressionAttributeValue(string.Empty, "Hello", v), + v => LiteralAttributeValue(" ", "World", v))), + c1 => Html(Environment.NewLine, c1))); + } + + [Fact] + public void Lower_TagHelpersWithBoundAttribute() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@addTagHelper *, TestAssembly +"); + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.String"), + }) + }; + + // Act + var documentNode = Lower(codeDocument, tagHelpers: tagHelpers); + + // Assert + Children( + documentNode, + n => Directive( + SyntaxConstants.CSharp.AddTagHelperKeyword, + n, + v => DirectiveToken(DirectiveTokenKind.String, "*, TestAssembly", v)), + n => TagHelper( + "input", + TagMode.SelfClosing, + tagHelpers, + n, + c => Assert.IsType(c), + c => SetTagHelperProperty( + "bound", + "FooProp", + AttributeStructure.SingleQuotes, + c, + v => Html("foo", v)))); + } + + [Fact] + public void Lower_WithImports_Using() + { + // Arrange + var source = TestRazorSourceDocument.Create(@"@using System.Threading.Tasks +

Hi!

"); + var imports = new[] + { + TestRazorSourceDocument.Create("@using System.Globalization"), + TestRazorSourceDocument.Create("@using System.Text"), + }; + + var codeDocument = TestRazorCodeDocument.Create(source, imports); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children( + documentNode, + n => Using("System.Globalization", n), + n => Using("System.Text", n), + n => Using("System.Threading.Tasks", n), + n => Html("

Hi!

", n)); + } + + [Fact] + public void Lower_WithImports_AllowsIdenticalNamespacesInPrimaryDocument() + { + // Arrange + var source = TestRazorSourceDocument.Create(@"@using System.Threading.Tasks +@using System.Threading.Tasks"); + var imports = new[] + { + TestRazorSourceDocument.Create("@using System.Threading.Tasks"), + }; + + var codeDocument = TestRazorCodeDocument.Create(source, imports); + + // Act + var documentNode = Lower(codeDocument); + + // Assert + Children( + documentNode, + n => Using("System.Threading.Tasks", n), + n => Using("System.Threading.Tasks", n)); + } + + [Fact] + public void Lower_WithMultipleImports_SingleLineFileScopedSinglyOccurring() + { + // Arrange + var source = TestRazorSourceDocument.Create("

Hi!

"); + var imports = new[] + { + TestRazorSourceDocument.Create("@test value1"), + TestRazorSourceDocument.Create("@test value2"), + }; + + var codeDocument = TestRazorCodeDocument.Create(source, imports); + + // Act + var documentNode = Lower(codeDocument, b => + { + b.AddDirective(DirectiveDescriptor.CreateDirective( + "test", + DirectiveKind.SingleLine, + builder => + { + builder.AddMemberToken(); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + })); + }); + + // Assert + Children( + documentNode, + n => Directive("test", n, c => DirectiveToken(DirectiveTokenKind.Member, "value2", c)), + n => Html("

Hi!

", n)); + } + + [Fact] + public void Lower_WithImports_IgnoresBlockDirective() + { + // Arrange + var source = TestRazorSourceDocument.Create("

Hi!

"); + var imports = new[] + { + TestRazorSourceDocument.Create("@block token { }"), + }; + + var codeDocument = TestRazorCodeDocument.Create(source, imports); + + // Act + var documentNode = Lower(codeDocument, b => + { + b.AddDirective(DirectiveDescriptor.CreateDirective("block", DirectiveKind.RazorBlock, d => d.AddMemberToken())); + }); + + // Assert + Children( + documentNode, + n => Html("

Hi!

", n)); + } + + private DocumentIntermediateNode Lower( + RazorCodeDocument codeDocument, + Action builder = null, + IEnumerable tagHelpers = null, + bool designTime = false) + { + tagHelpers = tagHelpers ?? new TagHelperDescriptor[0]; + + Action configureEngine = b => + { + builder?.Invoke(b); + + SectionDirective.Register(b); + b.AddTagHelpers(tagHelpers); + + b.Features.Add(new DesignTimeOptionsFeature(designTime)); + }; + + var projectEngine = RazorProjectEngine.Create(configureEngine); + + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorIntermediateNodeLoweringPhase) + { + break; + } + } + + var documentNode = codeDocument.GetDocumentIntermediateNode(); + Assert.NotNull(documentNode); + + return documentNode; + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BoundAttributeDescriptor(attributeBuilder); + } + } + + builder.TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + + var descriptor = builder.Build(); + + return descriptor; + } + + 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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs new file mode 100644 index 0000000000..908983d50a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorIntermediateNodeLoweringPhaseTest.cs @@ -0,0 +1,298 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorIntermediateNodeLoweringPhaseTest + { + [Fact] + public void Execute_AutomaticallyImportsSingleLineSinglyOccurringDirective() + { + // Arrange + var directive = DirectiveDescriptor.CreateSingleLineDirective( + "custom", + builder => + { + builder.AddStringToken(); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + }); + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + b.AddDirective(directive); + }); + var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); + var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import.cshtml"); + var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); + codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); + + // Act + phase.Execute(codeDocument); + + // Assert + var documentNode = codeDocument.GetDocumentIntermediateNode(); + var customDirectives = documentNode.FindDirectiveReferences(directive); + var customDirective = (DirectiveIntermediateNode)Assert.Single(customDirectives).Node; + var stringToken = Assert.Single(customDirective.Tokens); + Assert.Equal("\"hello\"", stringToken.Content); + } + + [Fact] + public void Execute_AutomaticallyOverridesImportedSingleLineSinglyOccurringDirective_MainDocument() + { + // Arrange + var directive = DirectiveDescriptor.CreateSingleLineDirective( + "custom", + builder => + { + builder.AddStringToken(); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + }); + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + b.AddDirective(directive); + }); + var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); + var importSource = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import.cshtml"); + var codeDocument = TestRazorCodeDocument.Create("@custom \"world\""); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); + codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); + + // Act + phase.Execute(codeDocument); + + // Assert + var documentNode = codeDocument.GetDocumentIntermediateNode(); + var customDirectives = documentNode.FindDirectiveReferences(directive); + var customDirective = (DirectiveIntermediateNode)Assert.Single(customDirectives).Node; + var stringToken = Assert.Single(customDirective.Tokens); + Assert.Equal("\"world\"", stringToken.Content); + } + + [Fact] + public void Execute_AutomaticallyOverridesImportedSingleLineSinglyOccurringDirective_MultipleImports() + { + // Arrange + var directive = DirectiveDescriptor.CreateSingleLineDirective( + "custom", + builder => + { + builder.AddStringToken(); + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + }); + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + b.AddDirective(directive); + }); + var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); + var importSource1 = TestRazorSourceDocument.Create("@custom \"hello\"", filePath: "import1.cshtml"); + var importSource2 = TestRazorSourceDocument.Create("@custom \"world\"", filePath: "import2.cshtml"); + var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); + codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource1, options), RazorSyntaxTree.Parse(importSource2, options) }); + + // Act + phase.Execute(codeDocument); + + // Assert + var documentNode = codeDocument.GetDocumentIntermediateNode(); + var customDirectives = documentNode.FindDirectiveReferences(directive); + var customDirective = (DirectiveIntermediateNode)Assert.Single(customDirectives).Node; + var stringToken = Assert.Single(customDirective.Tokens); + Assert.Equal("\"world\"", stringToken.Content); + } + + [Fact] + public void Execute_DoesNotImportNonFileScopedSinglyOccurringDirectives_Block() + { + // Arrange + var codeBlockDirective = DirectiveDescriptor.CreateCodeBlockDirective("code", b => b.AddStringToken()); + var razorBlockDirective = DirectiveDescriptor.CreateRazorBlockDirective("razor", b => b.AddStringToken()); + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + b.AddDirective(codeBlockDirective); + b.AddDirective(razorBlockDirective); + }); + var options = RazorParserOptions.Create(builder => + { + builder.Directives.Add(codeBlockDirective); + builder.Directives.Add(razorBlockDirective); + }); + var importSource = TestRazorSourceDocument.Create( +@"@code ""code block"" { } +@razor ""razor block"" { }", + filePath: "testImports.cshtml"); + var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); + codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); + + // Act + phase.Execute(codeDocument); + + // Assert + var documentNode = codeDocument.GetDocumentIntermediateNode(); + var directives = documentNode.Children.OfType(); + Assert.Empty(directives); + } + + [Fact] + public void Execute_ErrorsForCodeBlockFileScopedSinglyOccurringDirectives() + { + // Arrange + var directive = DirectiveDescriptor.CreateCodeBlockDirective("custom", b => b.Usage = DirectiveUsage.FileScopedSinglyOccurring); + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + b.AddDirective(directive); + }); + var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); + var importSource = TestRazorSourceDocument.Create("@custom { }", filePath: "import.cshtml"); + var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); + codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); + var expectedDiagnostic = RazorDiagnosticFactory.CreateDirective_BlockDirectiveCannotBeImported("custom"); + + // Act + phase.Execute(codeDocument); + + // Assert + var documentNode = codeDocument.GetDocumentIntermediateNode(); + var directives = documentNode.Children.OfType(); + Assert.Empty(directives); + var diagnostic = Assert.Single(documentNode.GetAllDiagnostics()); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void Execute_ErrorsForRazorBlockFileScopedSinglyOccurringDirectives() + { + // Arrange + var directive = DirectiveDescriptor.CreateRazorBlockDirective("custom", b => b.Usage = DirectiveUsage.FileScopedSinglyOccurring); + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + b.AddDirective(directive); + }); + var options = RazorParserOptions.Create(builder => builder.Directives.Add(directive)); + var importSource = TestRazorSourceDocument.Create("@custom { }", filePath: "import.cshtml"); + var codeDocument = TestRazorCodeDocument.Create("

NonDirective

"); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); + codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) }); + var expectedDiagnostic = RazorDiagnosticFactory.CreateDirective_BlockDirectiveCannotBeImported("custom"); + + // Act + phase.Execute(codeDocument); + + // Assert + var documentNode = codeDocument.GetDocumentIntermediateNode(); + var directives = documentNode.Children.OfType(); + Assert.Empty(directives); + var diagnostic = Assert.Single(documentNode.GetAllDiagnostics()); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void Execute_ThrowsForMissingDependency_SyntaxTree() + { + // Arrange + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + }); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The '{nameof(DefaultRazorIntermediateNodeLoweringPhase)}' phase requires a '{nameof(RazorSyntaxTree)}' " + + $"provided by the '{nameof(RazorCodeDocument)}'."); + } + + [Fact] + public void Execute_CollatesSyntaxDiagnosticsFromSourceDocument() + { + // Arrange + var phase = new DefaultRazorIntermediateNodeLoweringPhase(); + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + }); + var codeDocument = TestRazorCodeDocument.Create("

+ { + b.Phases.Add(phase); + b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); + }); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source)); + codeDocument.SetImportSyntaxTrees(new[] + { + RazorSyntaxTree.Parse(TestRazorSourceDocument.Create("@ ")), + RazorSyntaxTree.Parse(TestRazorSourceDocument.Create("

+ { + Assert.Equal(@"A space or line break was encountered after the ""@"" character. Only valid identifiers, keywords, comments, ""("" and ""{"" are valid at the start of a code block and they must occur immediately following ""@"" with no space in between.", + diagnostic.GetMessage()); + }, + diagnostic => + { + Assert.Equal(@"The explicit expression block is missing a closing "")"" character. Make sure you have a matching "")"" character for all the ""("" characters within this block, and that none of the "")"" characters are being interpreted as markup.", + diagnostic.GetMessage()); + }); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorOptimizationPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorOptimizationPhaseTest.cs new file mode 100644 index 0000000000..5a1d6eb238 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorOptimizationPhaseTest.cs @@ -0,0 +1,102 @@ +// 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.Intermediate; +using Microsoft.AspNetCore.Testing; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorOptimizationPhaseTest + { + [Fact] + public void OnInitialized_OrdersPassesInAscendingOrder() + { + // Arrange & Act + var phase = new DefaultRazorOptimizationPhase(); + + var first = Mock.Of(p => p.Order == 15); + var second = Mock.Of(p => p.Order == 17); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(second); + b.Features.Add(first); + }); + + // Assert + Assert.Collection( + phase.Passes, + p => Assert.Same(first, p), + p => Assert.Same(second, p)); + } + + [Fact] + public void Execute_ThrowsForMissingDependency() + { + // Arrange + var phase = new DefaultRazorOptimizationPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The '{nameof(DefaultRazorOptimizationPhase)}' phase requires a '{nameof(DocumentIntermediateNode)}' " + + $"provided by the '{nameof(RazorCodeDocument)}'."); + } + + [Fact] + public void Execute_ExecutesPhasesInOrder() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // We're going to set up mocks to simulate a sequence of passes. We don't care about + // what's in the nodes, we're just going to look at the identity via strict mocks. + var originalNode = new DocumentIntermediateNode(); + var firstPassNode = new DocumentIntermediateNode(); + var secondPassNode = new DocumentIntermediateNode(); + codeDocument.SetDocumentIntermediateNode(originalNode); + + var firstPass = new Mock(MockBehavior.Strict); + firstPass.SetupGet(m => m.Order).Returns(0); + firstPass.SetupProperty(m => m.Engine); + firstPass.Setup(m => m.Execute(codeDocument, originalNode)).Callback(() => + { + originalNode.Children.Add(firstPassNode); + }); + + var secondPass = new Mock(MockBehavior.Strict); + secondPass.SetupGet(m => m.Order).Returns(1); + secondPass.SetupProperty(m => m.Engine); + secondPass.Setup(m => m.Execute(codeDocument, originalNode)).Callback(() => + { + // Works only when the first pass has run before this. + originalNode.Children[0].Children.Add(secondPassNode); + }); + + var phase = new DefaultRazorOptimizationPhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(firstPass.Object); + b.Features.Add(secondPass.Object); + }); + + // Act + phase.Execute(codeDocument); + + // Assert + Assert.Same(secondPassNode, codeDocument.GetDocumentIntermediateNode().Children[0].Children[0]); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorParsingPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorParsingPhaseTest.cs new file mode 100644 index 0000000000..43fdf32031 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorParsingPhaseTest.cs @@ -0,0 +1,93 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorParsingPhaseTest + { + [Fact] + public void Execute_AddsSyntaxTree() + { + // Arrange + var phase = new DefaultRazorParsingPhase(); + var engine = RazorProjectEngine.CreateEmpty(builder => + { + builder.Phases.Add(phase); + builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: RazorLanguageVersion.Latest, fileKind: null)); + }); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act + phase.Execute(codeDocument); + + // Assert + Assert.NotNull(codeDocument.GetSyntaxTree()); + } + + [Fact] + public void Execute_UsesConfigureParserFeatures() + { + // Arrange + var phase = new DefaultRazorParsingPhase(); + var engine = RazorProjectEngine.CreateEmpty((builder) => + { + builder.Phases.Add(phase); + builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: RazorLanguageVersion.Latest, fileKind: null)); + builder.Features.Add(new MyParserOptionsFeature()); + }); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act + phase.Execute(codeDocument); + + // Assert + var syntaxTree = codeDocument.GetSyntaxTree(); + var directive = Assert.Single(syntaxTree.Options.Directives); + Assert.Equal("test", directive.Directive); + } + + [Fact] + public void Execute_ParsesImports() + { + // Arrange + var phase = new DefaultRazorParsingPhase(); + var engine = RazorProjectEngine.CreateEmpty((builder) => + { + builder.Phases.Add(phase); + builder.Features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: RazorLanguageVersion.Latest, fileKind: null)); + builder.Features.Add(new MyParserOptionsFeature()); + }); + + var imports = new[] + { + TestRazorSourceDocument.Create(), + TestRazorSourceDocument.Create(), + }; + + var codeDocument = TestRazorCodeDocument.Create(TestRazorSourceDocument.Create(), imports); + + // Act + phase.Execute(codeDocument); + + // Assert + Assert.Collection( + codeDocument.GetImportSyntaxTrees(), + t => { Assert.Same(t.Source, imports[0]); Assert.Equal("test", Assert.Single(t.Options.Directives).Directive); }, + t => { Assert.Same(t.Source, imports[1]); Assert.Equal("test", Assert.Single(t.Options.Directives).Directive); }); + } + + private class MyParserOptionsFeature : RazorEngineFeatureBase, IConfigureRazorParserOptionsFeature + { + public int Order { get; } + + public void Configure(RazorParserOptionsBuilder options) + { + options.Directives.Add(DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine)); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineBuilderTest.cs new file mode 100644 index 0000000000..5323ba3ffa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineBuilderTest.cs @@ -0,0 +1,65 @@ +// 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.Linq; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineBuilderTest + { + [Fact] + public void Build_AddsFeaturesToRazorEngine() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + + var features = builder.Features.ToArray(); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Collection(projectEngine.Engine.Features, + feature => Assert.Same(features[0], feature), + feature => Assert.Same(features[1], feature)); + } + + [Fact] + public void Build_AddsPhasesToRazorEngine() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + builder.Phases.Add(Mock.Of()); + builder.Phases.Add(Mock.Of()); + + var phases = builder.Phases.ToArray(); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Collection(projectEngine.Engine.Phases, + phase => Assert.Same(phases[0], phase), + phase => Assert.Same(phases[1], phase)); + } + + [Fact] + public void Build_CreatesProjectEngineWithFileSystem() + { + // Arrange + var fileSystem = Mock.Of(); + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, fileSystem); + + // Act + var projectEngine = builder.Build(); + + // Assert + Assert.Same(fileSystem, projectEngine.FileSystem); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineIntegrationTest.cs new file mode 100644 index 0000000000..10cee4a70b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineIntegrationTest.cs @@ -0,0 +1,351 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineIntegrationTest + { + [Fact] + public void Process_SetsOptions_Runtime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.False(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.False(codeGenerationOptions.DesignTime); + Assert.False(codeGenerationOptions.SuppressChecksum); + Assert.False(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void ProcessDesignTime_SetsOptions_DesignTime() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var parserOptions = codeDocument.GetParserOptions(); + Assert.True(parserOptions.DesignTime); + + var codeGenerationOptions = codeDocument.GetCodeGenerationOptions(); + Assert.True(codeGenerationOptions.DesignTime); + Assert.True(codeGenerationOptions.SuppressChecksum); + Assert.True(codeGenerationOptions.SuppressMetadataAttributes); + } + + [Fact] + public void Process_GetsImportsFromFeature() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var testImport = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue" && i.Exists == true); + var importFeature = new Mock(); + importFeature + .Setup(feature => feature.GetImports(It.IsAny())) + .Returns(new[] { testImport }); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty, builder => + { + builder.SetImportFeature(importFeature.Object); + }); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var import = Assert.Single(codeDocument.Imports); + Assert.Equal("testvalue", import.FilePath); + } + + [Fact] + public void Process_GetsImportsFromFeature_MultipleFeatures() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var testImport1 = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue1" && i.Exists == true); + var importFeature1 = new Mock(); + importFeature1 + .Setup(feature => feature.GetImports(It.IsAny())) + .Returns(new[] { testImport1 }); + + var testImport2 = Mock.Of(i => i.Read() == new MemoryStream() && i.FilePath == "testvalue2" && i.Exists == true); + var importFeature2 = new Mock(); + importFeature2 + .Setup(feature => feature.GetImports(It.IsAny())) + .Returns(new[] { testImport2 }); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty, builder => + { + builder.Features.Add(importFeature1.Object); + builder.Features.Add(importFeature2.Object); + }); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + Assert.Collection(codeDocument.Imports, + i => Assert.Equal("testvalue1", i.FilePath), + i => Assert.Equal("testvalue2", i.FilePath)); + } + + [Fact] + public void Process_GeneratesCodeDocumentWithValidCSharpDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var csharpDocument = codeDocument.GetCSharpDocument(); + Assert.NotNull(csharpDocument); + Assert.Empty(csharpDocument.Diagnostics); + } + + [Fact] + public void Process_WithImportsAndTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var importItem = new TestRazorProjectItem("_import.cshtml"); + var expectedImports = new[] { RazorSourceDocument.ReadFrom(importItem) }; + var expectedTagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build(), + TagHelperDescriptorBuilder.Create("Test2TagHelper", "TestAssembly").Build(), + }; + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), "test", expectedImports, expectedTagHelpers); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Same(expectedTagHelpers, tagHelpers); + Assert.Equal(expectedImports, codeDocument.Imports); + } + + [Fact] + public void Process_WithFileKind_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), "test", Array.Empty(), tagHelpers: null); + + // Assert + var actual = codeDocument.GetFileKind(); + Assert.Equal("test", actual); + } + + [Fact] + public void Process_WithNullTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), "test", Array.Empty(), tagHelpers: null); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void Process_SetsNullTagHelpersOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void Process_SetsInferredFileKindOnCodeDocument_MvcFile() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var actual = codeDocument.GetFileKind(); + Assert.Same(FileKinds.Legacy, actual); + } + + [Fact] + public void Process_SetsInferredFileKindOnCodeDocument_Component() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.razor"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var actual = codeDocument.GetFileKind(); + Assert.Same(FileKinds.Component, actual); + } + + [Fact] + public void Process_WithNullImports_SetsEmptyListOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), "test", importSources: null, tagHelpers: null); + + // Assert + Assert.Empty(codeDocument.Imports); + } + + [Fact] + public void ProcessDesignTime_WithImportsAndTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + var importItem = new TestRazorProjectItem("_import.cshtml"); + var expectedImports = new[] { RazorSourceDocument.ReadFrom(importItem) }; + var expectedTagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build(), + TagHelperDescriptorBuilder.Create("Test2TagHelper", "TestAssembly").Build(), + }; + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), "test", expectedImports, expectedTagHelpers); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Same(expectedTagHelpers, tagHelpers); + Assert.Equal(expectedImports, codeDocument.Imports); + } + + [Fact] + public void ProcessDesignTime_WithNullTagHelpers_SetsOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), "test", Array.Empty(), tagHelpers: null); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void ProcessDesignTime_SetsInferredFileKindOnCodeDocument_MvcFile() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var actual = codeDocument.GetFileKind(); + Assert.Same(FileKinds.Legacy, actual); + } + + [Fact] + public void ProcessDesignTime_SetsInferredFileKindOnCodeDocument_Component() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.razor"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var actual = codeDocument.GetFileKind(); + Assert.Same(FileKinds.Component, actual); + } + + [Fact] + public void ProcessDesignTime_SetsNullTagHelpersOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + var tagHelpers = codeDocument.GetTagHelpers(); + Assert.Null(tagHelpers); + } + + [Fact] + public void ProcessDesignTime_WithNullImports_SetsEmptyListOnCodeDocument() + { + // Arrange + var projectItem = new TestRazorProjectItem("Index.cshtml"); + + var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, TestRazorProjectFileSystem.Empty); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), "test", importSources: null, tagHelpers: null); + + // Assert + Assert.Empty(codeDocument.Imports); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineTest.cs new file mode 100644 index 0000000000..c70cdab663 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectEngineTest.cs @@ -0,0 +1,62 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectEngineTest + { + [Fact] + public void GetImportSourceDocuments_DoesNotIncludeNonExistentItems() + { + // Arrange + var existingItem = new TestRazorProjectItem("Index.cshtml"); + var nonExistentItem = Mock.Of(item => item.Exists == false); + var items = new[] { existingItem, nonExistentItem }; + + // Act + var sourceDocuments = DefaultRazorProjectEngine.GetImportSourceDocuments(items); + + // Assert + var sourceDocument = Assert.Single(sourceDocuments); + Assert.Equal(existingItem.FilePath, sourceDocument.FilePath); + } + + [Fact] + public void GetImportSourceDocuments_UnreadableItem_Throws() + { + // Arrange + var projectItem = new Mock(MockBehavior.Strict); + projectItem.SetupGet(p => p.Exists).Returns(true); + projectItem.SetupGet(p => p.PhysicalPath).Returns("path/to/file.cshtml"); + projectItem.Setup(p => p.Read()).Throws(new IOException("Couldn't read file.")); + var items = new[] { projectItem.Object }; + + // Act & Assert + var exception = Assert.Throws(() => DefaultRazorProjectEngine.GetImportSourceDocuments(items)); + Assert.Equal("Couldn't read file.", exception.Message); + } + + [Fact] + public void GetImportSourceDocuments_WithSuppressExceptions_UnreadableItem_DoesNotThrow() + { + // Arrange + var projectItem = new Mock(MockBehavior.Strict); + projectItem.SetupGet(p => p.Exists).Returns(true); + projectItem.SetupGet(p => p.PhysicalPath).Returns("path/to/file.cshtml"); + projectItem.SetupGet(p => p.FilePath).Returns("path/to/file.cshtml"); + projectItem.SetupGet(p => p.RelativePhysicalPath).Returns("path/to/file.cshtml"); + projectItem.Setup(p => p.Read()).Throws(new IOException("Couldn't read file.")); + var items = new[] { projectItem.Object }; + + // Act + var sourceDocuments = DefaultRazorProjectEngine.GetImportSourceDocuments(items, suppressExceptions: true); + + // Assert - Does not throw + Assert.Empty(sourceDocuments); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectFileSystemTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..a158f1dc8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectFileSystemTest.cs @@ -0,0 +1,318 @@ +// 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.Linq; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectFileSystemTest + { + private static string TestFolder { get; } = Path.Combine( + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectFileSystemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); + + [Theory] + [InlineData(null)] + [InlineData("")] + public void NormalizeAndEnsureValidPath_ThrowsIfPathIsNullOrEmpty(string path) + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act and Assert + ExceptionAssert.ThrowsArgumentNullOrEmptyString(() => fileSystem.NormalizeAndEnsureValidPath(path), "path"); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePath() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_FileFromNetworkShare__WindowsStyle_NormalizesToAbsolutePath() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("//some/network/share/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("\\\\some\\network\\share\\root\\file.cshtml"); + + // Assert + Assert.Equal("//some/network/share/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_FileFromNetworkShare_UnixStyle_NormalizesToAbsolutePath() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("//some/network/share/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("//some/network/share/root/file.cshtml"); + + // Assert + Assert.Equal("//some/network/share/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToAbsolutePathWithoutForwardSlash() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem("C:/some/test/path/root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath("/file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/file.cshtml", absolutePath); + } + + [Fact] + public void NormalizeAndEnsureValidPath_NormalizesToForwardSlashes() + { + // Arrange + var fileSystem = new TestRazorProjectFileSystem(@"C:\some\test\path\root"); + + // Act + var absolutePath = fileSystem.NormalizeAndEnsureValidPath(@"something\file.cshtml"); + + // Assert + Assert.Equal("C:/some/test/path/root/something/file.cshtml", absolutePath); + } + + [Fact] + public void EnumerateItems_DiscoversAllCshtmlFiles() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/"); + + // Assert + Assert.Collection( + items.OrderBy(f => f.FilePath, StringComparer.Ordinal), + item => + { + Assert.Equal("/Home.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Home.cshtml"), item.PhysicalPath); + Assert.Equal("Home.cshtml", item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/About/About.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/Home/Index.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "Index.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "Index.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + }); + } + + [Fact] + public void EnumerateItems_DiscoversAllCshtmlFiles_UnderSpecifiedBasePath() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/Views"); + + // Assert + Assert.Collection( + items.OrderBy(f => f.FilePath, StringComparer.Ordinal), + item => + { + Assert.Equal("/About/About.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("About", "About.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Home/Index.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "Index.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "Index.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("_ViewImports.cshtml"), item.RelativePhysicalPath); + }); + } + + [Fact] + public void EnumerateItems_ReturnsEmptySequence_WhenBasePathDoesNotExist() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.EnumerateItems("/Does-Not-Exist"); + + // Assert + Assert.Empty(items); + } + + [Fact] + public void FindHierarchicalItems_FindsItemsWithMatchingNames() + { + // Arrange + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var items = fileSystem.FindHierarchicalItems("/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + }); + } + + [Fact] + public void GetItem_ReturnsFileFromDisk() + { + // Arrange + var filePath = "/Views/About/About.cshtml"; + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var item = fileSystem.GetItem(filePath, fileKind: null); + + // Assert + Assert.True(item.Exists); + Assert.Equal(filePath, item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux, SkipReason = "This test does not makes sense for case sensitive Operating Systems.")] + public void GetItem_MismatchedCase_ReturnsFileFromDisk() + { + // Arrange + var filePath = "/Views/About/About.cshtml"; + var lowerCaseTestFolder = TestFolder.ToLower(); + var fileSystem = new DefaultRazorProjectFileSystem(lowerCaseTestFolder); + + // Act + var item = fileSystem.GetItem(filePath, fileKind: null); + + // Assert + Assert.True(item.Exists); + Assert.Equal(filePath, item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(lowerCaseTestFolder, "Views", "About", "About.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); + } + + [Fact] + public void GetItem_ReturnsNotFoundResult() + { + // Arrange + var path = "/NotFound.cshtml"; + var fileSystem = new DefaultRazorProjectFileSystem(TestFolder); + + // Act + var item = fileSystem.GetItem(path, fileKind: null); + + // Assert + Assert.False(item.Exists); + } + + [Fact] + public void GetItem_MismatchedRootPath_Throws() + { + // Arrange + var rootPath = "//some/network/share/root"; + var fileSystem = new TestRazorProjectFileSystem(rootPath); + var path = "\\\\some\\other\\network\\share\\root\\file.cshtml"; + + // Act & Assert + ExceptionAssert.Throws( + () => fileSystem.GetItem(path, fileKind: null), + $"The file '{path.Replace('\\', '/')}' is not a descendent of the base path '{rootPath}'."); + } + + private class TestRazorProjectFileSystem : DefaultRazorProjectFileSystem + { + public TestRazorProjectFileSystem(string root) : base(root) + { + } + + public new string NormalizeAndEnsureValidPath(string path) => base.NormalizeAndEnsureValidPath(path); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectItemTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectItemTest.cs new file mode 100644 index 0000000000..f903b16f63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorProjectItemTest.cs @@ -0,0 +1,101 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorProjectItemTest + { + private static string TestFolder { get; } = Path.Combine( + TestProject.GetProjectDirectory(typeof(DefaultRazorProjectItemTest)), + "TestFiles", + "DefaultRazorProjectFileSystem"); + + [Fact] + public void DefaultRazorProjectItem_SetsProperties() + { + // Arrange + var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); + + // Act + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", "test", fileInfo); + + // Assert + Assert.Equal("/Home.cshtml", projectItem.FilePath); + Assert.Equal("/", projectItem.BasePath); + Assert.True(projectItem.Exists); + Assert.Equal("Home.cshtml", projectItem.FileName); + Assert.Equal("test", projectItem.FileKind); + Assert.Equal(fileInfo.FullName, projectItem.PhysicalPath); + Assert.Equal("Home.cshtml", projectItem.RelativePhysicalPath); + } + + [Fact] + public void DefaultRazorProjectItem_InfersFileKind_Component() + { + // Arrange + var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); + + // Act + var projectItem = new DefaultRazorProjectItem("/", "/Home.razor", "Home.cshtml", fileKind: null, fileInfo); + + // Assert + Assert.Equal(FileKinds.Component, projectItem.FileKind); + } + + [Fact] + public void DefaultRazorProjectItem_InfersFileKind_Legacy() + { + // Arrange + var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); + + // Act + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", fileKind: null, fileInfo); + + // Assert + Assert.Equal(FileKinds.Legacy, projectItem.FileKind); + } + + [Fact] + public void DefaultRazorProjectItem_InfersFileKind_Null() + { + // Arrange + var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); + + // Act + var projectItem = new DefaultRazorProjectItem("/", filePath: null, "Home.cshtml", fileKind: null, fileInfo); + + // Assert + Assert.Null(projectItem.FileKind); + } + + [Fact] + public void Exists_ReturnsFalseWhenFileDoesNotExist() + { + // Arrange + var fileInfo = new FileInfo(Path.Combine(TestFolder, "Views", "FileDoesNotExist.cshtml")); + + // Act + var projectItem = new DefaultRazorProjectItem("/Views", "/FileDoesNotExist.cshtml", Path.Combine("Views", "FileDoesNotExist.cshtml"), "test", fileInfo); + + // Assert + Assert.False(projectItem.Exists); + } + + [Fact] + public void Read_ReturnsReadStream() + { + // Arrange + var fileInfo = new FileInfo(Path.Combine(TestFolder, "Home.cshtml")); + var projectItem = new DefaultRazorProjectItem("/", "/Home.cshtml", "Home.cshtml", "test", fileInfo); + + // Act + var stream = projectItem.Read(); + + // Assert + Assert.Equal("home-content", new StreamReader(stream).ReadToEnd()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorSyntaxTreePhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorSyntaxTreePhaseTest.cs new file mode 100644 index 0000000000..d6dc0ac75a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorSyntaxTreePhaseTest.cs @@ -0,0 +1,94 @@ +// 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.Testing; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorSyntaxTreePhaseTest + { + [Fact] + public void OnInitialized_OrdersPassesInAscendingOrder() + { + // Arrange & Act + var phase = new DefaultRazorSyntaxTreePhase(); + + var first = Mock.Of(p => p.Order == 15); + var second = Mock.Of(p => p.Order == 17); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(second); + b.Features.Add(first); + }); + + // Assert + Assert.Collection( + phase.Passes, + p => Assert.Same(first, p), + p => Assert.Same(second, p)); + } + + [Fact] + public void Execute_ThrowsForMissingDependency() + { + // Arrange + var phase = new DefaultRazorSyntaxTreePhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => b.Phases.Add(phase)); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // Act & Assert + ExceptionAssert.Throws( + () => phase.Execute(codeDocument), + $"The '{nameof(DefaultRazorSyntaxTreePhase)}' phase requires a '{nameof(RazorSyntaxTree)}' " + + $"provided by the '{nameof(RazorCodeDocument)}'."); + } + + [Fact] + public void Execute_ExecutesPhasesInOrder() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + // We're going to set up mocks to simulate a sequence of passes. We don't care about + // what's in the trees, we're just going to look at the identity via strict mocks. + var originalSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); + var firstPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); + var secondPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); + codeDocument.SetSyntaxTree(originalSyntaxTree); + + var firstPass = new Mock(MockBehavior.Strict); + firstPass.SetupGet(m => m.Order).Returns(0); + firstPass.SetupProperty(m => m.Engine); + firstPass.Setup(m => m.Execute(codeDocument, originalSyntaxTree)).Returns(firstPassSyntaxTree); + + var secondPass = new Mock(MockBehavior.Strict); + secondPass.SetupGet(m => m.Order).Returns(1); + secondPass.SetupProperty(m => m.Engine); + secondPass.Setup(m => m.Execute(codeDocument, firstPassSyntaxTree)).Returns(secondPassSyntaxTree); + + var phase = new DefaultRazorSyntaxTreePhase(); + + var engine = RazorProjectEngine.CreateEmpty(b => + { + b.Phases.Add(phase); + + b.Features.Add(firstPass.Object); + b.Features.Add(secondPass.Object); + }); + + // Act + phase.Execute(codeDocument); + + // Assert + Assert.Same(secondPassSyntaxTree, codeDocument.GetSyntaxTree()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs new file mode 100644 index 0000000000..41dedf836a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs @@ -0,0 +1,1439 @@ +// 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.Components; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRazorTagHelperBinderPhaseTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + +#region Legacy + [Fact] + public void Execute_CanHandleSingleLengthAddTagHelperDirective() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new TagHelperDescriptor[0]); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + var expectedDiagnostics = new[] + { + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1), "\"") + }; + + var content = + @" +@addTagHelper """; + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var erroredNode = rewrittenTree.Root.DescendantNodes().First(n => n.GetSpanContext()?.ChunkGenerator is AddTagHelperChunkGenerator); + var chunkGenerator = Assert.IsType(erroredNode.GetSpanContext().ChunkGenerator); + Assert.Equal(expectedDiagnostics, chunkGenerator.Diagnostics); + } + + [Fact] + public void Execute_CanHandleSingleLengthRemoveTagHelperDirective() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new TagHelperDescriptor[0]); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + var expectedDiagnostics = new[] + { + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "\"") + }; + + var content = + @" +@removeTagHelper """; + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var erroredNode = rewrittenTree.Root.DescendantNodes().First(n => n.GetSpanContext()?.ChunkGenerator is RemoveTagHelperChunkGenerator); + var chunkGenerator = Assert.IsType(erroredNode.GetSpanContext().ChunkGenerator); + Assert.Equal(expectedDiagnostics, chunkGenerator.Diagnostics); + } + + [Fact] + public void Execute_CanHandleSingleLengthTagHelperPrefix() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new TagHelperDescriptor[0]); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + var expectedDiagnostics = new[] + { + RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "tagHelperPrefix", '\"', "\""), + }; + + var content = + @" +@tagHelperPrefix """; + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var erroredNode = rewrittenTree.Root.DescendantNodes().First(n => n.GetSpanContext()?.ChunkGenerator is TagHelperPrefixDirectiveChunkGenerator); + var chunkGenerator = Assert.IsType(erroredNode.GetSpanContext().ChunkGenerator); + Assert.Equal(expectedDiagnostics, chunkGenerator.Diagnostics); + } + + [Fact] + public void Execute_RewritesTagHelpers() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + Assert.Equal("form", tagHelperNodes[0].TagHelperInfo.TagName); + Assert.Equal("input", tagHelperNodes[1].TagHelperInfo.TagName); + } + + [Fact] + public void Execute_WithTagHelperDescriptorsFromCodeDocument_RewritesTagHelpers() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + codeDocument.SetTagHelpers(tagHelpers); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + Assert.Equal("form", tagHelperNodes[0].TagHelperInfo.TagName); + Assert.Equal("input", tagHelperNodes[1].TagHelperInfo.TagName); + } + + [Fact] + public void Execute_NullTagHelperDescriptorsFromCodeDocument_FallsBackToTagHelperFeature() + { + // Arrange + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + codeDocument.SetTagHelpers(tagHelpers: null); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + Assert.Equal("form", tagHelperNodes[0].TagHelperInfo.TagName); + Assert.Equal("input", tagHelperNodes[1].TagHelperInfo.TagName); + } + + [Fact] + public void Execute_EmptyTagHelperDescriptorsFromCodeDocument_DoesNotFallbackToTagHelperFeature() + { + // Arrange + var tagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(tagHelpers)); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + codeDocument.SetTagHelpers(tagHelpers: Array.Empty()); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + Assert.Empty(tagHelperNodes); + } + + [Fact] + public void Execute_DirectiveWithoutQuotes_RewritesTagHelpers_TagHelperMatchesElementTwice() + { + // Arrange + var descriptor = CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + ruleBuilder => ruleBuilder + .RequireAttributeDescriptor(attribute => attribute + .Name("a") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)), + ruleBuilder => ruleBuilder + .RequireAttributeDescriptor(attribute => attribute + .Name("b") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)), + }); + + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new[] { descriptor }); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var content = @" +@addTagHelper *, TestAssembly +

+
"; + + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + + var formTagHelper = Assert.Single(tagHelperNodes); + Assert.Equal("form", formTagHelper.TagHelperInfo.TagName); + Assert.Equal(2, formTagHelper.TagHelperInfo.BindingResult.Mappings[descriptor].Count()); + } + + [Fact] + public void Execute_DirectiveWithQuotes_RewritesTagHelpers_TagHelperMatchesElementTwice() + { + // Arrange + var descriptor = CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + ruleBuilder => ruleBuilder + .RequireAttributeDescriptor(attribute => attribute + .Name("a") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)), + ruleBuilder => ruleBuilder + .RequireAttributeDescriptor(attribute => attribute + .Name("b") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)), + }); + + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new[] { descriptor }); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var content = @" +@addTagHelper ""*, TestAssembly"" +
+
"; + + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + + var formTagHelper = Assert.Single(tagHelperNodes); + Assert.Equal("form", formTagHelper.TagHelperInfo.TagName); + Assert.Equal(2, formTagHelper.TagHelperInfo.BindingResult.Mappings[descriptor].Count()); + } + + [Fact] + public void Execute_TagHelpersFromCodeDocumentAndFeature_PrefersCodeDocument() + { + // Arrange + var featureTagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }; + var projectEngine = RazorProjectEngine.Create(builder => builder.AddTagHelpers(featureTagHelpers)); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + var codeDocumentTagHelpers = new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + }; + codeDocument.SetTagHelpers(codeDocumentTagHelpers); + + // Act + phase.Execute(codeDocument); + + // Assert + var rewrittenTree = codeDocument.GetSyntaxTree(); + var descendantNodes = rewrittenTree.Root.DescendantNodes(); + Assert.Empty(rewrittenTree.Diagnostics); + var tagHelperNodes = descendantNodes.Where(n => n is MarkupTagHelperElementSyntax tagHelper).Cast().ToArray(); + + var formTagHelper = Assert.Single(tagHelperNodes); + Assert.Equal("form", formTagHelper.TagHelperInfo.TagName); + } + + [Fact] + public void Execute_NoopsWhenNoTagHelpersFromCodeDocumentOrFeature() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + var sourceDocument = CreateTestSourceDocument(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var outputTree = codeDocument.GetSyntaxTree(); + Assert.Empty(outputTree.Diagnostics); + Assert.Same(originalTree, outputTree); + } + + [Fact] + public void Execute_NoopsWhenNoTagHelperDescriptorsAreResolved() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new TestTagHelperFeature()); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + // No taghelper directives here so nothing is resolved. + var sourceDocument = TestRazorSourceDocument.Create("Hello, world"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var outputTree = codeDocument.GetSyntaxTree(); + Assert.Empty(outputTree.Diagnostics); + Assert.Same(originalTree, outputTree); + } + + [Fact] + public void Execute_SetsTagHelperDocumentContext() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.Features.Add(new TestTagHelperFeature()); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + // No taghelper directives here so nothing is resolved. + var sourceDocument = TestRazorSourceDocument.Create("Hello, world"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + codeDocument.SetSyntaxTree(originalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var context = codeDocument.GetTagHelperContext(); + Assert.Null(context.Prefix); + Assert.Empty(context.TagHelpers); + } + + [Fact] + public void Execute_CombinesErrorsOnRewritingErrors() + { + // Arrange + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.AddTagHelpers(new[] + { + CreateTagHelperDescriptor( + tagName: "form", + typeName: "TestFormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestInputTagHelper", + assemblyName: "TestAssembly"), + }); + }); + + var phase = new DefaultRazorTagHelperBinderPhase() + { + Engine = projectEngine.Engine, + }; + + var content = + @" +@addTagHelper *, TestAssembly +
+ "; + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + + var initialError = RazorDiagnostic.Create( + new RazorDiagnosticDescriptor("RZ9999", () => "Initial test error", RazorDiagnosticSeverity.Error), + new SourceSpan(SourceLocation.Zero, contentLength: 1)); + var expectedRewritingError = RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper( + new SourceSpan(new SourceLocation(Environment.NewLine.Length * 2 + 30, 2, 1), contentLength: 4), "form"); + + var erroredOriginalTree = RazorSyntaxTree.Create(originalTree.Root, originalTree.Source, new[] { initialError }, originalTree.Options); + codeDocument.SetSyntaxTree(erroredOriginalTree); + + // Act + phase.Execute(codeDocument); + + // Assert + var outputTree = codeDocument.GetSyntaxTree(); + Assert.Empty(originalTree.Diagnostics); + Assert.NotSame(erroredOriginalTree, outputTree); + Assert.Equal(new[] { initialError, expectedRewritingError }, outputTree.Diagnostics); + } + + private static string AssemblyA => "TestAssembly"; + + private static string AssemblyB => "AnotherAssembly"; + + private static TagHelperDescriptor Valid_PlainTagHelperDescriptor + { + get + { + return CreateTagHelperDescriptor( + tagName: "valid_plain", + typeName: "Microsoft.AspNetCore.Razor.TagHelpers.ValidPlainTagHelper", + assemblyName: AssemblyA); + } + } + + private static TagHelperDescriptor Valid_InheritedTagHelperDescriptor + { + get + { + return CreateTagHelperDescriptor( + tagName: "valid_inherited", + typeName: "Microsoft.AspNetCore.Razor.TagHelpers.ValidInheritedTagHelper", + assemblyName: AssemblyA); + } + } + + private static TagHelperDescriptor String_TagHelperDescriptor + { + get + { + // We're treating 'string' as a TagHelper so we can test TagHelpers in multiple assemblies without + // building a separate assembly with a single TagHelper. + return CreateTagHelperDescriptor( + tagName: "string", + typeName: "System.String", + assemblyName: AssemblyB); + } + } + + public static TheoryData ProcessTagHelperPrefixData + { + get + { + // source, expected prefix + return new TheoryData + { + { + $@" +@tagHelperPrefix """" +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidPlain*, TestAssembly", + null + }, + { + $@" +@tagHelperPrefix th: +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidPlain*, {AssemblyA}", + "th:" + }, + { + $@" +@addTagHelper *, {AssemblyA} +@tagHelperPrefix th:", + "th:" + }, + { + $@" +@tagHelperPrefix th- +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidPlain*, {AssemblyA} +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidInherited*, {AssemblyA}", + "th-" + }, + { + $@" +@tagHelperPrefix +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidPlain*, {AssemblyA} +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidInherited*, {AssemblyA}", + null + }, + { + $@" +@tagHelperPrefix ""th"" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB}", + "th" + }, + { + $@" +@addTagHelper *, {AssemblyA} +@tagHelperPrefix th:- +@addTagHelper *, {AssemblyB}", + "th:-" + }, + }; + } + } + + [Theory] + [MemberData(nameof(ProcessTagHelperPrefixData))] + public void DirectiveVisitor_ExtractsPrefixFromSyntaxTree( + string source, + string expectedPrefix) + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); + var parser = new RazorParser(); + var syntaxTree = parser.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.TagHelperDirectiveVisitor(tagHelpers: new List()); + + // Act + visitor.Visit(syntaxTree.Root); + + // Assert + Assert.Equal(expectedPrefix, visitor.TagHelperPrefix); + } + + public static TheoryData ProcessTagHelperMatchesData + { + get + { + // source, taghelpers, expected descriptors + return new TheoryData + { + { + $@" +@addTagHelper *, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, String_TagHelperDescriptor }, + new [] { Valid_PlainTagHelperDescriptor, String_TagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper *, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, String_TagHelperDescriptor }, + new [] { Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB} +@removeTagHelper *, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, String_TagHelperDescriptor }, + new [] { String_TagHelperDescriptor } + }, + { + $@" +@addTagHelper {Valid_PlainTagHelperDescriptor.Name}, {AssemblyA} +@addTagHelper *, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper {Valid_PlainTagHelperDescriptor.Name}, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_InheritedTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_InheritedTagHelperDescriptor, Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_InheritedTagHelperDescriptor, Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidPlain*, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper Microsoft.AspNetCore.Razor.TagHelpers.*, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor, Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper Microsoft.AspNetCore.Razor.TagHelpers.ValidP*, {AssemblyA} +@addTagHelper *, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, }, + new [] { Valid_InheritedTagHelperDescriptor, Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper Str*, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, String_TagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper *, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, String_TagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper System.{String_TagHelperDescriptor.Name}, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, String_TagHelperDescriptor, }, + new [] { Valid_PlainTagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB} +@removeTagHelper Microsoft.*, {AssemblyA}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, String_TagHelperDescriptor }, + new [] { String_TagHelperDescriptor } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB} +@removeTagHelper ?Microsoft*, {AssemblyA} +@removeTagHelper System.{String_TagHelperDescriptor.Name}, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, String_TagHelperDescriptor }, + new [] + { + Valid_InheritedTagHelperDescriptor, + Valid_PlainTagHelperDescriptor, + String_TagHelperDescriptor + } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB} +@removeTagHelper TagHelper*, {AssemblyA} +@removeTagHelper System.{String_TagHelperDescriptor.Name}, {AssemblyB}", + new [] { Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor, String_TagHelperDescriptor }, + new [] + { + Valid_InheritedTagHelperDescriptor, + Valid_PlainTagHelperDescriptor, + String_TagHelperDescriptor + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(ProcessTagHelperMatchesData))] + public void DirectiveVisitor_FiltersTagHelpersByDirectives( + string source, + object tagHelpers, + object expectedDescriptors) + { + // Arrange + var expected = (TagHelperDescriptor[])expectedDescriptors; + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); + var parser = new RazorParser(); + var syntaxTree = parser.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.TagHelperDirectiveVisitor((TagHelperDescriptor[])tagHelpers); + + // Act + visitor.Visit(syntaxTree.Root); + + // Assert + Assert.Equal(expected.Count(), visitor.Matches.Count()); + + foreach (var expectedDescriptor in expected) + { + Assert.Contains(expectedDescriptor, visitor.Matches, TagHelperDescriptorComparer.Default); + } + } + + public static TheoryData ProcessTagHelperMatches_EmptyResultData + { + get + { + // source, taghelpers + return new TheoryData> + { + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper *, {AssemblyA}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper {Valid_PlainTagHelperDescriptor.Name}, {AssemblyA} +@removeTagHelper {Valid_InheritedTagHelperDescriptor.Name}, {AssemblyA}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + Valid_InheritedTagHelperDescriptor, + } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB} +@removeTagHelper *, {AssemblyA} +@removeTagHelper *, {AssemblyB}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + Valid_InheritedTagHelperDescriptor, + String_TagHelperDescriptor, + } + }, + { + $@" +@addTagHelper *, {AssemblyA} +@addTagHelper *, {AssemblyB} +@removeTagHelper {Valid_PlainTagHelperDescriptor.Name}, {AssemblyA} +@removeTagHelper {Valid_InheritedTagHelperDescriptor.Name}, {AssemblyA} +@removeTagHelper {String_TagHelperDescriptor.Name}, {AssemblyB}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + Valid_InheritedTagHelperDescriptor, + String_TagHelperDescriptor, + } + }, + { + $@" +@removeTagHelper *, {AssemblyA} +@removeTagHelper {Valid_PlainTagHelperDescriptor.Name}, {AssemblyA}", + new TagHelperDescriptor[0] + }, + { + $@" +@addTagHelper *, {AssemblyA} +@removeTagHelper Mic*, {AssemblyA}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + } + }, + { + $@" +@addTagHelper Mic*, {AssemblyA} +@removeTagHelper {Valid_PlainTagHelperDescriptor.Name}, {AssemblyA} +@removeTagHelper {Valid_InheritedTagHelperDescriptor.Name}, {AssemblyA}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, Valid_InheritedTagHelperDescriptor + } + }, + { + $@" +@addTagHelper Microsoft.*, {AssemblyA} +@addTagHelper System.*, {AssemblyB} +@removeTagHelper Microsoft.AspNetCore.Razor.TagHelpers*, {AssemblyA} +@removeTagHelper System.*, {AssemblyB}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + Valid_InheritedTagHelperDescriptor, + String_TagHelperDescriptor, + } + }, + { + $@" +@addTagHelper ?icrosoft.*, {AssemblyA} +@addTagHelper ?ystem.*, {AssemblyB} +@removeTagHelper *?????r, {AssemblyA} +@removeTagHelper Sy??em.*, {AssemblyB}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + Valid_InheritedTagHelperDescriptor, + String_TagHelperDescriptor, + } + }, + { + $@" +@addTagHelper ?i?crosoft.*, {AssemblyA} +@addTagHelper ??ystem.*, {AssemblyB}", + new TagHelperDescriptor[] + { + Valid_PlainTagHelperDescriptor, + Valid_InheritedTagHelperDescriptor, + String_TagHelperDescriptor, + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(ProcessTagHelperMatches_EmptyResultData))] + public void ProcessDirectives_CanReturnEmptyDescriptorsBasedOnDirectiveDescriptors( + string source, + object tagHelpers) + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(source, filePath: "TestFile"); + var parser = new RazorParser(); + var syntaxTree = parser.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.TagHelperDirectiveVisitor((TagHelperDescriptor[])tagHelpers); + + // Act + visitor.Visit(syntaxTree.Root); + + // Assert + Assert.Empty(visitor.Matches); + } + + [Fact] + public void TagHelperDirectiveVisitor_DoesNotMatch_Components() + { + // Arrange + var componentDescriptor = CreateComponentDescriptor("counter", "SomeProject.Counter", AssemblyA); + var legacyDescriptor = Valid_PlainTagHelperDescriptor; + var descriptors = new[] + { + legacyDescriptor, + componentDescriptor, + }; + var visitor = new DefaultRazorTagHelperBinderPhase.TagHelperDirectiveVisitor(descriptors); + var sourceDocument = CreateTestSourceDocument(); + var tree = RazorSyntaxTree.Parse(sourceDocument); + + // Act + visitor.Visit(tree); + + // Assert + var match = Assert.Single(visitor.Matches); + Assert.Same(legacyDescriptor, match); + } + + private static TagHelperDescriptor CreatePrefixedValidPlainDescriptor(string prefix) + { + return Valid_PlainTagHelperDescriptor; + } + + private static TagHelperDescriptor CreatePrefixedValidInheritedDescriptor(string prefix) + { + return Valid_InheritedTagHelperDescriptor; + } + + private static TagHelperDescriptor CreatePrefixedStringDescriptor(string prefix) + { + return String_TagHelperDescriptor; + } + + private static RazorSourceDocument CreateTestSourceDocument() + { + var content = + @" +@addTagHelper *, TestAssembly + + +"; + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: null); + return sourceDocument; + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null, + IEnumerable> ruleBuilders = null) + { + return CreateDescriptor(TagHelperConventions.DefaultKind, tagName, typeName, assemblyName, attributes, ruleBuilders); + } +#endregion + +#region Components + [Fact] + public void ComponentDirectiveVisitor_DoesNotMatch_LegacyTagHelpers() + { + // Arrange + var currentNamespace = "SomeProject"; + var componentDescriptor = CreateComponentDescriptor("counter", "SomeProject.Counter", AssemblyA); + var legacyDescriptor = Valid_PlainTagHelperDescriptor; + var descriptors = new[] + { + legacyDescriptor, + componentDescriptor, + }; + var sourceDocument = CreateComponentTestSourceDocument(@"", "C:\\SomeFolder\\SomeProject\\Counter.cshtml"); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + Assert.Null(visitor.TagHelperPrefix); + var match = Assert.Single(visitor.Matches); + Assert.Same(componentDescriptor, match); + } + + [Fact] + public void ComponentDirectiveVisitor_AddsErrorOnLegacyTagHelperDirectives() + { + // Arrange + var currentNamespace = "SomeProject"; + var componentDescriptor = CreateComponentDescriptor("counter", "SomeProject.Counter", AssemblyA); + var legacyDescriptor = Valid_PlainTagHelperDescriptor; + var descriptors = new[] + { + legacyDescriptor, + componentDescriptor, + }; + var filePath = "C:\\SomeFolder\\SomeProject\\Counter.cshtml"; + var content = @" +@tagHelperPrefix th: + + +"; + var sourceDocument = CreateComponentTestSourceDocument(content, filePath); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + Assert.Null(visitor.TagHelperPrefix); + var match = Assert.Single(visitor.Matches); + Assert.Same(componentDescriptor, match); + var directiveChunkGenerator = (TagHelperPrefixDirectiveChunkGenerator)tree.Root.DescendantNodes().First(n => n is CSharpStatementLiteralSyntax).GetSpanContext().ChunkGenerator; + var diagnostic = Assert.Single(directiveChunkGenerator.Diagnostics); + Assert.Equal("RZ9978", diagnostic.Id); + } + + [Fact] + public void ComponentDirectiveVisitor_MatchesFullyQualifiedComponents() + { + // Arrange + var currentNamespace = "SomeProject"; + var componentDescriptor = CreateComponentDescriptor( + "SomeProject.SomeOtherFolder.Counter", + "SomeProject.SomeOtherFolder.Counter", + AssemblyA, + fullyQualified: true); + var descriptors = new[] + { + componentDescriptor, + }; + var filePath = "C:\\SomeFolder\\SomeProject\\Counter.cshtml"; + var content = @" +"; + var sourceDocument = CreateComponentTestSourceDocument(content, filePath); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + var match = Assert.Single(visitor.Matches); + Assert.Same(componentDescriptor, match); + } + + [Fact] + public void ComponentDirectiveVisitor_ComponentInScope_MatchesChildContent() + { + // Arrange + var currentNamespace = "SomeProject"; + var componentDescriptor = CreateComponentDescriptor( + "Counter", + "SomeProject.Counter", + AssemblyA); + var childContentDescriptor = CreateComponentDescriptor( + "ChildContent", + "SomeProject.Counter.ChildContent", + AssemblyA, + childContent: true); + var descriptors = new[] + { + componentDescriptor, + childContentDescriptor, + }; + var filePath = "C:\\SomeFolder\\SomeProject\\Counter.cshtml"; + var content = @" +"; + var sourceDocument = CreateComponentTestSourceDocument(content, filePath); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + Assert.Equal(2, visitor.Matches.Count); + } + + [Fact] + public void ComponentDirectiveVisitor_NullCurrentNamespace_MatchesOnlyFullyQualifiedComponents() + { + // Arrange + string currentNamespace = null; + var componentDescriptor = CreateComponentDescriptor( + "Counter", + "SomeProject.Counter", + AssemblyA); + var fullyQualifiedComponent = CreateComponentDescriptor( + "SomeProject.SomeOtherFolder.Counter", + "SomeProject.SomeOtherFolder.Counter", + AssemblyA, + fullyQualified: true); + var descriptors = new[] + { + componentDescriptor, + fullyQualifiedComponent, + }; + var filePath = "C:\\SomeFolder\\SomeProject\\Counter.cshtml"; + var content = @" +"; + var sourceDocument = CreateComponentTestSourceDocument(content, filePath); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + var match = Assert.Single(visitor.Matches); + Assert.Same(fullyQualifiedComponent, match); + } + + [Fact] + public void ComponentDirectiveVisitor_MatchesIfNamespaceInUsing() + { + // Arrange + var currentNamespace = "SomeProject"; + var componentDescriptor = CreateComponentDescriptor( + "Counter", + "SomeProject.Counter", + AssemblyA); + var anotherComponentDescriptor = CreateComponentDescriptor( + "Foo", + "SomeProject.SomeOtherFolder.Foo", + AssemblyA); + var descriptors = new[] + { + componentDescriptor, + anotherComponentDescriptor, + }; + var filePath = "C:\\SomeFolder\\SomeProject\\Counter.cshtml"; + var content = @" +@using SomeProject.SomeOtherFolder +"; + var sourceDocument = CreateComponentTestSourceDocument(content, filePath); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + Assert.Equal(2, visitor.Matches.Count); + } + + [Fact] + public void ComponentDirectiveVisitor_DoesNotMatchForUsingAliasAndStaticUsings() + { + // Arrange + var currentNamespace = "SomeProject"; + var componentDescriptor = CreateComponentDescriptor( + "Counter", + "SomeProject.Counter", + AssemblyA); + var anotherComponentDescriptor = CreateComponentDescriptor( + "Foo", + "SomeProject.SomeOtherFolder.Foo", + AssemblyA); + var descriptors = new[] + { + componentDescriptor, + anotherComponentDescriptor, + }; + var filePath = "C:\\SomeFolder\\SomeProject\\Counter.cshtml"; + var content = @" +@using Bar = SomeProject.SomeOtherFolder +@using static SomeProject.SomeOtherFolder.Foo +"; + var sourceDocument = CreateComponentTestSourceDocument(content, filePath); + var tree = RazorSyntaxTree.Parse(sourceDocument); + var visitor = new DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor(sourceDocument.FilePath, descriptors, currentNamespace); + + // Act + visitor.Visit(tree); + + // Assert + var match = Assert.Single(visitor.Matches); + Assert.Same(componentDescriptor, match); + } + + [Theory] + [InlineData("", "", true)] + [InlineData("Foo", "Project", true)] + [InlineData("Project.Foo", "Project", true)] + [InlineData("Project.Bar.Foo", "Project.Bar", true)] + [InlineData("Project.Foo", "Project.Bar", false)] + [InlineData("Project.Bar.Foo", "Project", false)] + [InlineData("Bar.Foo", "Project", false)] + public void IsTypeInNamespace_WorksAsExpected(string typeName, string @namespace, bool expected) + { + // Arrange & Act + var result = DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor.IsTypeInNamespace(typeName, @namespace); + + // Assert + Assert.Equal(expected, result); + } + + [Theory] + [InlineData("", "", true)] + [InlineData("Foo", "Project", true)] + [InlineData("Project.Foo", "Project", true)] + [InlineData("Project.Bar.Foo", "Project.Bar", true)] + [InlineData("Project.Foo", "Project.Bar", true)] + [InlineData("Project.Bar.Foo", "Project", false)] + [InlineData("Bar.Foo", "Project", false)] + public void IsTypeInScope_WorksAsExpected(string typeName, string currentNamespace, bool expected) + { + // Arrange & Act + var result = DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor.IsTypeInScope(typeName, currentNamespace); + + // Assert + Assert.Equal(expected, result); + } + + [Fact] + public void IsTagHelperFromMangledClass_WorksAsExpected() + { + // Arrange + var className = "Counter"; + var typeName = $"SomeProject.SomeNamespace.{ComponentMetadata.MangleClassName(className)}"; + var descriptor = CreateComponentDescriptor( + tagName: "Counter", + typeName: typeName, + assemblyName: AssemblyA); + + // Act + var result = DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor.IsTagHelperFromMangledClass(descriptor); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("", false, "", "")] + [InlineData(".", true, "", "")] + [InlineData("Foo", true, "", "Foo")] + [InlineData("SomeProject.Foo", true, "SomeProject", "Foo")] + [InlineData("SomeProject.Foo", true, "SomeProject", "Foo")] + [InlineData("SomeProject.Foo", true, "SomeProject", "Foo")] + [InlineData("SomeProject.Foo>", true, "", "SomeProject.Foo>")] + [InlineData("SomeProject..Foo", true, "SomeProject.", "Foo")] + public void TrySplitNamespaceAndType_WorksAsExpected(string fullTypeName, bool expectedResult, string expectedNamespace, string expectedTypeName) + { + // Arrange & Act + var result = DefaultRazorTagHelperBinderPhase.ComponentDirectiveVisitor.TrySplitNamespaceAndType( + fullTypeName, out var @namespace, out var typeName); + + // Assert + Assert.Equal(expectedResult, result); + Assert.Equal(expectedNamespace, @namespace); + Assert.Equal(expectedTypeName, typeName); + } + + private static RazorSourceDocument CreateComponentTestSourceDocument(string content, string filePath = null) + { + var sourceDocument = TestRazorSourceDocument.Create(content, filePath: filePath); + return sourceDocument; + } + + private static TagHelperDescriptor CreateComponentDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null, + IEnumerable> ruleBuilders = null, + string kind = null, + bool fullyQualified = false, + bool childContent = false) + { + kind = kind ?? ComponentMetadata.Component.TagHelperKind; + return CreateDescriptor(kind, tagName, typeName, assemblyName, attributes, ruleBuilders, fullyQualified, childContent); + } +#endregion + + private static TagHelperDescriptor CreateDescriptor( + string kind, + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null, + IEnumerable> ruleBuilders = null, + bool componentFullyQualified = false, + bool componentChildContent = false) + { + var builder = TagHelperDescriptorBuilder.Create(kind, typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BoundAttributeDescriptor(attributeBuilder); + } + } + + if (ruleBuilders != null) + { + foreach (var ruleBuilder in ruleBuilders) + { + builder.TagMatchingRuleDescriptor(innerRuleBuilder => + { + innerRuleBuilder.RequireTagName(tagName); + ruleBuilder(innerRuleBuilder); + }); + } + } + else + { + builder.TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + } + + if (componentFullyQualified) + { + builder.Metadata[ComponentMetadata.Component.NameMatchKey] = ComponentMetadata.Component.FullyQualifiedNameMatch; + } + + if (componentChildContent) + { + builder.Metadata[ComponentMetadata.SpecialKindKey] = ComponentMetadata.ChildContent.TagHelperKind; + } + + var descriptor = builder.Build(); + + return descriptor; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs new file mode 100644 index 0000000000..7f81d74e66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs @@ -0,0 +1,48 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DefaultRequiredAttributeDescriptorBuilderTest + { + [Fact] + public void Build_DisplayNameIsName_NameComparisonFullMatch() + { + // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder); + + builder + .Name("asp-action") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch); + + // Act + var descriptor = builder.Build(); + + // Assert + Assert.Equal("asp-action", descriptor.DisplayName); + } + + [Fact] + public void Build_DisplayNameIsNameWithDots_NameComparisonPrefixMatch() + { + // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder); + + builder + .Name("asp-route-") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch); + + // Act + var descriptor = builder.Build(); + + // Assert + Assert.Equal("asp-route-...", descriptor.DisplayName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs new file mode 100644 index 0000000000..6e78ea1eec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs @@ -0,0 +1,150 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DirectiveDescriptorBuilderExtensionsTest + { + [Fact] + public void AddMemberToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddMemberToken()); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Member, token.Kind); + Assert.False(token.Optional); + Assert.Null(token.Name); + Assert.Null(token.Description); + } + + [Fact] + public void AddNamespaceToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken("Name", "Description")); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Namespace, token.Kind); + Assert.False(token.Optional); + Assert.Equal("Name", token.Name); + Assert.Equal("Description", token.Description); + } + + [Fact] + public void AddStringToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddStringToken()); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.String, token.Kind); + Assert.False(token.Optional); + Assert.Null(token.Name); + Assert.Null(token.Description); + } + + [Fact] + public void AddTypeToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddTypeToken("Name", "Description")); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Type, token.Kind); + Assert.False(token.Optional); + Assert.Equal("Name", token.Name); + Assert.Equal("Description", token.Description); + } + + [Fact] + public void AddOptionalTypeToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddOptionalTypeToken()); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Type, token.Kind); + Assert.True(token.Optional); + Assert.Null(token.Name); + Assert.Null(token.Description); + } + + [Fact] + public void AddOptionalMemberToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddOptionalMemberToken("Name", "Description")); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Member, token.Kind); + Assert.True(token.Optional); + Assert.Equal("Name", token.Name); + Assert.Equal("Description", token.Description); + } + + [Fact] + public void AddOptionalNamespaceToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddOptionalNamespaceToken()); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Namespace, token.Kind); + Assert.True(token.Optional); + Assert.Null(token.Name); + Assert.Null(token.Description); + } + + [Fact] + public void AddOptionalStringToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddOptionalStringToken("Name", "Description")); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.String, token.Kind); + Assert.True(token.Optional); + Assert.Equal("Name", token.Name); + Assert.Equal("Description", token.Description); + } + + [Fact] + public void AddAttributeToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddAttributeToken("Name", "Description")); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Attribute, token.Kind); + Assert.False(token.Optional); + Assert.Equal("Name", token.Name); + Assert.Equal("Description", token.Description); + } + + [Fact] + public void AddOptionalAttributeToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddOptionalAttributeToken()); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.Attribute, token.Kind); + Assert.True(token.Optional); + Assert.Null(token.Name); + Assert.Null(token.Description); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorTest.cs new file mode 100644 index 0000000000..a5bb3c8434 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorTest.cs @@ -0,0 +1,150 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DirectiveDescriptorTest + { + [Fact] + public void CreateDirective_CreatesDirective_WithProvidedKind() + { + // Arrange & Act + var directive = DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.SingleLine, directive.Kind); + } + + [Fact] + public void CreateDirective_WithConfigure_CreatesDirective_WithProvidedKind() + { + // Arrange + var called = false; + Action configure = b => { called = true; }; + + // Act + var directive = DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine, configure); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.SingleLine, directive.Kind); + Assert.True(called); + } + + [Fact] + public void CreateSingleLineDirective_CreatesSingleLineDirective() + { + // Arrange & Act + var directive = DirectiveDescriptor.CreateSingleLineDirective("test"); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.SingleLine, directive.Kind); + } + + [Fact] + public void CreateSingleLineDirective_WithConfigure_CreatesSingleLineDirective() + { + // Arrange + var called = false; + Action configure = b => { called = true; }; + + // Act + var directive = DirectiveDescriptor.CreateSingleLineDirective("test", configure); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.SingleLine, directive.Kind); + Assert.True(called); + } + + [Fact] + public void CreateRazorBlockDirective_CreatesRazorBlockDirective() + { + // Arrange & Act + var directive = DirectiveDescriptor.CreateRazorBlockDirective("test"); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.RazorBlock, directive.Kind); + } + + [Fact] + public void CreateRazorBlockDirective_WithConfigure_CreatesRazorBlockDirective() + { + // Arrange + var called = false; + Action configure = b => { called = true; }; + + // Act + var directive = DirectiveDescriptor.CreateRazorBlockDirective("test", configure); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.RazorBlock, directive.Kind); + Assert.True(called); + } + + [Fact] + public void CreateCodeBlockDirective_CreatesCodeBlockDirective() + { + // Arrange & Act + var directive = DirectiveDescriptor.CreateCodeBlockDirective("test"); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.CodeBlock, directive.Kind); + } + + [Fact] + public void CreateCodeBlockDirective_WithConfigure_CreatesCodeBlockDirective() + { + // Arrange + var called = false; + Action configure = b => { called = true; }; + + // Act + var directive = DirectiveDescriptor.CreateCodeBlockDirective("test", configure); + + // Assert + Assert.Equal("test", directive.Directive); + Assert.Equal(DirectiveKind.CodeBlock, directive.Kind); + Assert.True(called); + } + + [Fact] + public void Build_ValidatesDirectiveKeyword_EmptyIsInvalid() + { + // Arrange & Act + var ex = Assert.Throws(() => DirectiveDescriptor.CreateSingleLineDirective("")); + + // Assert + Assert.Equal("Invalid directive keyword ''. Directives must have a non-empty keyword that consists only of letters.", ex.Message); + } + + [Fact] + public void Build_ValidatesDirectiveKeyword_InvalidCharacter() + { + // Arrange & Act + var ex = Assert.Throws(() => DirectiveDescriptor.CreateSingleLineDirective("test_directive")); + + // Assert + Assert.Equal("Invalid directive keyword 'test_directive'. Directives must have a non-empty keyword that consists only of letters.", ex.Message); + } + + [Fact] + public void Build_ValidatesDirectiveName_NonOptionalTokenFollowsOptionalToken() + { + // Arrange & Act + var ex = Assert.Throws( + () => DirectiveDescriptor.CreateSingleLineDirective("test", b => { b.AddOptionalMemberToken(); b.AddMemberToken(); })); + + // Assert + Assert.Equal("A non-optional directive token cannot follow an optional directive token.", ex.Message); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs new file mode 100644 index 0000000000..3e831b7d23 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveRemovalOptimizationPassTest.cs @@ -0,0 +1,135 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DirectiveRemovalOptimizationPassTest + { + [Fact] + public void Execute_Custom_RemovesDirectiveNodeFromDocument() + { + // Arrange + var content = "@custom \"Hello\""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var defaultEngine = RazorProjectEngine.Create(b => + { + b.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, d => d.AddStringToken())); + }).Engine; + var documentNode = Lower(codeDocument, defaultEngine); + var pass = new DirectiveRemovalOptimizationPass() + { + Engine = defaultEngine, + }; + + // Act + pass.Execute(codeDocument, documentNode); + + // Assert + Children(documentNode, + node => Assert.IsType(node)); + var @namespace = documentNode.Children[0]; + Children(@namespace, + node => Assert.IsType(node)); + var @class = @namespace.Children[0]; + var method = SingleChild(@class); + Assert.Empty(method.Children); + } + + [Fact] + public void Execute_MultipleCustomDirectives_RemovesDirectiveNodesFromDocument() + { + // Arrange + var content = "@custom \"Hello\"" + Environment.NewLine + "@custom \"World\""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var defaultEngine = RazorProjectEngine.Create(b => + { + b.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, d => d.AddStringToken())); + }).Engine; + var documentNode = Lower(codeDocument, defaultEngine); + var pass = new DirectiveRemovalOptimizationPass() + { + Engine = defaultEngine, + }; + + // Act + pass.Execute(codeDocument, documentNode); + + // Assert + Children(documentNode, + node => Assert.IsType(node)); + var @namespace = documentNode.Children[0]; + Children(@namespace, + node => Assert.IsType(node)); + var @class = @namespace.Children[0]; + var method = SingleChild(@class); + Assert.Empty(method.Children); + } + + [Fact] + public void Execute_DirectiveWithError_PreservesDiagnosticsAndRemovesDirectiveNodeFromDocument() + { + // Arrange + var content = "@custom \"Hello\""; + var expectedDiagnostic = RazorDiagnostic.Create(new RazorDiagnosticDescriptor("RZ9999", () => "Some diagnostic message.", RazorDiagnosticSeverity.Error), SourceSpan.Undefined); + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var defaultEngine = RazorProjectEngine.Create(b => + { + b.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, d => d.AddStringToken())); + }).Engine; + var documentNode = Lower(codeDocument, defaultEngine); + + // Add the diagnostic to the directive node. + var directiveNode = documentNode.FindDescendantNodes().Single(); + directiveNode.Diagnostics.Add(expectedDiagnostic); + + var pass = new DirectiveRemovalOptimizationPass() + { + Engine = defaultEngine, + }; + + // Act + pass.Execute(codeDocument, documentNode); + + // Assert + var diagnostic = Assert.Single(documentNode.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + + Children(documentNode, + node => Assert.IsType(node)); + var @namespace = documentNode.Children[0]; + Children(@namespace, + node => Assert.IsType(node)); + var @class = @namespace.Children[0]; + var method = SingleChild(@class); + Assert.Empty(method.Children); + } + + private static DocumentIntermediateNode Lower(RazorCodeDocument codeDocument, RazorEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorDirectiveClassifierPhase) + { + break; + } + } + + var documentNode = codeDocument.GetDocumentIntermediateNode(); + Assert.NotNull(documentNode); + + return documentNode; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveTokenEditHandlerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveTokenEditHandlerTest.cs new file mode 100644 index 0000000000..1f0336d008 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveTokenEditHandlerTest.cs @@ -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.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test +{ + public class DirectiveTokenEditHandlerTest + { + [Theory] + [InlineData(0, 4, "")] // "Namespace" + [InlineData(4, 0, "Other")] // "SomeOtherNamespace" + [InlineData(0, 4, "Other")] // "OtherNamespace" + public void CanAcceptChange_ProvisionallyAcceptsNonWhitespaceChanges(int index, int length, string newText) + { + // Arrange + var directiveTokenHandler = new TestDirectiveTokenEditHandler(); + directiveTokenHandler.AcceptedCharacters = AcceptedCharactersInternal.NonWhitespace; + + var target = GetSyntaxNode(directiveTokenHandler, "SomeNamespace"); + + var sourceChange = new SourceChange(index, length, newText); + + // Act + var result = directiveTokenHandler.CanAcceptChange(target, sourceChange); + + // Assert + Assert.Equal(PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional, result); + } + + [Theory] + [InlineData(4, 1, "")] // "SomeNamespace" + [InlineData(9, 0, " ")] // "Some Name space" + [InlineData(9, 5, " Space")] // "Some Name Space" + public void CanAcceptChange_RejectsWhitespaceChanges(int index, int length, string newText) + { + // Arrange + var directiveTokenHandler = new TestDirectiveTokenEditHandler(); + directiveTokenHandler.AcceptedCharacters = AcceptedCharactersInternal.NonWhitespace; + + var target = GetSyntaxNode(directiveTokenHandler, "Some Namespace"); + + var sourceChange = new SourceChange(index, length, newText); + + // Act + var result = directiveTokenHandler.CanAcceptChange(target, sourceChange); + + // Assert + Assert.Equal(PartialParseResultInternal.Rejected, result); + } + + private static CSharpStatementLiteralSyntax GetSyntaxNode(DirectiveTokenEditHandler editHandler, string content) + { + var builder = SyntaxListBuilder.Create(); + var tokens = CSharpLanguageCharacteristics.Instance.TokenizeString(content).ToArray(); + foreach (var token in tokens) + { + builder.Add((SyntaxToken)token.CreateRed()); + } + var node = SyntaxFactory.CSharpStatementLiteral(builder.ToList()); + + var context = new SpanContext(SpanChunkGenerator.Null, editHandler); + + return node.WithSpanContext(context); + } + + private class TestDirectiveTokenEditHandler : DirectiveTokenEditHandler + { + public TestDirectiveTokenEditHandler() : base(content => TestTokenizer(content)) + { + } + + public new PartialParseResultInternal CanAcceptChange(SyntaxNode target, SourceChange change) + => base.CanAcceptChange(target, change); + + internal static IEnumerable TestTokenizer(string str) + { + yield return Syntax.InternalSyntax.SyntaxFactory.Token(SyntaxKind.Marker, str); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs new file mode 100644 index 0000000000..e63768bf54 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DocumentClassifierPassBaseTest.cs @@ -0,0 +1,295 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class DocumentClassifierPassBaseTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + + public RazorEngine Engine => CreateProjectEngine().Engine; + + [Fact] + public void Execute_HasDocumentKind_IgnoresDocument() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + DocumentKind = "ignore", + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var pass = new TestDocumentClassifierPass(); + pass.Engine = Engine; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + Assert.Equal("ignore", documentNode.DocumentKind); + NoChildren(documentNode); + } + + [Fact] + public void Execute_NoMatch_IgnoresDocument() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var pass = new TestDocumentClassifierPass() + { + Engine = Engine, + ShouldMatch = false, + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + Assert.Null(documentNode.DocumentKind); + NoChildren(documentNode); + } + + [Fact] + public void Execute_Match_AddsGlobalTargetExtensions() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var expected = new ICodeTargetExtension[] + { + new MyExtension1(), + new MyExtension2(), + }; + + var pass = new TestDocumentClassifierPass(); + pass.Engine = RazorProjectEngine.CreateEmpty(b => + { + for (var i = 0; i < expected.Length; i++) + { + b.AddTargetExtension(expected[i]); + } + }).Engine; + + ICodeTargetExtension[] extensions = null; + + pass.CodeTargetCallback = (builder) => extensions = builder.TargetExtensions.ToArray(); + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + Assert.Equal(expected, extensions); + } + + [Fact] + public void Execute_Match_SetsDocumentType_AndCreatesStructure() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var pass = new TestDocumentClassifierPass(); + pass.Engine = Engine; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + Assert.Equal("test", documentNode.DocumentKind); + Assert.NotNull(documentNode.Target); + + var @namespace = SingleChild(documentNode); + var @class = SingleChild(@namespace); + var method = SingleChild(@class); + NoChildren(method); + } + + [Fact] + public void Execute_AddsUsingsToNamespace() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(documentNode); + builder.Add(new UsingDirectiveIntermediateNode()); + + var pass = new TestDocumentClassifierPass(); + pass.Engine = Engine; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + var @namespace = SingleChild(documentNode); + Children( + @namespace, + n => Assert.IsType(n), + n => Assert.IsType(n)); + } + + [Fact] + public void Execute_AddsTheRestToMethod() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(documentNode); + builder.Add(new HtmlContentIntermediateNode()); + builder.Add(new CSharpCodeIntermediateNode()); + + var pass = new TestDocumentClassifierPass(); + pass.Engine = Engine; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + var @namespace = SingleChild(documentNode); + var @class = SingleChild(@namespace); + var method = SingleChild(@class); + Children( + method, + n => Assert.IsType(n), + n => Assert.IsType(n)); + } + + [Fact] + public void Execute_CanInitializeDefaults() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(documentNode); + builder.Add(new HtmlContentIntermediateNode()); + builder.Add(new CSharpCodeIntermediateNode()); + + var pass = new TestDocumentClassifierPass() + { + Engine = Engine, + Namespace = "TestNamespace", + Class = "TestClass", + Method = "TestMethod", + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + var @namespace = SingleChild(documentNode); + Assert.Equal("TestNamespace", @namespace.Content); + + var @class = SingleChild(@namespace); + Assert.Equal("TestClass", @class.ClassName); + + var method = SingleChild(@class); + Assert.Equal("TestMethod", method.MethodName); + } + + [Fact] + public void Execute_AddsPrimaryAnnotations() + { + // Arrange + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.CreateDefault(), + }; + + var builder = IntermediateNodeBuilder.Create(documentNode); + builder.Add(new HtmlContentIntermediateNode()); + builder.Add(new CSharpCodeIntermediateNode()); + + var pass = new TestDocumentClassifierPass() + { + Engine = Engine, + Namespace = "TestNamespace", + Class = "TestClass", + Method = "TestMethod", + }; + + // Act + pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode); + + // Assert + var @namespace = SingleChild(documentNode); + AnnotationEquals(@namespace, CommonAnnotations.PrimaryNamespace); + + var @class = SingleChild(@namespace); + AnnotationEquals(@class, CommonAnnotations.PrimaryClass); + + var method = SingleChild(@class); + AnnotationEquals(method, CommonAnnotations.PrimaryMethod); + } + + private class TestDocumentClassifierPass : DocumentClassifierPassBase + { + public override int Order => IntermediateNodePassBase.DefaultFeatureOrder; + + public bool ShouldMatch { get; set; } = true; + + public Action CodeTargetCallback { get; set; } + + public string Namespace { get; set; } + + public string Class { get; set; } + + public string Method { get; set; } + + protected override string DocumentKind => "test"; + + protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + return ShouldMatch; + } + + protected override void OnDocumentStructureCreated( + RazorCodeDocument codeDocument, + NamespaceDeclarationIntermediateNode @namespace, + ClassDeclarationIntermediateNode @class, + MethodDeclarationIntermediateNode method) + { + @namespace.Content = Namespace; + @class.ClassName = Class; + @method.MethodName = Method; + } + + protected override void ConfigureTarget(CodeTargetBuilder builder) + { + CodeTargetCallback?.Invoke(builder); + } + } + + private class MyExtension1 : ICodeTargetExtension + { + } + + private class MyExtension2 : ICodeTargetExtension + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultMetadataIdentifierFeatureTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultMetadataIdentifierFeatureTest.cs new file mode 100644 index 0000000000..fec5a77cc1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultMetadataIdentifierFeatureTest.cs @@ -0,0 +1,74 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class DefaultMetadataIdentifierFeatureTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + + [Fact] + public void GetIdentifier_ReturnsNull_ForNullRelativePath() + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", null)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Null(result); + } + + [Fact] + public void GetIdentifier_ReturnsNull_ForEmptyRelativePath() + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", string.Empty)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Null(result); + } + + [Theory] + [InlineData("Test.cshtml", "/Test.cshtml")] + [InlineData("/Test.cshtml", "/Test.cshtml")] + [InlineData("\\Test.cshtml", "/Test.cshtml")] + [InlineData("\\About\\Test.cshtml", "/About/Test.cshtml")] + [InlineData("\\About\\Test\\cshtml", "/About/Test/cshtml")] + public void GetIdentifier_SanitizesRelativePath(string relativePath, string expected) + { + // Arrange + var sourceDocument = RazorSourceDocument.Create("content", new RazorSourceDocumentProperties("Test.cshtml", relativePath)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var feature = new DefaultMetadataIdentifierFeature() + { + Engine = CreateProjectEngine().Engine, + }; + + // Act + var result = feature.GetIdentifier(codeDocument, sourceDocument); + + // Assert + Assert.Equal(expected, result); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs new file mode 100644 index 0000000000..104c63c752 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs @@ -0,0 +1,128 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class DefaultTagHelperOptimizationPassTest + { + [Fact] + public void DefaultTagHelperOptimizationPass_Execute_ReplacesChildren() + { + // Arrange + var codeDocument = CreateDocument(@" +@addTagHelper TestTagHelper, TestAssembly +

"); + + var tagHelpers = new[] + { + TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly") + .TypeName("TestTagHelper") + .BoundAttributeDescriptor(attribute => attribute + .Name("Foo") + .TypeName("System.Int32") + .PropertyName("FooProp")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build() + }; + + var engine = CreateEngine(tagHelpers); + var pass = new DefaultTagHelperOptimizationPass() + { + Engine = engine + }; + + var irDocument = CreateIRDocument(engine, codeDocument); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + var @class = irDocument.FindPrimaryClass(); + Assert.IsType(@class.Children[0]); + + var fieldDeclaration = Assert.IsType(@class.Children[1]); + Assert.Equal(bool.TrueString, fieldDeclaration.Annotations[CommonAnnotations.DefaultTagHelperExtension.TagHelperField]); + Assert.Equal("__TestTagHelper", fieldDeclaration.FieldName); + Assert.Equal("global::TestTagHelper", fieldDeclaration.FieldType); + Assert.Equal("private", fieldDeclaration.Modifiers.First()); + + var tagHelper = FindTagHelperNode(irDocument); + Assert.Equal(5, tagHelper.Children.Count); + + var body = Assert.IsType(tagHelper.Children[0]); + Assert.Equal("p", body.TagName); + Assert.Equal(TagMode.StartTagAndEndTag, body.TagMode); + + var create = Assert.IsType(tagHelper.Children[1]); + Assert.Equal("__TestTagHelper", create.FieldName); + Assert.Equal("TestTagHelper", create.TypeName); + Assert.Equal(tagHelpers[0], create.TagHelper, TagHelperDescriptorComparer.Default); + + var property = Assert.IsType(tagHelper.Children[2]); + Assert.Equal("foo", property.AttributeName); + Assert.Equal(AttributeStructure.DoubleQuotes, property.AttributeStructure); + Assert.Equal(tagHelpers[0].BoundAttributes[0], property.BoundAttribute, BoundAttributeDescriptorComparer.Default); + Assert.Equal("__TestTagHelper", property.FieldName); + Assert.False(property.IsIndexerNameMatch); + Assert.Equal("FooProp", property.PropertyName); + Assert.Equal(tagHelpers[0], property.TagHelper, TagHelperDescriptorComparer.Default); + + var htmlAttribute = Assert.IsType(tagHelper.Children[3]); + Assert.Equal("attr", htmlAttribute.AttributeName); + Assert.Equal(AttributeStructure.DoubleQuotes, htmlAttribute.AttributeStructure); + + Assert.IsType(tagHelper.Children[4]); + } + + 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 class TagHelperNodeVisitor : IntermediateNodeWalker + { + public TagHelperIntermediateNode Node { get; set; } + + public override void VisitTagHelper(TagHelperIntermediateNode node) + { + Node = node; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperTargetExtensionTest.cs new file mode 100644 index 0000000000..fba53cd721 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperTargetExtensionTest.cs @@ -0,0 +1,1247 @@ +// 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.CodeGeneration; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class DefaultTagHelperTargetExtensionTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + + private static readonly TagHelperDescriptor StringPropertyTagHelper = CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("StringProp") + .TypeName("System.String"), + }); + + private static readonly TagHelperDescriptor IntPropertyTagHelper = CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("IntProp") + .TypeName("System.Int32"), + }); + + private static readonly TagHelperDescriptor StringIndexerTagHelper = CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("StringIndexer") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionary("foo-", "System.String"), + }); + + private static readonly TagHelperDescriptor IntIndexerTagHelper = CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("IntIndexer") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionary("foo-", "System.Int32"), + }); + + private static readonly SourceSpan Span = new SourceSpan("test.cshtml", 15, 2, 5, 2); + + [Fact] + public void WriteTagHelperBody_DesignTime_WritesChildren() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperBodyIntermediateNode() + { + Children = + { + new CSharpExpressionIntermediateNode(), + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperBody(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"Render Children +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperBody_Runtime_RendersCorrectly_UsesTagNameAndModeFromContext() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperBodyIntermediateNode() + { + Children = + { + new CSharpExpressionIntermediateNode(), + }, + TagMode = TagMode.SelfClosing, + TagName = "p", + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperBody(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__tagHelperExecutionContext = __tagHelperScopeManager.Begin(""p"", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, ""test"", async() => { + Render Children +} +); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperCreate_DesignTime_RendersCorrectly_UsesSpecifiedTagHelperType() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperCreateIntermediateNode() + { + FieldName = "__TestNamespace_MyTagHelper", + TypeName = "TestNamespace.MyTagHelper", + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperCreate(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__TestNamespace_MyTagHelper = CreateTagHelper(); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperCreate_Runtime_RendersCorrectly_UsesSpecifiedTagHelperType() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperCreateIntermediateNode() + { + FieldName = "__TestNamespace_MyTagHelper", + TypeName = "TestNamespace.MyTagHelper", + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperCreate(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__TestNamespace_MyTagHelper = CreateTagHelper(); +__tagHelperExecutionContext.Add(__TestNamespace_MyTagHelper); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperExecute_DesignTime_RendersAsyncCode() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperExecuteIntermediateNode(); + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperExecute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperExecute_Runtime_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperExecuteIntermediateNode(); + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperExecute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +if (!__tagHelperExecutionContext.Output.IsContentModified) +{ + await __tagHelperExecutionContext.SetOutputContentAsync(); +} +Write(__tagHelperExecutionContext.Output); +__tagHelperExecutionContext = __tagHelperScopeManager.End(); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperHtmlAttribute_DesignTime_WritesNothing() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperHtmlAttributeIntermediateNode() + { + AttributeName = "name", + AttributeStructure = AttributeStructure.DoubleQuotes, + Children = + { + new HtmlAttributeValueIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.Html, Content = "Blah-" } } + }, + new CSharpCodeAttributeValueIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "\"Foo\"", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"Render Children +Render Children +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperHtmlAttribute_Runtime_SimpleAttribute_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperHtmlAttributeIntermediateNode() + { + AttributeName = "name", + AttributeStructure = AttributeStructure.DoubleQuotes, + Children = + { + new HtmlAttributeIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.Html, Content = "\"value\"", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"BeginWriteTagHelperAttribute(); +Render Children +__tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); +__tagHelperExecutionContext.AddHtmlAttribute(""name"", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperHtmlAttribute_Runtime_DynamicAttribute_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperHtmlAttributeIntermediateNode() + { + AttributeName = "name", + AttributeStructure = AttributeStructure.DoubleQuotes, + Children = + { + new HtmlAttributeValueIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.Html, Content = "Blah-" } } + }, + new CSharpCodeAttributeValueIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "\"Foo\"", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"BeginAddHtmlAttributeValues(__tagHelperExecutionContext, ""name"", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +Render Children +Render Children +EndAddHtmlAttributeValues(__tagHelperExecutionContext); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonString_StatementInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = false, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_CodeBlocksNotSupportedInAttributes(expectedLocation); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new CSharpCodeIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonStringIndexerMatch_TemplateInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = true, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(expectedLocation, "System.Int32"); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new TemplateIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void RenderTagHelperAttributeInline_NonString_TemplateInAttribute_Errors() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + IsIndexerNameMatch = false, + }; + var expectedLocation = new SourceSpan(100, 10); + var expectedDiagnostic = RazorDiagnosticFactory.CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes( + expectedLocation, + "System.Collections.Generic.Dictionary"); + + // Act + extension.RenderTagHelperAttributeInline(context, node, new TemplateIntermediateNode(), expectedLocation); + + // Assert + var diagnostic = Assert.Single(context.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + + [Fact] + public void WriteTagHelperProperty_DesignTime_StringProperty_HtmlContent_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = StringPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "StringProp", + TagHelper = StringPropertyTagHelper, + Children = + { + new HtmlContentIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.Html, Content = "value", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"Render Children +__InputTagHelper.StringProp = ""value""; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] // We don't actually assign the expression result at design time, we just use string.Empty as a placeholder. + public void WriteTagHelperProperty_DesignTime_StringProperty_NonHtmlContent_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = StringPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "StringProp", + TagHelper = StringPropertyTagHelper, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "\"3+5\"", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"Render Children +__InputTagHelper.StringProp = string.Empty; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "IntProp", + TagHelper = IntPropertyTagHelper, + Source = Span, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@" +#nullable restore +#line 3 ""test.cshtml"" +__InputTagHelper.IntProp = 32; + +#line default +#line hidden +#nullable disable +", + csharp, + ignoreLineEndingDifferences: true); + } + + // If a value is bound to multiple tag helpers, we want to make sure to only render the first + // occurrence of the expression due to side-effects. + [Fact] + public void WriteTagHelperProperty_DesignTime_NonStringProperty_SecondUseOfAttribute() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node1 = new DefaultTagHelperPropertyIntermediateNode() + { + // We only look at the attribute name here. + AttributeName = "bound", + FieldName = "__OtherTagHelper", + PropertyName = "IntProp", + }; + var node2 = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "IntProp", + TagHelper = IntPropertyTagHelper, + Source = Span, + }; + tagHelperNode.Children.Add(node1); + tagHelperNode.Children.Add(node2); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node2); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__InputTagHelper.IntProp = __OtherTagHelper.IntProp; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_DesignTime_NonStringProperty_RendersCorrectly_WithoutLocation() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "IntProp", + TagHelper = IntPropertyTagHelper, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__InputTagHelper.IntProp = 32; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "foo-bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = true, + PropertyName = "IntIndexer", + TagHelper = IntIndexerTagHelper, + Source = Span, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@" +#nullable restore +#line 3 ""test.cshtml"" +__InputTagHelper.IntIndexer[""bound""] = 32; + +#line default +#line hidden +#nullable disable +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_DesignTime_NonStringIndexer_RendersCorrectly_WithoutLocation() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "foo-bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = true, + PropertyName = "IntIndexer", + TagHelper = IntIndexerTagHelper, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__InputTagHelper.IntIndexer[""bound""] = 32; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_Runtime_StringProperty_HtmlContent_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = StringPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "StringProp", + TagHelper = StringPropertyTagHelper, + Children = + { + new HtmlContentIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.Html, Content = "\"value\"", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + + // The attribute value is not rendered inline because we are not using the preallocated writer. + Assert.Equal( +@"BeginWriteTagHelperAttribute(); +Render Children +__tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); +__InputTagHelper.StringProp = __tagHelperStringValueBuffer; +__tagHelperExecutionContext.AddTagHelperAttribute(""bound"", __InputTagHelper.StringProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_Runtime_NonStringProperty_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "IntProp", + TagHelper = IntPropertyTagHelper, + Source = Span, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + }, + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@" +#nullable restore +#line 3 ""test.cshtml"" +__InputTagHelper.IntProp = 32; + +#line default +#line hidden +#nullable disable +__tagHelperExecutionContext.AddTagHelperAttribute(""bound"", __InputTagHelper.IntProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + // If a value is bound to multiple tag helpers, we want to make sure to only render the first + // occurrence of the expression due to side-effects. + [Fact] + public void WriteTagHelperProperty_Runtime_NonStringProperty_SecondUseOfAttribute() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node1 = new DefaultTagHelperPropertyIntermediateNode() + { + // We only look at the attribute name here. + AttributeName = "bound", + FieldName = "__OtherTagHelper", + PropertyName = "IntProp", + }; + var node2 = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "IntProp", + TagHelper = IntPropertyTagHelper, + Source = Span, + }; + tagHelperNode.Children.Add(node1); + tagHelperNode.Children.Add(node2); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node2); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__InputTagHelper.IntProp = __OtherTagHelper.IntProp; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_Runtime_NonStringProperty_RendersCorrectly_WithoutLocation() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntPropertyTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = false, + PropertyName = "IntProp", + TagHelper = IntPropertyTagHelper, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__InputTagHelper.IntProp = 32; +__tagHelperExecutionContext.AddTagHelperAttribute(""bound"", __InputTagHelper.IntProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_Runtime_NonStringIndexer_RendersCorrectly() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "foo-bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = true, + PropertyName = "IntIndexer", + TagHelper = IntIndexerTagHelper, + Source = Span, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"if (__InputTagHelper.IntIndexer == null) +{ + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment(""foo-bound"", ""InputTagHelper"", ""IntIndexer"")); +} +#nullable restore +#line 3 ""test.cshtml"" +__InputTagHelper.IntIndexer[""bound""] = 32; + +#line default +#line hidden +#nullable disable +__tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelper.IntIndexer[""bound""], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] // We should only emit the validation code for the first use of an indexer property. + public void WriteTagHelperProperty_Runtime_NonStringIndexer_MultipleValues() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node1 = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "foo-first", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = true, + PropertyName = "IntIndexer", + TagHelper = IntIndexerTagHelper, + Source = Span, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "17", } }, + } + } + }; + var node2 = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "foo-bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = true, + PropertyName = "IntIndexer", + TagHelper = IntIndexerTagHelper, + Source = Span, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node1); + tagHelperNode.Children.Add(node2); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node2); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@" +#nullable restore +#line 3 ""test.cshtml"" +__InputTagHelper.IntIndexer[""bound""] = 32; + +#line default +#line hidden +#nullable disable +__tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelper.IntIndexer[""bound""], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_Runtime_NonStringIndexer_RendersCorrectly_WithoutLocation() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new DefaultTagHelperPropertyIntermediateNode() + { + AttributeName = "foo-bound", + AttributeStructure = AttributeStructure.DoubleQuotes, + BoundAttribute = IntIndexerTagHelper.BoundAttributes.Single(), + FieldName = "__InputTagHelper", + IsIndexerNameMatch = true, + PropertyName = "IntIndexer", + TagHelper = IntIndexerTagHelper, + Children = + { + new CSharpExpressionIntermediateNode() + { + Children = { new IntermediateToken { Kind = TokenKind.CSharp, Content = "32", } }, + } + } + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"if (__InputTagHelper.IntIndexer == null) +{ + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment(""foo-bound"", ""InputTagHelper"", ""IntIndexer"")); +} +__InputTagHelper.IntIndexer[""bound""] = 32; +__tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelper.IntIndexer[""bound""], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperRuntime_DesignTime_RendersPreRequisites() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DefaultTagHelperRuntimeIntermediateNode(); + + // Act + extension.WriteTagHelperRuntime(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( + @"#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(); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperRuntime_Runtime_DeclaresRequiredFields() + { + // Arrange + var extension = new DefaultTagHelperTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new DefaultTagHelperRuntimeIntermediateNode(); + + // Act + extension.WriteTagHelperRuntime(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#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(); +#pragma warning disable 0169 +private string __tagHelperStringValueBuffer; +#pragma warning restore 0169 +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; + } +} +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void GetDeterministicId_IsDeterministic() + { + // Arrange + var context = TestCodeRenderingContext.CreateRuntime(suppressUniqueIds: null); + + // Act + var firstId = DefaultTagHelperTargetExtension.GetDeterministicId(context); + var secondId = DefaultTagHelperTargetExtension.GetDeterministicId(context); + + // Assert + Assert.Equal(firstId, secondId); + } + + private static void Push(CodeRenderingContext context, TagHelperIntermediateNode node) + { + ((DefaultCodeRenderingContext)context).AncestorsInternal.Push(node); + } + + private DocumentIntermediateNode Lower(RazorCodeDocument codeDocument) + { + var projectEngine = CreateProjectEngine(); + return Lower(codeDocument, projectEngine); + } + + private DocumentIntermediateNode LowerDesignTime(RazorCodeDocument codeDocument) + { + var projectEngine = RazorProjectEngine.Create(b => + { + b.Features.Add(new DesignTimeOptionsFeature(designTime: true)); + }); + + return Lower(codeDocument, projectEngine); + } + + private static DocumentIntermediateNode Lower(RazorCodeDocument codeDocument, RazorProjectEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorIntermediateNodeLoweringPhase) + { + break; + } + } + + var irDocument = codeDocument.GetDocumentIntermediateNode(); + Assert.NotNull(irDocument); + + return irDocument; + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BindAttribute(attributeBuilder); + } + } + + builder.TagMatchingRule(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + + var descriptor = builder.Build(); + + return descriptor; + } + + 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); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DesignTimeDirectiveTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DesignTimeDirectiveTargetExtensionTest.cs new file mode 100644 index 0000000000..4d61b0ef6c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DesignTimeDirectiveTargetExtensionTest.cs @@ -0,0 +1,247 @@ +// 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.Intermediate; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class DesignTimeDirectiveTargetExtensionTest + { + [Fact] + public void WriteDesignTimeDirective_NoChildren_WritesEmptyMethod_WithPragma() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DesignTimeDirectiveIntermediateNode(); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithTypeToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DesignTimeDirectiveIntermediateNode(); + var token = new DirectiveTokenIntermediateNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "System.String", + DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Type), + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +#nullable restore +#line 1 ""test.cshtml"" +System.String __typeHelper = default!; + +#line default +#line hidden +#nullable disable +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithNamespaceToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DesignTimeDirectiveIntermediateNode(); + var token = new DirectiveTokenIntermediateNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "System.Collections.Generic", + DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Namespace), + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +#nullable restore +#line 1 ""test.cshtml"" +global::System.Object __typeHelper = nameof(System.Collections.Generic); + +#line default +#line hidden +#nullable disable +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithMemberToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DesignTimeDirectiveIntermediateNode(); + var token = new DirectiveTokenIntermediateNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "Foo", + DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.Member), + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +#nullable restore +#line 1 ""test.cshtml"" +global::System.Object Foo = null!; + +#line default +#line hidden +#nullable disable +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithStringToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DesignTimeDirectiveIntermediateNode(); + var token = new DirectiveTokenIntermediateNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "Value", + DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String), + }; + var tokenWithQuotedContent = new DirectiveTokenIntermediateNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "\"Value\"", + DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String), + }; + node.Children.Add(token); + node.Children.Add(tokenWithQuotedContent); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +#nullable restore +#line 1 ""test.cshtml"" +global::System.Object __typeHelper = ""Value""; + +#line default +#line hidden +#nullable disable +} +))(); +((System.Action)(() => { +#nullable restore +#line 1 ""test.cshtml"" +global::System.Object __typeHelper = ""Value""; + +#line default +#line hidden +#nullable disable +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_ChildrenWithNoSource_WritesEmptyMethod_WithPragma() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = TestCodeRenderingContext.CreateDesignTime(); + + var node = new DesignTimeDirectiveIntermediateNode(); + var token = new DirectiveTokenIntermediateNode() + { + Content = "Value", + DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String), + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/FunctionsDirectivePassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/FunctionsDirectivePassTest.cs new file mode 100644 index 0000000000..ff60131973 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/FunctionsDirectivePassTest.cs @@ -0,0 +1,182 @@ +// 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.Components; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class FunctionsDirectivePassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + + [Fact] + public void Execute_SkipsDocumentWithNoClassNode() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var pass = new FunctionsDirectivePass() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("@functions { var value = true; }"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + irDocument.Children.Add(new DirectiveIntermediateNode() { Directive = FunctionsDirective.Directive, }); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + } + + [Fact] + public void Execute_AddsStatementsToClassLevel() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var pass = new FunctionsDirectivePass() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("@functions { var value = true; }"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = Lower(codeDocument, projectEngine); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + + var @namespace = irDocument.Children[0]; + Children( + @namespace, + node => Assert.IsType(node)); + + var @class = @namespace.Children[0]; + Children( + @class, + node => Assert.IsType(node), + node => CSharpCode(" var value = true; ", node)); + + var method = @class.Children[0]; + Assert.Empty(method.Children); + } + + [Fact] + public void Execute_ComponentCodeDirective_AddsStatementsToClassLevel() + { + // Arrange + var projectEngine = CreateProjectEngine(b => b.AddDirective(ComponentCodeDirective.Directive)); + var pass = new FunctionsDirectivePass() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("@code { var value = true; }"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + codeDocument.SetFileKind(FileKinds.Component); + + var irDocument = Lower(codeDocument, projectEngine); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + + var @namespace = irDocument.Children[0]; + Children( + @namespace, + node => Assert.IsType(node)); + + var @class = @namespace.Children[0]; + Children( + @class, + node => Assert.IsType(node), + node => CSharpCode(" var value = true; ", node)); + + var method = @class.Children[0]; + Assert.Empty(method.Children); + } + + [Fact] + public void Execute_FunctionsAndComponentCodeDirective_AddsStatementsToClassLevel() + { + // Arrange + var projectEngine = CreateProjectEngine(b => b.AddDirective(ComponentCodeDirective.Directive)); + var pass = new FunctionsDirectivePass() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(@" +@functions { var value1 = true; } +@code { var value2 = true; } +@functions { var value3 = true; }"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + codeDocument.SetFileKind(FileKinds.Component); + + var irDocument = Lower(codeDocument, projectEngine); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + + var @namespace = irDocument.Children[0]; + Children( + @namespace, + node => Assert.IsType(node)); + + var @class = @namespace.Children[0]; + Children( + @class, + node => Assert.IsType(node), + node => CSharpCode(" var value1 = true; ", node), + node => CSharpCode(" var value2 = true; ", node), + node => CSharpCode(" var value3 = true; ", node)); + + var method = @class.Children[0]; + Children( + method, + node => Assert.IsType(node)); + } + + private static DocumentIntermediateNode Lower(RazorCodeDocument codeDocument, RazorProjectEngine projectEngine) + { + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorDocumentClassifierPhase) + { + break; + } + } + + var irDocument = codeDocument.GetDocumentIntermediateNode(); + Assert.NotNull(irDocument); + + return irDocument; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/InheritsDirectivePassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/InheritsDirectivePassTest.cs new file mode 100644 index 0000000000..e851990b80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/InheritsDirectivePassTest.cs @@ -0,0 +1,91 @@ +// 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.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class InheritsDirectivePassTest : RazorProjectEngineTestBase + { + protected override RazorLanguageVersion Version => RazorLanguageVersion.Latest; + + [Fact] + public void Execute_SkipsDocumentWithNoClassNode() + { + // Arrange + var engine = CreateEngine(); + var pass = new InheritsDirectivePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("@inherits Hello"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + irDocument.Children.Add(new DirectiveIntermediateNode() { Directive = FunctionsDirective.Directive, }); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + } + + [Fact] + public void Execute_Inherits_SetsClassDeclarationBaseType() + { + // Arrange + var engine = CreateEngine(); + var pass = new InheritsDirectivePass() + { + Engine = engine, + }; + + var content = "@inherits Hello"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = Lower(codeDocument, engine); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + + var @namespace = irDocument.Children[0]; + Children( + @namespace, + node => Assert.IsType(node)); + + var @class = (ClassDeclarationIntermediateNode)@namespace.Children[0]; + Assert.Equal("Hello", @class.BaseType); + } + + private static DocumentIntermediateNode Lower(RazorCodeDocument codeDocument, RazorEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorDocumentClassifierPhase) + { + break; + } + } + + var irDocument = codeDocument.GetDocumentIntermediateNode(); + Assert.NotNull(irDocument); + + return irDocument; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs new file mode 100644 index 0000000000..db50c00268 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributePassTest.cs @@ -0,0 +1,392 @@ +// 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.Components; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class MetadataAttributePassTest + { + [Fact] + public void Execute_NullCodeGenerationOptions_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_SuppressMetadataAttributes_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(o => + { + o.SuppressMetadataAttributes = true; + }), + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_ComponentDocumentKind_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = ComponentDocumentClassifierPass.ComponentDocumentKind, + Options = RazorCodeGenerationOptions.Create(o => + { + o.SuppressMetadataAttributes = true; + }), + }; + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + NoChildren(irDocument); + } + + [Fact] + public void Execute_NoNamespaceSet_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoClassNameSet_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoDocumentKind_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_NoIdentifier_Noops() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, null)); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + SingleChild(irDocument); + } + + [Fact] + public void Execute_HasRequiredInfo_AddsItemAndSourceChecksum() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, "Foo\\Bar.cshtml")); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal(2, irDocument.Children.Count); + + var item = Assert.IsType(irDocument.Children[0]); + Assert.Equal("/Foo/Bar.cshtml", item.Identifier); + Assert.Equal("test", item.Kind); + Assert.Equal("Some.Namespace.Test", item.TypeName); + + Assert.Equal(2, @namespace.Children.Count); + var checksum = Assert.IsType(@namespace.Children[0]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Bar.cshtml", checksum.Identifier); + } + + [Fact] + public void Execute_HasRequiredInfo_AndImport_AddsItemAndSourceChecksum() + { + // Arrange + var engine = CreateEngine(); + var pass = new MetadataAttributePass() + { + Engine = engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("", new RazorSourceDocumentProperties(null, "Foo\\Bar.cshtml")); + var import = TestRazorSourceDocument.Create("@using System", new RazorSourceDocumentProperties(null, "Foo\\Import.cshtml")); + var codeDocument = RazorCodeDocument.Create(sourceDocument, new[] { import, }); + + var irDocument = new DocumentIntermediateNode() + { + DocumentKind = "test", + Options = RazorCodeGenerationOptions.Create((o) => { }), + }; + var builder = IntermediateNodeBuilder.Create(irDocument); + var @namespace = new NamespaceDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace, + }, + Content = "Some.Namespace" + }; + builder.Push(@namespace); + var @class = new ClassDeclarationIntermediateNode + { + Annotations = + { + [CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass, + }, + ClassName = "Test", + }; + builder.Add(@class); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Assert.Equal(2, irDocument.Children.Count); + + var item = Assert.IsType(irDocument.Children[0]); + Assert.Equal("/Foo/Bar.cshtml", item.Identifier); + Assert.Equal("test", item.Kind); + Assert.Equal("Some.Namespace.Test", item.TypeName); + + Assert.Equal(3, @namespace.Children.Count); + var checksum = Assert.IsType(@namespace.Children[0]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Bar.cshtml", checksum.Identifier); + + checksum = Assert.IsType(@namespace.Children[1]); + Assert.NotNull(checksum.Checksum); // Not verifying the checksum here + Assert.Equal("SHA1", checksum.ChecksumAlgorithm); + Assert.Equal("/Foo/Import.cshtml", checksum.Identifier); + } + + private static RazorEngine CreateEngine() + { + return RazorProjectEngine.Create(b => + { + b.Features.Add(new DefaultMetadataIdentifierFeature()); + }).Engine; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributeTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributeTargetExtensionTest.cs new file mode 100644 index 0000000000..faeaf4d662 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/MetadataAttributeTargetExtensionTest.cs @@ -0,0 +1,123 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class MetadataAttributeTargetExtensionTest + { + [Fact] + public void WriteRazorCompiledItemAttribute_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + CompiledItemAttributeName = "global::TestItem", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorCompiledItemAttributeIntermediateNode() + { + TypeName = "Foo.Bar", + Kind = "test", + Identifier = "Foo/Bar", + }; + + // Act + extension.WriteRazorCompiledItemAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"[assembly: global::TestItem(typeof(Foo.Bar), @""test"", @""Foo/Bar"")] +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteRazorSourceChecksumAttribute_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + SourceChecksumAttributeName = "global::TestChecksum", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorSourceChecksumAttributeIntermediateNode() + { + ChecksumAlgorithm = "SHA1", + Checksum = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t', }, + Identifier = "Foo/Bar", + }; + + // Act + extension.WriteRazorSourceChecksumAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"[global::TestChecksum(@""SHA1"", @""74657374"", @""Foo/Bar"")] +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteRazorCompiledItemAttributeMetadata_RendersCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + CompiledItemMetadataAttributeName = "global::TestItemMetadata", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorCompiledItemMetadataAttributeIntermediateNode + { + Key = "key", + Value = "value", + }; + + // Act + extension.WriteRazorCompiledItemMetadataAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode().Trim(); + Assert.Equal( +"[global::TestItemMetadata(\"key\", \"value\")]", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteRazorCompiledItemAttributeMetadata_EscapesKeysAndValuesCorrectly() + { + // Arrange + var extension = new MetadataAttributeTargetExtension() + { + CompiledItemMetadataAttributeName = "global::TestItemMetadata", + }; + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new RazorCompiledItemMetadataAttributeIntermediateNode + { + Key = "\"test\" key", + Value = @"""test"" value", + }; + + // Act + extension.WriteRazorCompiledItemMetadataAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode().Trim(); + Assert.Equal( +"[global::TestItemMetadata(\"\\\"test\\\" key\", \"\\\"test\\\" value\")]", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/PreallocatedAttributeTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/PreallocatedAttributeTargetExtensionTest.cs new file mode 100644 index 0000000000..da2f960847 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/PreallocatedAttributeTargetExtensionTest.cs @@ -0,0 +1,276 @@ +// 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 PreallocatedAttributeTargetExtensionTest + { + [Fact] + public void WriteTagHelperHtmlAttributeValue_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new PreallocatedTagHelperHtmlAttributeValueIntermediateNode() + { + AttributeName = "Foo", + Value = "Bar", + AttributeStructure = AttributeStructure.DoubleQuotes, + VariableName = "MyProp" + }; + + // Act + extension.WriteTagHelperHtmlAttributeValue(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute MyProp = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(""Foo"", new global::Microsoft.AspNetCore.Html.HtmlString(""Bar""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperHtmlAttributeValue_Minimized_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new PreallocatedTagHelperHtmlAttributeValueIntermediateNode() + { + AttributeName = "Foo", + Value = "Bar", + AttributeStructure = AttributeStructure.Minimized, + VariableName = "_tagHelper1" + }; + + // Act + extension.WriteTagHelperHtmlAttributeValue(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute _tagHelper1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(""Foo""); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperHtmlAttribute_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new PreallocatedTagHelperHtmlAttributeIntermediateNode() + { + VariableName = "_tagHelper1" + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__tagHelperExecutionContext.AddHtmlAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperPropertyValue_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var node = new PreallocatedTagHelperPropertyValueIntermediateNode() + { + AttributeName = "Foo", + Value = "Bar", + AttributeStructure = AttributeStructure.DoubleQuotes, + VariableName = "_tagHelper1", + }; + + // Act + extension.WriteTagHelperPropertyValue(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute _tagHelper1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(""Foo"", ""Bar"", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteTagHelperProperty_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "FooTagHelper", "Test"); + tagHelperBuilder.TypeName("FooTagHelper"); + + var builder = new DefaultBoundAttributeDescriptorBuilder(tagHelperBuilder, TagHelperConventions.DefaultKind); + builder + .Name("Foo") + .TypeName("System.String") + .PropertyName("FooProp"); + + var descriptor = builder.Build(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new PreallocatedTagHelperPropertyIntermediateNode() + { + AttributeName = descriptor.Name, + BoundAttribute = descriptor, + FieldName = "__FooTagHelper", + PropertyName = "FooProp", + VariableName = "_tagHelper1", + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__FooTagHelper.FooProp = (string)_tagHelper1.Value; +__tagHelperExecutionContext.AddTagHelperAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetPreallocatedTagHelperProperty_IndexerAttribute_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "FooTagHelper", "Test"); + tagHelperBuilder.TypeName("FooTagHelper"); + + var builder = new DefaultBoundAttributeDescriptorBuilder(tagHelperBuilder, TagHelperConventions.DefaultKind); + builder + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionaryAttribute("pre-", "System.String") + .PropertyName("FooProp"); + + var descriptor = builder.Build(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node = new PreallocatedTagHelperPropertyIntermediateNode() + { + AttributeName = "pre-Foo", + FieldName = "__FooTagHelper", + VariableName = "_tagHelper1", + BoundAttribute = descriptor, + IsIndexerNameMatch = true, + PropertyName = "FooProp", + TagHelper = tagHelperBuilder.Build(), + }; + tagHelperNode.Children.Add(node); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"if (__FooTagHelper.FooProp == null) +{ + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment(""pre-Foo"", ""FooTagHelper"", ""FooProp"")); +} +__FooTagHelper.FooProp[""Foo""] = (string)_tagHelper1.Value; +__tagHelperExecutionContext.AddTagHelperAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetPreallocatedTagHelperProperty_IndexerAttribute_MultipleValues() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = TestCodeRenderingContext.CreateRuntime(); + + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "FooTagHelper", "Test"); + tagHelperBuilder.TypeName("FooTagHelper"); + + var builder = new DefaultBoundAttributeDescriptorBuilder(tagHelperBuilder, TagHelperConventions.DefaultKind); + builder + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionaryAttribute("pre-", "System.String") + .PropertyName("FooProp"); + + var boundAttribute = builder.Build(); + var tagHelper = tagHelperBuilder.Build(); + + var tagHelperNode = new TagHelperIntermediateNode(); + var node1 = new PreallocatedTagHelperPropertyIntermediateNode() + { + AttributeName = "pre-Bar", + FieldName = "__FooTagHelper", + VariableName = "_tagHelper0s", + BoundAttribute = boundAttribute, + IsIndexerNameMatch = true, + PropertyName = "FooProp", + TagHelper = tagHelper, + }; + var node2 = new PreallocatedTagHelperPropertyIntermediateNode() + { + AttributeName = "pre-Foo", + FieldName = "__FooTagHelper", + VariableName = "_tagHelper1", + BoundAttribute = boundAttribute, + IsIndexerNameMatch = true, + PropertyName = "FooProp", + TagHelper = tagHelper, + }; + tagHelperNode.Children.Add(node1); + tagHelperNode.Children.Add(node2); + Push(context, tagHelperNode); + + // Act + extension.WriteTagHelperProperty(context, node2); + + // Assert + var csharp = context.CodeWriter.GenerateCode(); + Assert.Equal( +@"__FooTagHelper.FooProp[""Foo""] = (string)_tagHelper1.Value; +__tagHelperExecutionContext.AddTagHelperAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + + private static void Push(CodeRenderingContext context, TagHelperIntermediateNode node) + { + ((DefaultCodeRenderingContext)context).AncestorsInternal.Push(node); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs new file mode 100644 index 0000000000..a2f747e7a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionDirectivePassTest.cs @@ -0,0 +1,106 @@ +// 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.Intermediate; +using Xunit; +using static Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeAssert; + +namespace Microsoft.AspNetCore.Razor.Language.Extensions +{ + public class SectionDirectivePassTest + { + [Fact] + public void Execute_SkipsDocumentWithNoClassNode() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var pass = new SectionDirectivePass() + { + Engine = projectEngine.Engine, + }; + + var sourceDocument = TestRazorSourceDocument.Create("@section Header {

Hello World

}"); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = new DocumentIntermediateNode(); + irDocument.Children.Add(new DirectiveIntermediateNode() { Directive = SectionDirective.Directive, }); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + } + + [Fact] + public void Execute_WrapsStatementInSectionNode() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var pass = new SectionDirectivePass() + { + Engine = projectEngine.Engine, + }; + + var content = "@section Header {

Hello World

}"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + var irDocument = Lower(codeDocument, projectEngine); + + // Act + pass.Execute(codeDocument, irDocument); + + // Assert + Children( + irDocument, + node => Assert.IsType(node)); + + var @namespace = irDocument.Children[0]; + Children( + @namespace, + node => Assert.IsType(node)); + + var @class = @namespace.Children[0]; + var method = SingleChild(@class); + + Children( + method, + node => Assert.IsType(node), + node => Assert.IsType(node)); + + var section = method.Children[1] as SectionIntermediateNode; + Assert.Equal("Header", section.SectionName); + Children(section, c => Html("

Hello World

", c)); + } + + private static RazorProjectEngine CreateProjectEngine() + { + return RazorProjectEngine.Create(b => + { + SectionDirective.Register(b); + }); + } + + private static DocumentIntermediateNode Lower(RazorCodeDocument codeDocument, RazorProjectEngine projectEngine) + { + for (var i = 0; i < projectEngine.Phases.Count; i++) + { + var phase = projectEngine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorDocumentClassifierPhase) + { + break; + } + } + + var irDocument = codeDocument.GetDocumentIntermediateNode(); + Assert.NotNull(irDocument); + + return irDocument; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionTargetExtensionTest.cs new file mode 100644 index 0000000000..16288b3117 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/SectionTargetExtensionTest.cs @@ -0,0 +1,80 @@ +// 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 SectionTargetExtensionTest + { + [Fact] + public void WriteSection_WritesSectionCode() + { + // Arrange + var node = new SectionIntermediateNode() + { + Children = + { + new CSharpExpressionIntermediateNode(), + }, + SectionName = "MySection" + }; + + var extension = new SectionTargetExtension() + { + SectionMethodName = "CreateSection" + }; + + var context = TestCodeRenderingContext.CreateRuntime(); + + // Act + extension.WriteSection(context, node); + + // Assert + var expected = @"CreateSection(""MySection"", async() => { + Render Children +} +); +"; + + var output = context.CodeWriter.GenerateCode(); + Assert.Equal(expected, output); + } + + [Fact] + public void WriteSection_WritesSectionCode_DesignTime() + { + // Arrange + var node = new SectionIntermediateNode() + { + Children = + { + new CSharpExpressionIntermediateNode(), + }, + SectionName = "MySection" + }; + + var extension = new SectionTargetExtension() + { + 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); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/TemplateTargetExtensionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/TemplateTargetExtensionTest.cs new file mode 100644 index 0000000000..b24d6f5174 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/TemplateTargetExtensionTest.cs @@ -0,0 +1,51 @@ +// 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 TemplateTargetExtensionTest + { + [Fact] + public void WriteTemplate_WritesTemplateCode() + { + // Arrange + var node = new TemplateIntermediateNode() + { + Children = + { + new CSharpExpressionIntermediateNode() + } + }; + var extension = new TemplateTargetExtension() + { + TemplateTypeName = "global::TestTemplate" + }; + + var nodeWriter = new RuntimeNodeWriter() + { + PushWriterMethod = "TestPushWriter", + PopWriterMethod = "TestPopWriter" + }; + + var context = TestCodeRenderingContext.CreateRuntime(nodeWriter: nodeWriter); + + // Act + extension.WriteTemplate(context, node); + + // Assert + var expected = @"item => new global::TestTemplate(async(__razor_template_writer) => { + TestPushWriter(__razor_template_writer); + Render Children + TestPopWriter(); +} +)"; + + var output = context.CodeWriter.GenerateCode(); + Assert.Equal(expected, output); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/HtmlConventionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/HtmlConventionsTest.cs new file mode 100644 index 0000000000..e1020bb81c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/HtmlConventionsTest.cs @@ -0,0 +1,39 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class HtmlConventionsTest + { + public static TheoryData HtmlConversionData + { + get + { + return new TheoryData + { + { "SomeThing", "some-thing" }, + { "someOtherThing", "some-other-thing" }, + { "capsONInside", "caps-on-inside" }, + { "CAPSOnOUTSIDE", "caps-on-outside" }, + { "ALLCAPS", "allcaps" }, + { "One1Two2Three3", "one1-two2-three3" }, + { "ONE1TWO2THREE3", "one1two2three3" }, + { "First_Second_ThirdHi", "first_second_third-hi" } + }; + } + } + + [Theory] + [MemberData(nameof(HtmlConversionData))] + public void ToHtmlCase_ReturnsExpectedConversions(string input, string expectedOutput) + { + // Arrange, Act + var output = HtmlConventions.ToHtmlCase(input); + + // Assert + Assert.Equal(output, expectedOutput); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/HtmlNodeOptimizationPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/HtmlNodeOptimizationPassTest.cs new file mode 100644 index 0000000000..bf08903e5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/HtmlNodeOptimizationPassTest.cs @@ -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; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class HtmlNodeOptimizationPassTest + { + [Fact] + public void Execute_RewritesWhitespace() + { + // Assert + var content = Environment.NewLine + " @true"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var originalTree = RazorSyntaxTree.Parse(sourceDocument); + var pass = new HtmlNodeOptimizationPass(); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + + // Act + var outputTree = pass.Execute(codeDocument, originalTree); + + // Assert + var document = Assert.IsType(outputTree.Root); + var block = Assert.IsType(document.Document); + Assert.Equal(4, block.Children.Count); + var whitespace = Assert.IsType(block.Children[1]); + Assert.True(whitespace.GetContent().All(char.IsWhiteSpace)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/BasicIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/BasicIntegrationTest.cs new file mode 100644 index 0000000000..9ae793d5a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/BasicIntegrationTest.cs @@ -0,0 +1,57 @@ +// 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.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class BasicIntegrationTest : IntegrationTestBase + { + [Fact] + public void Empty() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + } + + [Fact] + public void HelloWorld() + { + // Arrange + var projectEngine = CreateProjectEngine(); + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + } + + [Fact] + public void CustomDirective() + { + // Arrange + var projectEngine = CreateProjectEngine(b => + { + b.AddDirective(DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine)); + }); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs new file mode 100644 index 0000000000..175c69abf6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -0,0 +1,1092 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class CodeGenerationIntegrationTest : IntegrationTestBase + { + public CodeGenerationIntegrationTest() + : base(generateBaselines: null) + { + } + + #region Runtime + [Fact] + public void SingleLineControlFlowStatements_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void CSharp8_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void IncompleteDirectives_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void CSharp7_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void UnfinishedExpressionInCode_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Templates_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Markup_InCodeBlocks_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Markup_InCodeBlocksWithTagHelper_Runtime() + { + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void StringLiterals_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void SimpleUnspacedIf_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Sections_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void RazorComments_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ParserError_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void OpenedIf_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void NullConditionalExpressions_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void NoLinePragmas_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void NestedCSharp_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void NestedCodeBlocks_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void MarkupInCodeBlock_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Instrumented_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void InlineBlocks_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Inherits_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Usings_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ImplicitExpressionAtEOF_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ImplicitExpression_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void HtmlCommentWithQuote_Double_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void HtmlCommentWithQuote_Single_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void HiddenSpansInCode_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void FunctionsBlock_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void FunctionsBlockMinimal_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ExpressionsInCode_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ExplicitExpressionWithMarkup_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ExplicitExpressionAtEOF_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ExplicitExpression_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void EmptyImplicitExpressionInCode_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void EmptyImplicitExpression_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void EmptyExplicitExpression_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void EmptyCodeBlock_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void ConditionalAttributes_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void CodeBlockWithTextElement_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void CodeBlockAtEOF_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void CodeBlock_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Blocks_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Await_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void Tags_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void SimpleTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithBoundAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithPrefix_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void NestedTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void SingleTagHelper_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void SingleTagHelperWithNewlineBeforeAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithWeirdlySpacedAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void IncompleteTagHelper_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void BasicTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void BasicTagHelpers_Prefixed_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void BasicTagHelpers_RemoveTagHelper_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void CssSelectorTagHelperAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.CssSelectorTagHelperDescriptors); + } + + [Fact] + public void ComplexTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void EmptyAttributeTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void EscapedTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void DuplicateTargetTagHelper_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DuplicateTargetTagHelperDescriptors); + } + + [Fact] + public void AttributeTargetingTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.AttributeTargetingTagHelperDescriptors); + } + + [Fact] + public void PrefixedAttributeTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.PrefixedAttributeTagHelperDescriptors); + } + + [Fact] + public void DuplicateAttributeTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void DynamicAttributeTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DynamicAttributeTagHelpers_Descriptors); + } + + [Fact] + public void TransitionsInTagHelperAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void MinimizedTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.MinimizedTagHelpers_Descriptors); + } + + [Fact] + public void NestedScriptTagTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void SymbolBoundAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SymbolBoundTagHelperDescriptors); + } + + [Fact] + public void EnumTagHelpers_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.EnumTagHelperDescriptors); + } + + [Fact] + public void TagHelpersInSection_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.TagHelpersInSectionDescriptors); + } + + [Fact] + public void TagHelpersWithTemplate_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithDataDashAttributes_Runtime() + { + // Arrange, Act & Assert + RunRuntimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void Implements_Runtime() + { + RunTimeTest(); + } + + [Fact] + public void AttributeDirective_Runtime() + { + RunTimeTest(); + } + + #endregion + + #region DesignTime + [Fact] + public void SingleLineControlFlowStatements_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void CSharp8_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void IncompleteDirectives_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void CSharp7_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void UnfinishedExpressionInCode_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Templates_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Markup_InCodeBlocks_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Markup_InCodeBlocksWithTagHelper_DesignTime() + { + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void StringLiterals_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void SimpleUnspacedIf_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Sections_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void RazorComments_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ParserError_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void OpenedIf_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void NullConditionalExpressions_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void NoLinePragmas_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void NestedCSharp_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void NestedCodeBlocks_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void MarkupInCodeBlock_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Instrumented_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void InlineBlocks_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Inherits_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Usings_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ImplicitExpressionAtEOF_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ImplicitExpression_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void HtmlCommentWithQuote_Double_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void HtmlCommentWithQuote_Single_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void HiddenSpansInCode_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void FunctionsBlock_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void FunctionsBlockMinimal_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ExpressionsInCode_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ExplicitExpressionWithMarkup_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ExplicitExpressionAtEOF_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ExplicitExpression_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void EmptyImplicitExpressionInCode_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void EmptyImplicitExpression_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void EmptyExplicitExpression_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void EmptyCodeBlock_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void DesignTime_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void ConditionalAttributes_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void CodeBlockWithTextElement_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void CodeBlockAtEOF_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void CodeBlock_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Blocks_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Await_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void Tags_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void AddTagHelperDirective_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void RemoveTagHelperDirective_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void SimpleTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithBoundAttributes_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithPrefix_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void NestedTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void SingleTagHelper_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void SingleTagHelperWithNewlineBeforeAttributes_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithWeirdlySpacedAttributes_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void IncompleteTagHelper_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void BasicTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void BasicTagHelpers_Prefixed_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void ComplexTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void EmptyAttributeTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void EscapedTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void DuplicateTargetTagHelper_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DuplicateTargetTagHelperDescriptors); + } + + [Fact] + public void AttributeTargetingTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.AttributeTargetingTagHelperDescriptors); + } + + [Fact] + public void PrefixedAttributeTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.PrefixedAttributeTagHelperDescriptors); + } + + [Fact] + public void DuplicateAttributeTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void DynamicAttributeTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DynamicAttributeTagHelpers_Descriptors); + } + + [Fact] + public void TransitionsInTagHelperAttributes_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void MinimizedTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.MinimizedTagHelpers_Descriptors); + } + + [Fact] + public void NestedScriptTagTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.DefaultPAndInputTagHelperDescriptors); + } + + [Fact] + public void SymbolBoundAttributes_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SymbolBoundTagHelperDescriptors); + } + + [Fact] + public void EnumTagHelpers_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.EnumTagHelperDescriptors); + } + + [Fact] + public void TagHelpersInSection_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.TagHelpersInSectionDescriptors); + } + + [Fact] + public void TagHelpersWithTemplate_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void TagHelpersWithDataDashAttributes_DesignTime() + { + // Arrange, Act & Assert + RunDesignTimeTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors); + } + + [Fact] + public void Implements_DesignTime() + { + DesignTimeTest(); + } + + [Fact] + public void AttributeDirective_DesignTime() + { + DesignTimeTest(); + } + + #endregion + + private void DesignTimeTest() + { + // Arrange + var projectEngine = CreateProjectEngine(builder => + { + builder.ConfigureDocumentClassifier(); + + // Some of these tests use templates + builder.AddTargetExtension(new TemplateTargetExtension()); + + SectionDirective.Register(builder); + }); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertHtmlDocumentMatchesBaseline(codeDocument.GetHtmlDocument()); + AssertCSharpDocumentMatchesBaseline(codeDocument.GetCSharpDocument()); + AssertSourceMappingsMatchBaseline(codeDocument); + AssertLinePragmas(codeDocument, designTime: true); + } + + private void RunTimeTest() + { + // Arrange + var projectEngine = CreateProjectEngine(builder => + { + builder.ConfigureDocumentClassifier(); + + // Some of these tests use templates + builder.AddTargetExtension(new TemplateTargetExtension()); + + SectionDirective.Register(builder); + }); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(codeDocument.GetCSharpDocument()); + AssertLinePragmas(codeDocument, designTime: false); + } + + private void RunRuntimeTagHelpersTest(IEnumerable descriptors) + { + // Arrange + var projectEngine = CreateProjectEngine(builder => + { + builder.ConfigureDocumentClassifier(); + + // Some of these tests use templates + builder.AddTargetExtension(new TemplateTargetExtension()); + + SectionDirective.Register(builder); + }); + + var projectItem = CreateProjectItemFromFile(); + var imports = GetImports(projectEngine, projectItem); + + // Act + var codeDocument = projectEngine.Process(RazorSourceDocument.ReadFrom(projectItem), FileKinds.Legacy, imports, descriptors.ToList()); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(codeDocument.GetCSharpDocument()); + } + + private void RunDesignTimeTagHelpersTest(IEnumerable descriptors) + { + // Arrange + var projectEngine = CreateProjectEngine(builder => + { + builder.ConfigureDocumentClassifier(); + + // Some of these tests use templates + builder.AddTargetExtension(new TemplateTargetExtension()); + + SectionDirective.Register(builder); + }); + + var projectItem = CreateProjectItemFromFile(); + var imports = GetImports(projectEngine, projectItem); + + // Act + var codeDocument = projectEngine.ProcessDesignTime(RazorSourceDocument.ReadFrom(projectItem), FileKinds.Legacy, imports, descriptors.ToList()); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(codeDocument.GetCSharpDocument()); + AssertSourceMappingsMatchBaseline(codeDocument); + } + + private static IReadOnlyList GetImports(RazorProjectEngine projectEngine, RazorProjectItem projectItem) + { + var importFeatures = projectEngine.ProjectFeatures.OfType(); + var importItems = importFeatures.SelectMany(f => f.GetImports(projectItem)); + var importSourceDocuments = importItems.Where(i => i.Exists).Select(i => RazorSourceDocument.ReadFrom(i)).ToList(); + + return importSourceDocuments; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentBindIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentBindIntegrationTest.cs new file mode 100644 index 0000000000..77bd6c9ed3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentBindIntegrationTest.cs @@ -0,0 +1,99 @@ +// 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.Components; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentBindIntegrationTest : RazorIntegrationTestBase + { + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + [Fact] + public void BindDuplicates_ReportsDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue2"", ""myevent2"")] + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var result = CompileToCSharp(@" +
+@functions { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + var diagnostic = Assert.Single(result.Diagnostics); + Assert.Equal("RZ9989", diagnostic.Id); + Assert.Equal( + "The attribute '@bind-value' was matched by multiple bind attributes. Duplicates:" + Environment.NewLine + + "Test.BindAttributes" + Environment.NewLine + + "Test.BindAttributes", + diagnostic.GetMessage()); + } + + [Fact] + public void BindFallback_InvalidSyntax_TooManyParts() + { + // Arrange & Act + var generated = CompileToCSharp(@" + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9991", diagnostic.Id); + } + + [Fact] + public void BindFallback_InvalidSyntax_TrailingDash() + { + // Arrange & Act + var generated = CompileToCSharp(@" + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9991", diagnostic.Id); + } + + [Fact] + public void Bind_InvalidUseOfDirective_DoesNotThrow() + { + // We're looking for VS crash issues. Meaning if the parser returns + // diagnostics we don't want to throw. + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@functions { + public string page { get; set; } = ""text""; +}", throwOnFailure: false); + + // Assert + Assert.Collection( + generated.Diagnostics, + d => Assert.Equal("RZ2005", d.Id), + d => Assert.Equal("RZ1011", d.Id)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs new file mode 100644 index 0000000000..624de396b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs @@ -0,0 +1,272 @@ +// 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.Components; +using Microsoft.AspNetCore.Razor.Language.Components; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentChildContentIntegrationTest : RazorIntegrationTestBase + { + private readonly CSharpSyntaxTree RenderChildContentComponent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +namespace Test +{ + public class RenderChildContent : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, ChildContent); + } + + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +"); + + private readonly CSharpSyntaxTree RenderChildContentStringComponent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +namespace Test +{ + public class RenderChildContentString : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, ChildContent, Value); + } + + [Parameter] + public RenderFragment ChildContent { get; set; } + + [Parameter] + public string Value { get; set; } + } +} +"); + + private readonly CSharpSyntaxTree RenderMultipleChildContent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering +namespace Test +{ + public class RenderMultipleChildContent : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, Header, Name); + builder.AddContent(1, ChildContent, Value); + builder.AddContent(2, Footer); + } + + [Parameter] + public string Name { get; set; } + + [Parameter] + public RenderFragment Header { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + + [Parameter] + public RenderFragment Footer { get; set; } + + [Parameter] + public string Value { get; set; } + } +} +"); + + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + [Fact] + public void ChildContent_AttributeAndBody_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment template = @
@context.ToLowerInvariant()
; } + +Some Content +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentSetByAttributeAndBody.Id, diagnostic.Id); + } + + [Fact] + public void ChildContent_AttributeAndExplicitChildContent_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment template = @
@context.ToLowerInvariant()
; } + + +Some Content + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentSetByAttributeAndBody.Id, diagnostic.Id); + } + + [Fact] + public void ChildContent_ExplicitChildContent_UnrecogizedContent_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" + + + +@somethingElse +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentMixedWithExplicitChildContent.Id, diagnostic.Id); + Assert.Equal( + "Unrecognized child content inside component 'RenderChildContent'. The component 'RenderChildContent' accepts " + + "child content through the following top-level items: 'ChildContent'.", + diagnostic.GetMessage()); + } + + [Fact] + public void ChildContent_ExplicitChildContent_UnrecogizedElement_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" + + + + +"); + + // Assert + Assert.Collection( + generated.Diagnostics, + d => Assert.Equal("RZ10012", d.Id), + d => Assert.Equal("RZ9996", d.Id)); + } + + [Fact] + public void ChildContent_ExplicitChildContent_UnrecogizedAttribute_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidAttribute.Id, diagnostic.Id); + } + + [Fact] + public void ChildContent_ExplicitChildContent_InvalidParameterName_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidParameter.Id, diagnostic.Id); + } + + [Fact] + public void ChildContent_ExplicitChildContent_RepeatedParameterName_GeneratesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" + + + + + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentRepeatedParameterName.Id, diagnostic.Id); + Assert.Equal( + "The child content element 'ChildContent' of component 'RenderChildContentString' uses the same parameter name ('context') as enclosing child content " + + "element 'ChildContent' of component 'RenderChildContentString'. Specify the parameter name like: ' to resolve the ambiguity", + diagnostic.GetMessage()); + } + + [Fact] + public void ChildContent_ContextParameterNameOnComponent_Invalid_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidParameterOnComponent.Id, diagnostic.Id); + Assert.Equal( + "Invalid parameter name. The parameter name attribute 'Context' on component 'RenderChildContentString' can only include literal text.", + diagnostic.GetMessage()); + } + + [Fact] + public void ChildContent_ExplicitChildContent_ContainsDirectiveAttribute_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidAttribute.Id, diagnostic.Id); + Assert.Equal( + "Unrecognized attribute '@key' on child content element 'ChildContent'.", + diagnostic.GetMessage()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs new file mode 100644 index 0000000000..b9fb0e4020 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -0,0 +1,5406 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public abstract class ComponentCodeGenerationTestBase : RazorBaselineIntegrationTestBase + { + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + protected ComponentCodeGenerationTestBase() + : base(generateBaselines: null) + { + } + + #region Basics + + [Fact] + public void SingleLineControlFlowStatements_InCodeDirective() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Rendering; + +@code { + void RenderChildComponent(RenderTreeBuilder __builder) + { + var output = string.Empty; + if (__builder == null) output = ""Builder is null!""; + else output = ""Builder is not null!""; +

Output: @output

+ } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void SingleLineControlFlowStatements_InCodeBlock() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.RenderTree; + +@{ + var output = string.Empty; + if (__builder == null) output = ""Builder is null!""; + else output = ""Builder is not null!""; +

Output: @output

+}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] + public void ChildComponent_InFunctionsDirective() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Rendering; + +@{ RenderChildComponent(__builder); } + +@code { + void RenderChildComponent(RenderTreeBuilder __builder) + { + + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_InLocalFunction() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.RenderTree; +@{ + void RenderChildComponent() + { + + } +} + +@{ RenderChildComponent(); } +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_Simple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithParameters() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeType + { + } + + public class MyComponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + [Parameter] public bool BoolProperty { get; set; } + [Parameter] public string StringProperty { get; set; } + [Parameter] public SomeType ObjectProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ComponentWithTypeParameters() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components; +@typeparam TItem1 +@typeparam TItem2 + +

Item1

+@foreach (var item2 in Items2) +{ +

+ @ChildContent(item2); +

+} +@code { + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithExplicitStringParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string StringProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithNonPropertyAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ComponentParameter_TypeMismatch_ReportsDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class CoolnessMeter : ComponentBase + { + [Parameter] public int Coolness { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS1503", d.Id)); + } + + [Fact] + public void DataDashAttribute_ImplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@{ + var myValue = ""Expression value""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void DataDashAttribute_ExplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@{ + var myValue = ""Expression value""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void MarkupComment_IsNotIncluded() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@{ + var myValue = ""Expression value""; +} +
@myValue
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithFullyQualifiedTagNames() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} + +namespace Test2 +{ + public class MyComponent2 : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Bind + + [Fact] + public void BindToComponent_SpecifiesValue_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithStringAttribute_DoesNotUseStringSyntax() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class InputText : ComponentBase + { + [Parameter] + public string Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + AdditionalSyntaxTrees.Add(Parse(@" +using System; + +namespace Test +{ + public class Person + { + public string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@functions +{ + Person person = new Person(); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_TypeChecked_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public string ParentValue { get; set; } = ""42""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS0029", d.Id), + d => Assert.Equal("CS1503", d.Id)); + } + + [Fact] + public void BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_EventCallback_TypeChecked_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public string ParentValue { get; set; } = ""42""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS1503", d.Id), + d => Assert.Equal("CS1503", d.Id)); + } + + [Fact] + public void BindToComponent_SpecifiesValue_WithoutMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action OnChanged { get; set; } + } +}")); + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +}")); + + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_SpecifiesValueAndExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + + [Parameter] + public Expression> ValueExpression { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_EventCallback_SpecifiesValueAndExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + + [Parameter] + public Expression> ValueExpression { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_SpecifiesValueAndExpression_TypeChecked() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + + [Parameter] + public Expression> ValueExpression { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS0029", d.Id), + d => Assert.Equal("CS1662", d.Id)); + } + + [Fact] + public void BindToComponent_SpecifiesValueAndExpression_Generic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public T SomeParam { get; set; } + + [Parameter] + public Action SomeParamChanged { get; set; } + + [Parameter] + public Expression> SomeParamExpression { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime ParentValue { get; set; } = DateTime.Now; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public T SomeParam { get; set; } + + [Parameter] + public EventCallback SomeParamChanged { get; set; } + + [Parameter] + public Expression> SomeParamExpression { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime ParentValue { get; set; } = DateTime.Now; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElement_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElement_WithoutCloseTag() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" +
+ +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElement_WithStringAttribute_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElementWithSuffix_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElementWithSuffix_OverridesEvent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElement_WithEventAsExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +@{ var x = ""anotherevent""; } +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElement_WithEventAsExplicitExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +@{ var x = ""anotherevent""; } +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithoutType_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithoutType_IsCaseSensitive() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputText_WithFormat_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = ""MM/dd/yyyy""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputText_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputCheckbox_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public bool Enabled { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElementFallback_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElementFallback_WithFormat_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElementFallback_WithCulture() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Globalization +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToElementWithCulture() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +@using System.Globalization +
+@code { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToInputElementWithDefaultCulture() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: true, format: null)] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +@using System.Globalization + +@code { + public int ParentValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToInputElementWithDefaultCulture_Override() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: true, format: null)] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +@using System.Globalization + +@code { + public int ParentValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + + [Fact] + public void BuiltIn_BindToInputText_CanOverrideEvent() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithSuffix() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithSuffix_CanOverrideEvent() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithDefaultFormat() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: false, format: ""MM/dd"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithDefaultFormat_Override() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: false, format: ""MM/dd"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: true, format: ""MM/dd"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Child Content + + [Fact] + public void ChildComponent_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string MyAttr { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +Some textNested text"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithGenericChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string MyAttr { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +Some text@context.ToLowerInvariant()"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + + [Fact] + public void ChildComponent_WithGenericChildContent_SetsParameterName() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string MyAttr { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + + Some text@item.ToLowerInvariant() + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string MyAttr { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + + Some text@item.ToLowerInvariant() + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithElementOnlyChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +hello"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithExplicitChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +hello"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithExplicitGenericChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@context"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void MultipleExplictChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment Header { get; set; } + + [Parameter] + public RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +
Hi!
+
@(""bye!"")
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BodyAndAttributeChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment Header { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + + [Parameter] + public RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment header = (context) => @
@context.ToLowerInvariant()
; } + + Some Content +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BodyAndExplicitChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment Header { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + + [Parameter] + public RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment header = (context) => @
@context.ToLowerInvariant()
; } + + Some Content +
Bye!
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void MultipleChildContentMatchingComponentName() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment Header { get; set; } + + [Parameter] + public RenderFragment Footer { get; set; } + } + + public class Header : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +
Hi!
+
Bye!
+
+
Hello!
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Directives + + [Fact] + public void ChildComponent_WithPageDirective() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@page ""/MyPage"" +@page ""/AnotherRoute/{id}"" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithUsingDirectives() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} + +namespace Test2 +{ + public class MyComponent2 : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@page ""/MyPage"" +@page ""/AnotherRoute/{id}"" +@using Test2 + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithUsingDirectives_AmbiguousImport() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} + +namespace Test2 +{ + public class SomeComponent : ComponentBase + { + } +} + +namespace Test3 +{ + public class SomeComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test2 +@using Test3 + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + var result = CompileToAssembly(generated, throwOnFailure: false); + + if (DesignTime) + { + Assert.Collection(result.Diagnostics, d => + { + Assert.Equal("CS0104", d.Id); + Assert.Equal(CodeAnalysis.DiagnosticSeverity.Error, d.Severity); + Assert.Equal("'SomeComponent' is an ambiguous reference between 'Test2.SomeComponent' and 'Test3.SomeComponent'", d.GetMessage()); + }); + } + } + + [Fact] + public void Component_IgnoresStaticAndAliasUsings() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} + +namespace Test2 +{ + public class SomeComponent : ComponentBase + { + } +} + +namespace Test3 +{ + public class SomeComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using static Test2.SomeComponent +@using Foo = Test3 + + ", throwOnFailure: false); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, throwOnFailure: false); + } + + [Fact] + public void ChildContent_FromAnotherNamespace() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class HeaderComponent : ComponentBase + { + [Parameter] + public RenderFragment Header { get; set; } + } +} + +namespace AnotherTest +{ + public class FooterComponent : ComponentBase + { + [Parameter] + public RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using AnotherTest + + +
Hi!
+
+ +
@context
+
+ +
Hi!
+
+ +
@context
+
+"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithNamespaceDirective() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class HeaderComponent : ComponentBase + { + [Parameter] + public string Header { get; set; } + } +} + +namespace AnotherTest +{ + public class FooterComponent : ComponentBase + { + [Parameter] + public string Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test +@namespace AnotherTest + + + + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region EventCallback + + [Fact] + public void EventCallback_CanPassEventCallback_Explicitly() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallbackOfT_Explicitly() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +(this, Increment))""/> + +@code { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallback_Implicitly_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallback_Implicitly_ActionOfObject() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private void Increment(object e) { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallback_Implicitly_FuncOfTask() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private Task Increment() { + counter++; + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallback_Implicitly_FuncOfobjectTask() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private Task Increment(object e) { + counter++; + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallbackOfT_Implicitly_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallbackOfT_Implicitly_ActionOfT() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + + +@code { + private int counter; + private void Increment(MouseEventArgs e) { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallbackOfT_Implicitly_FuncOfTask() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private Task Increment() { + counter++; + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallbackOfT_Implicitly_FuncOfTTask() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + + +@code { + private int counter; + private Task Increment(MouseEventArgs e) { + counter++; + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventCallback_CanPassEventCallbackOfT_Implicitly_TypeMismatch() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + + +@code { + private int counter; + private void Increment(ChangeEventArgs e) { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var result = CompileToAssembly(generated, throwOnFailure: false); + + // Cannot convert from method group to Action - this isn't a great error message, but it's + // what the compiler gives us. + Assert.Collection(result.Diagnostics, d => { Assert.Equal("CS1503", d.Id); }); + } + + #endregion + + #region Event Handlers + + [Fact] + public void Component_WithImplicitLambdaEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" + Increment()""/> + +@code { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithLambdaEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public Action OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + { Increment(); })""/> + +@code { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + // Regression test for #954 - we need to allow arbitrary event handler + // attributes with weak typing. + [Fact] + public void ChildComponent_WithWeaklyTypeEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class DynamicElement : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + + +@code { + private Action OnClick { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_WithExplicitEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public Action OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private int counter; + private void Increment(EventArgs e) { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithString() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithNoArgsLambdaDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + { }"" />"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithEventArgsLambdaDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + { }"" />"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithNoArgMethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + void OnClick() { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithoutCloseTag() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +
+ +
+@code { + void OnClick() { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithEventArgsMethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + void OnClick(MouseEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + void OnClick(EventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void AsyncEventHandler_OnElement_Action_MethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Components.Web + +@code { + Task OnClick() + { + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Components.Web + +@code { + Task OnClick(MouseEventArgs e) + { + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void AsyncEventHandler_OnElement_Action_Lambda() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Components.Web + await Task.Delay(10))"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void AsyncEventHandler_OnElement_ActionEventArgs_Lambda() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks +@using Microsoft.AspNetCore.Components.Web + await Task.Delay(10))"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithLambdaDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + { }"" />"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_OnElement_WithDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + void OnClick(MouseEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_AttributeNameIsCaseSensitive() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + void OnClick(MouseEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_PreventDefault_StopPropagation_Minimized() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_PreventDefault_StopPropagation() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + bool Foo { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_WithDelegate_PreventDefault() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web + +@code { + void OnFocus(FocusEventArgs e) { } + + bool ShouldPreventDefault() { return false; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandler_PreventDefault_Duplicates() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Generics + + [Fact] + public void ChildComponent_Generic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_Generic_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_Generic_TypeInference_Multiple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericWeaklyTypedAttribute() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericWeaklyTypedAttribute_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericBind() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TItem Item { get; set; } + + [Parameter] + public Action ItemChanged { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +@code { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericBind_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TItem Item { get; set; } + + [Parameter] + public Action ItemChanged { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericBindWeaklyTyped() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +@code { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericBindWeaklyTyped_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Value { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +@code { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + + [Parameter] public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +
@context.ToLower()
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_GenericChildContent_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + + [Parameter] public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +
@context.ToLower()
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_NonGenericParameterizedChildContent_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + + [Parameter] public RenderFragment GenericFragment { get; set; } + + [Parameter] public RenderFragment IntFragment { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + @context.ToLower() + @context +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_WithFullyQualifiedTagName() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + + [Parameter] public RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +
@context.ToLower()
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_MultipleGenerics() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem1 Item { get; set; } + + [Parameter] public RenderFragment ChildContent { get; set; } + + [Parameter] public RenderFragment AnotherChildContent { get; set; } + + public class Context + { + public TItem2 Item { get; set; } + } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +
@context.ToLower()
+ + @System.Math.Max(0, item.Item); + +
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ChildComponent_MultipleGenerics_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem1 Item { get; set; } + + [Parameter] public List Items { get; set; } + + [Parameter] public RenderFragment ChildContent { get; set; } + + [Parameter] public RenderFragment AnotherChildContent { get; set; } + + public class Context + { + public TItem2 Item { get; set; } + } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +())> +
@context.ToLower()
+ + @System.Math.Max(0, item.Item); + +
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void NonGenericComponent_WithGenericEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyEventArgs { } + + public class MyComponent : ComponentBase + { + [Parameter] public string Item { get; set; } + [Parameter] public EventCallback Event { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + public void MyEventHandler() {} +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_WithKey() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private object _someKey = new object(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_WithKey_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private object _someKey = new object(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_WithComponentRef_CreatesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_NonGenericParameter_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; +using Test.Shared; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public MyClass Foo { get; set; } + } +} + +namespace Test.Shared +{ + public class MyClass + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test.Shared + + +@code { + MyClass Hello = new MyClass(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_NonGenericEventCallback_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyEventArgs { } + + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback MyEvent { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_GenericEventCallback_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyEventArgs { } + + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback MyEvent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_NestedGenericEventCallback_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyEventArgs { } + + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback>> MyEvent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponent_GenericEventCallbackWithGenericTypeParameter_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyEventArgs { } + + public class MyComponent : ComponentBase + { + [Parameter] public TItem Item { get; set; } + [Parameter] public EventCallback MyEvent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@using Test + {}"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Key + + [Fact] + public void Element_WithKey() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private object someObject = new object(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithKey_AndOtherAttributes() + { + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private object someObject = new object(); + + [Parameter] public int Min { get; set; } + } +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithKey() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private DateTime someDate = DateTime.Now; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithKey_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + Some further content + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithKey_AttributeNameIsCaseSensitive() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private object someObject = new object(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Splat + + [Fact] + public void Element_WithSplat() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithSplat_ImplicitExpression() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithSplat_ExplicitExpression() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithSplat() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithSplat_ImplicitExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithSplat_ExplicitExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithSplat_GenericTypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public T Value { get; set;} + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithSplat_AttributeNameIsCaseSensitive() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Ref + + [Fact] + public void Element_WithRef() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private Microsoft.AspNetCore.Components.ElementReference myElem; + public void Foo() { System.GC.KeepAlive(myElem); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithRef_AndOtherAttributes() + { + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private ElementReference _element; + + [Parameter] public int Min { get; set; } + public void Foo() { System.GC.KeepAlive(_element); } + } +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithRef() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + +@code { + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithRef_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" + + Some further content + + +@code { + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithRef_AttributeNameIsCaseSensitive() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Templates + + [Fact] + public void RazorTemplate_InCodeBlock() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@{ + RenderFragment p = (person) => @
@person.Name
; +} +@code { + class Person + { + public string Name { get; set; } + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_InExplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@(RenderPerson((person) => @
@person.Name
)) +@code { + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_NonGeneric_InImplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@RenderPerson(@
HI
) +@code { + object RenderPerson(RenderFragment p) => null; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_Generic_InImplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@RenderPerson((person) => @
@person.Name
) +@code { + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_ContainsComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ + RenderFragment p = (person) => @
; +} +@code { + class Person + { + public string Name { get; set; } + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + // Targeted at the logic that assigns 'builder' names + [Fact] + public void RazorTemplate_FollowedByComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ + RenderFragment p = (person) => @
; +} + +@(""hello, world!"") + + +@code { + class Person + { + public string Name { get; set; } + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_NonGeneric_AsComponentParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public RenderFragment Template { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment template = @
Joey
; } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_Generic_AsComponentParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public RenderFragment PersonTemplate { get; set; } + } + + public class Person + { + public string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment template = (person) => @
@person.Name
; } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void RazorTemplate_AsComponentParameter_MixedContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public RenderFragment Template { get; set; } + } + + public class Context + { + public int Index { get; set; } + public string Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@{ RenderFragment template = (context) => @
  • #@context.Index - @context.Item.ToLower()
  • ; } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Whitespace + + [Fact] + public void LeadingWhiteSpace_WithDirective() + { + // Arrange/Act + var generated = CompileToCSharp(@" + +@using System + +

    Hello

    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void LeadingWhiteSpace_WithCSharpExpression() + { + // Arrange/Act + var generated = CompileToCSharp(@" + +@(""My value"") + +

    Hello

    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void LeadingWhiteSpace_WithComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeOtherComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +

    Hello

    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void TrailingWhiteSpace_WithDirective() + { + // Arrange/Act + var generated = CompileToCSharp(@" +

    Hello

    + +@page ""/my/url"" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void TrailingWhiteSpace_WithCSharpExpression() + { + // Arrange/Act + var generated = CompileToCSharp(@" +

    Hello

    + +@(""My value"") + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void TrailingWhiteSpace_WithComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeOtherComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +

    Hello

    + + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Whitespace_BetweenElementAndFunctions() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + + @code { + int Foo = 18; + } +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void WhiteSpace_InsideAttribute_InMarkupBlock() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    Hello
    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Imports + [Fact] + public void Component_WithImportsFile() + { + // Arrange + var importContent = @" +@using System.Text +@using System.Reflection +@attribute [Serializable] +"; + var importItem = CreateProjectItem("_Imports.razor", importContent, FileKinds.ComponentImport); + ImportItems.Add(importItem); + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class Counter : ComponentBase + { + public int Count { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ComponentImports() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +namespace Test +{ + public class MainLayout : ComponentBase, ILayoutComponent + { + public RenderFragment Body { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp("_Imports.razor", @" +@using System.Text +@using System.Reflection + +@layout MainLayout +@Foo +
    Hello
    +", throwOnFailure: false, fileKind: FileKinds.ComponentImport); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, throwOnFailure: false); + } + + [Fact] + public void Component_NamespaceDirective_InImports() + { + // Arrange + var importContent = @" +@using System.Text +@using System.Reflection +@namespace New.Test +"; + var importItem = CreateProjectItem("_Imports.razor", importContent, FileKinds.ComponentImport); + ImportItems.Add(importItem); + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace New.Test +{ + public class Counter : ComponentBase + { + public int Count { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_NamespaceDirective_OverrideImports() + { + // Arrange + var importContent = @" +@using System.Text +@using System.Reflection +@namespace Import.Test +"; + var importItem = CreateProjectItem("_Imports.razor", importContent, FileKinds.ComponentImport); + ImportItems.Add(importItem); + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace New.Test +{ + public class Counter2 : ComponentBase + { + public int Count { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp("Pages/Counter.razor", @" +@namespace New.Test + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion + + #region Misc + + [Fact] // We don't process - we just skip them + public void Component_WithDocType() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +
    +
    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void DuplicateMarkupAttributes_IsAnError() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateMarkupAttributes_IsAnError_EventHandler() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateMarkupAttributes_Multiple_IsAnError() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + Assert.All(generated.Diagnostics, d => + { + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, d.Id); + }); + } + + [Fact] + public void DuplicateMarkupAttributes_IsAnError_BindValue() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +
    + +
    +@functions { + private string text = ""hi""; +} +"); + + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +
    + +
    +@functions { + private string text = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateMarkupAttributes_IsAnError_BindOnInput() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +
    + {}""> +
    +@functions { + private string text = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameter.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_Multiple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + Assert.All(generated.Diagnostics, d => + { + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameter.Id, d.Id); + }); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_WeaklyTyped() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameter.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_BindMessage() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; set; } + [Parameter] public EventCallback MessageChanged { get; set; } + [Parameter] public Expression> MessageExpression { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +@functions { + string message = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameterDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_BindMessageChanged() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; set; } + [Parameter] public EventCallback MessageChanged { get; set; } + [Parameter] public Expression> MessageExpression { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + {})"" @bind-Message=""@message"" /> +@functions { + string message = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameterDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_BindMessageExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; set; } + [Parameter] public EventCallback MessageChanged { get; set; } + [Parameter] public Expression> MessageExpression { get; set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + {})"" /> +@functions { + string message = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameterDirective.Id, diagnostic.Id); + } + + [Fact] + public void ScriptTag_WithErrorSuppressed() + { + // Arrange/Act + var generated = CompileToCSharp(@" +
    + +
    +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] // https://github.com/dotnet/blazor/issues/597 + public void Regression_597() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class Counter : ComponentBase + { + public int Count { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +@code { + string y = null; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Regression_609() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class User : ComponentBase + { + public string Name { get; set; } + public Action NameChanged { get; set; } + public bool IsActive { get; set; } + public Action IsActiveChanged { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +@code { + public string UserName { get; set; } + public bool UserIsActive { get; set; } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] // https://github.com/dotnet/blazor/issues/772 + public void Regression_772() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SurveyPrompt : ComponentBase + { + [Parameter] public string Title { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@page ""/"" + +

    Hello, world!

    + +Welcome to your new app. + + d.Id), + d => Assert.Equal("RZ1034", d.Id), + d => Assert.Equal("RZ1035", d.Id)); + } + + [Fact] // https://github.com/dotnet/blazor/issues/773 + public void Regression_773() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SurveyPrompt : ComponentBase + { + [Parameter] public string Title { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@page ""/"" + +

    Hello, world!

    + +Welcome to your new app. + +Test!
    "" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Regression_784() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components.Web +

    +@code { + public string ParentBgColor { get; set; } = ""#FFFFFF""; + + public void OnComponentHover(MouseEventArgs e) + { + } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void EventHandlerTagHelper_EscapeQuotes() + { + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_TextTagsAreNotRendered() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class Counter : ComponentBase + { + public int Count { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +@if (true) +{ + This text is rendered +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_MatchingIsCaseSensitive() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + [Parameter] public bool BoolProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_MultipleComponentsDifferByCase() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + } + + public class Mycomponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ElementWithUppercaseTagName_CanHideWarningWithBang() + { + // Arrange & Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs new file mode 100644 index 0000000000..8e9215906e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs @@ -0,0 +1,177 @@ +// 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.Reflection; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDeclarationRazorIntegrationTest : RazorIntegrationTestBase + { + public ComponentDeclarationRazorIntegrationTest() + { + // Include this assembly to use types defined in tests. + BaseCompilation = DefaultBaseCompilation.AddReferences(MetadataReference.CreateFromFile(GetType().Assembly.Location)); + } + + internal override CSharpCompilation BaseCompilation { get; } + + internal override string FileKind => FileKinds.Component; + + internal override bool DeclarationOnly => true; + + [Fact] + public void DeclarationConfiguration_IncludesFunctions() + { + // Arrange & Act + var component = CompileToComponent(@" +@functions { + public string Value { get; set; } +}"); + + // Assert + var property = component.GetType().GetProperty("Value"); + Assert.NotNull(property); + Assert.Same(typeof(string), property.PropertyType); + } + + [Fact] + public void DeclarationConfiguration_IncludesInject() + { + // Arrange & Act + var component = CompileToComponent(@" +@inject string Value +"); + + // Assert + var property = component.GetType().GetProperty("Value", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(property); + Assert.Same(typeof(string), property.PropertyType); + } + + [Fact] + public void DeclarationConfiguration_IncludesUsings() + { + // Arrange & Act + var component = CompileToComponent(@" +@using System.Text +@inject StringBuilder Value +"); + + // Assert + var property = component.GetType().GetProperty("Value", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(property); + Assert.Same(typeof(StringBuilder), property.PropertyType); + } + + [Fact] + public void DeclarationConfiguration_IncludesInherits() + { + // Arrange & Act + var component = CompileToComponent($@" +@inherits {FullTypeName()} +"); + + // Assert + Assert.Same(typeof(BaseClass), component.GetType().BaseType); + } + + [Fact] + public void DeclarationConfiguration_IncludesImplements() + { + // Arrange & Act + var component = CompileToComponent($@" +@implements {FullTypeName()} +"); + + // Assert + var type = component.GetType(); + Assert.Contains(typeof(IDoCoolThings), component.GetType().GetInterfaces()); + } + + [Fact] // Regression test for https://github.com/dotnet/blazor/issues/453 + public void DeclarationConfiguration_FunctionsBlockHasLineMappings_MappingsApplyToError() + { + // Arrange & Act 1 + var generated = CompileToCSharp(@" +@functions { + public StringBuilder Builder { get; set; } +} +"); + + // Assert 1 + AssertSourceEquals(@" +// +#pragma warning disable 1591 +#pragma warning disable 0414 +#pragma warning disable 0649 +#pragma warning disable 0169 + +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 +#nullable restore +#line 1 ""x:\dir\subdir\Test\TestComponent.cshtml"" + + public StringBuilder Builder { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 +", generated); + + // Act 2 + var assembly = CompileToAssembly(generated, throwOnFailure: false); + + // Assert 2 + var diagnostic = Assert.Single(assembly.Diagnostics); + + // This error should map to line 2 of the generated file, the test + // says 1 because Roslyn's line/column data structures are 0-based. + var position = diagnostic.Location.GetMappedLineSpan(); + Assert.EndsWith(".cshtml", position.Path); + Assert.Equal(1, position.StartLinePosition.Line); + } + + public class BaseClass : IComponent + { + public void Attach(RenderHandle renderHandle) + { + } + + protected virtual void BuildRenderTree(RenderTreeBuilder builder) + { + } + + public Task SetParametersAsync(ParameterView parameters) + { + throw new System.NotImplementedException(); + } + } + + public interface IDoCoolThings + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDesignTimeCodeGenerationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDesignTimeCodeGenerationTest.cs new file mode 100644 index 0000000000..f86a7d8d23 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDesignTimeCodeGenerationTest.cs @@ -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.Razor.Language.IntegrationTests +{ + public class ComponentDesignTimeCodeGenerationTest : ComponentCodeGenerationTestBase + { + internal override bool DesignTime => true; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs new file mode 100644 index 0000000000..863e2a0d16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs @@ -0,0 +1,205 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDiagnosticRazorIntegrationTest : RazorIntegrationTestBase + { + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + [Fact] + public void RejectsEndTagWithNoStartTag() + { + // Arrange/Act + var result = CompileToCSharp( + "Line1\nLine2\nLine3"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ9981", item.Id); + Assert.Equal("Unexpected closing tag 'mytag' with no matching start tag.", item.GetMessage()); + }); + } + + // This used to be a sugar syntax for lambdas, but we don't support that anymore + [Fact] + public void OldCodeBlockAttributeSyntax_ReportsError() + { + // Arrange/Act + var generated = CompileToCSharp(@" + +@functions { + public bool DidInvokeCode { get; set; } = false; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9979", diagnostic.Id); + Assert.NotNull(diagnostic.GetMessage()); + + } + + [Fact] + public void RejectsScriptTag() + { + // Arrange/Act + var result = CompileToCSharp(@"Hello +

    + +
    +Goodbye"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ9992", item.Id); + Assert.Equal("Script tags should not be placed inside components because they cannot be updated dynamically. To fix this, move the script tag to the 'index.html' file or another static location. For more information see https://go.microsoft.com/fwlink/?linkid=872131", item.GetMessage()); + Assert.Equal(2, item.Span.LineIndex); + Assert.Equal(4, item.Span.CharacterIndex); + }); + } + + [Fact] + public void RejectsTagHelperDirectives() + { + // Arrange/Act + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + var result = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@tagHelperPrefix th + + +"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ9978", item.Id); + Assert.Equal("The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. " + + "Use '@using ' directive instead.", item.GetMessage()); + Assert.Equal(0, item.Span.LineIndex); + Assert.Equal(0, item.Span.CharacterIndex); + }, + item => + { + Assert.Equal("RZ9978", item.Id); + Assert.Equal("The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. " + + "Use '@using ' directive instead.", item.GetMessage()); + Assert.Equal(1, item.Span.LineIndex); + Assert.Equal(0, item.Span.CharacterIndex); + }); + } + + [Fact] + public void DirectiveAttribute_ComplexContent_ReportsError() + { + // Arrange & Act + var generated = CompileToCSharp(@" + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9986", diagnostic.Id); + Assert.Equal( + "Component attributes do not support complex content (mixed C# and markup). Attribute: '@key', text: 'Foo @Text'", + diagnostic.GetMessage()); + } + + [Fact] + public void Component_StartsWithLowerCase_ReportsError() + { + // Arrange & Act + var generated = CompileToCSharp("lowerCase.razor", @" + +@functions { + public string Text { get; set; } = ""text""; +}", throwOnFailure: false); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ10011", diagnostic.Id); + Assert.Equal( + "Component 'lowerCase' starts with a lowercase character. Component names cannot start with a lowercase character.", + diagnostic.GetMessage()); + } + + [Fact] + public void Element_DoesNotStartWithLowerCase_ReportsWarning() + { + // Arrange & Act + var generated = CompileToCSharp(@" + + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ10012", diagnostic.Id); + Assert.Equal(RazorDiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal( + "Found markup element with unexpected name 'PossibleComponent'. If this is intended to be a component, add a @using directive for its namespace.", + diagnostic.GetMessage()); + } + + [Fact] + public void Element_DoesNotStartWithLowerCase_OverrideWithBang_NoWarning() + { + // Arrange & Act + var generated = CompileToCSharp(@" +"); + + // Assert + Assert.Empty(generated.Diagnostics); + } + + [Fact] + public void Component_StartAndEndTagCaseMismatch_ReportsError() + { + // Arrange & Act + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + var generated = CompileToCSharp(@" +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ10013", diagnostic.Id); + Assert.Equal( + "The start tag name 'MyComponent' does not match the end tag name 'mycomponent'. Components must have matching start and end tag names (case-sensitive).", + diagnostic.GetMessage()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs new file mode 100644 index 0000000000..b7e968f74a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDirectiveIntegrationTest.cs @@ -0,0 +1,151 @@ +// 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.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Integration tests for component directives + public class ComponentDirectiveIntegrationTest : RazorIntegrationTestBase + { + public ComponentDirectiveIntegrationTest() + { + // Include this assembly to use types defined in tests. + BaseCompilation = DefaultBaseCompilation.AddReferences(MetadataReference.CreateFromFile(GetType().Assembly.Location)); + } + + internal override CSharpCompilation BaseCompilation { get; } + + internal override string FileKind => FileKinds.Component; + + [Fact] + public void ComponentsDoNotHaveLayoutAttributeByDefault() + { + // Arrange/Act + var component = CompileToComponent($"Hello"); + + // Assert + Assert.Null(component.GetType().GetCustomAttribute()); + } + + [Fact] + public void SupportsLayoutDeclarations() + { + // Arrange/Act + var testComponentTypeName = FullTypeName(); + var component = CompileToComponent( + $"@layout {testComponentTypeName}\n" + + $"Hello"); + + // Assert + var layoutAttribute = component.GetType().GetCustomAttribute(); + Assert.NotNull(layoutAttribute); + } + + [Fact] + public void SupportsImplementsDeclarations() + { + // Arrange/Act + var testInterfaceTypeName = FullTypeName(); + var component = CompileToComponent( + $"@implements {testInterfaceTypeName}\n" + + $"Hello"); + + // Assert + Assert.IsAssignableFrom(component); + } + + [Fact] + public void SupportsMultipleImplementsDeclarations() + { + // Arrange/Act + var testInterfaceTypeName = FullTypeName(); + var testInterfaceTypeName2 = FullTypeName(); + var component = CompileToComponent( + $"@implements {testInterfaceTypeName}\n" + + $"@implements {testInterfaceTypeName2}\n" + + $"Hello"); + + // Assert + Assert.IsAssignableFrom(component); + Assert.IsAssignableFrom(component); + } + + [Fact] + public void SupportsInheritsDirective() + { + // Arrange/Act + var testBaseClassTypeName = FullTypeName(); + var component = CompileToComponent( + $"@inherits {testBaseClassTypeName}" + Environment.NewLine + + $"Hello"); + + // Assert + Assert.IsAssignableFrom(component); + } + + [Fact] + public void SupportsInjectDirective() + { + // Arrange/Act 1: Compilation + var componentType = CompileToComponent( + $"@inject {FullTypeName()} MyService1\n" + + $"@inject {FullTypeName()} MyService2\n" + + $"Hello from @MyService1 and @MyService2").GetType(); + + // Assert 1: Compiled type has correct properties + var propertyFlags = BindingFlags.Instance | BindingFlags.NonPublic; + var injectableProperties = componentType.GetProperties(propertyFlags) + .Where(p => p.GetCustomAttribute() != null); + Assert.Collection(injectableProperties.OrderBy(p => p.Name), + property => + { + Assert.Equal("MyService1", property.Name); + Assert.Equal(typeof(IMyService1), property.PropertyType); + Assert.False(property.GetMethod.IsPublic); + Assert.False(property.SetMethod.IsPublic); + }, + property => + { + Assert.Equal("MyService2", property.Name); + Assert.Equal(typeof(IMyService2), property.PropertyType); + Assert.False(property.GetMethod.IsPublic); + Assert.False(property.SetMethod.IsPublic); + }); + } + + public class TestLayout : IComponent + { + [Parameter] + public RenderFragment Body { get; set; } + + public void Attach(RenderHandle renderHandle) + { + throw new NotImplementedException(); + } + + public Task SetParametersAsync(ParameterView parameters) + { + throw new NotImplementedException(); + } + } + + public interface ITestInterface { } + + public interface ITestInterface2 { } + + public class TestBaseClass : ComponentBase { } + + public interface IMyService1 { } + public interface IMyService2 { } + public class MyService1Impl : IMyService1 { } + public class MyService2Impl : IMyService2 { } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs new file mode 100644 index 0000000000..3743979a0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDiscoveryIntegrationTest : RazorIntegrationTestBase + { + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + [Fact] + public void ComponentDiscovery_CanFindComponent_DefinedinCSharp() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var result = CompileToCSharp(string.Empty); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.MyComponent"); + } + + [Fact] + public void ComponentDiscovery_CanFindComponent_WithNamespace_DefinedinCSharp() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test.AnotherNamespace +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var result = CompileToCSharp(string.Empty); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + + Assert.Contains(bindings.TagHelpers, t => + { + return t.Name == "Test.AnotherNamespace.MyComponent" && + t.IsComponentFullyQualifiedNameMatch(); + }); + + Assert.DoesNotContain(bindings.TagHelpers, t => + { + return t.Name == "Test.AnotherNamespace.MyComponent" && + !t.IsComponentFullyQualifiedNameMatch(); + }); + } + + [Fact] + public void ComponentDiscovery_CanFindComponent_DefinedinCshtml() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", string.Empty); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + + [Fact] + public void ComponentDiscovery_CanFindComponent_WithTypeParameter() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", @" +@typeparam TItem +@functions { + [Parameter] public TItem Item { get; set; } +}"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + + [Fact] + public void ComponentDiscovery_CanFindComponent_WithMultipleTypeParameters() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", @" +@typeparam TItem1 +@typeparam TItem2 +@typeparam TItem3 +@functions { + [Parameter] public TItem1 Item { get; set; } +}"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Contains(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentFilePathIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentFilePathIntegrationTest.cs new file mode 100644 index 0000000000..2b3a60c2a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentFilePathIntegrationTest.cs @@ -0,0 +1,50 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Integration tests focused on file path handling for class/namespace names + public class ComponentFilePathIntegrationTest : RazorIntegrationTestBase + { + internal override string FileKind => FileKinds.Component; + + [Fact] + public void FileNameIsInvalidClassName_SanitizesInvalidClassName() + { + // Arrange + + // Act + var result = CompileToAssembly("Filename with spaces.cshtml", ""); + + // Assert + Assert.Empty(result.Diagnostics); + + var type = Assert.Single(result.Assembly.GetTypes()); + Assert.Equal(DefaultRootNamespace, type.Namespace); + Assert.Equal("Filename_with_spaces", type.Name); + } + + [Theory] + [InlineData("ItemAtRoot.cs", "Test", "ItemAtRoot")] + [InlineData("Dir1\\MyFile.cs", "Test.Dir1", "MyFile")] + [InlineData("Dir1\\Dir2\\MyFile.cs", "Test.Dir1.Dir2", "MyFile")] + public void CreatesClassWithCorrectNameAndNamespace(string relativePath, string expectedNamespace, string expectedClassName) + { + // Arrange + relativePath = relativePath.Replace('\\', Path.DirectorySeparatorChar); + + // Act + var result = CompileToAssembly(relativePath, ""); + + // Assert + Assert.Empty(result.Diagnostics); + + var type = Assert.Single(result.Assembly.GetTypes()); + Assert.Equal(expectedNamespace, type.Namespace); + Assert.Equal(expectedClassName, type.Name); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentGenericTypeIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentGenericTypeIntegrationTest.cs new file mode 100644 index 0000000000..70c936d13f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentGenericTypeIntegrationTest.cs @@ -0,0 +1,120 @@ +// 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.Components; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentGenericTypeIntegrationTest : RazorIntegrationTestBase + { + private readonly CSharpSyntaxTree GenericContextComponent = Parse(@" +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +namespace Test +{ + public class GenericContext : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + var items = (IReadOnlyList)Items ?? Array.Empty(); + for (var i = 0; i < items.Count; i++) + { + if (ChildContent == null) + { + builder.AddContent(i, Items[i]); + } + else + { + builder.AddContent(i, ChildContent, new Context() { Index = i, Item = items[i], }); + } + } + } + + [Parameter] + public List Items { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + + public class Context + { + public int Index { get; set; } + public TItem Item { get; set; } + } + } +} +"); + + private readonly CSharpSyntaxTree MultipleGenericParameterComponent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +namespace Test +{ + public class MultipleGenericParameter : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, Item1); + builder.AddContent(1, Item2); + builder.AddContent(2, Item3); + } + + [Parameter] + public TItem1 Item1 { get; set; } + + [Parameter] + public TItem2 Item2 { get; set; } + + [Parameter] + public TItem3 Item3 { get; set; } + } +} +"); + + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + [Fact] + public void GenericComponent_WithoutAnyTypeParameters_TriggersDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.GenericComponentTypeInferenceUnderspecified.Id, diagnostic.Id); + Assert.Equal( + "The type of component 'GenericContext' cannot be inferred based on the values provided. Consider " + + "specifying the type arguments directly using the following attributes: 'TItem'.", + diagnostic.GetMessage()); + } + + [Fact] + public void GenericComponent_WithMissingTypeParameters_TriggersDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(MultipleGenericParameterComponent); + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.GenericComponentMissingTypeArgument.Id, diagnostic.Id); + Assert.Equal( + "The component 'MultipleGenericParameter' is missing required type arguments. " + + "Specify the missing types using the attributes: 'TItem2', 'TItem3'.", + diagnostic.GetMessage()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentImportsIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentImportsIntegrationTest.cs new file mode 100644 index 0000000000..a4241730fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentImportsIntegrationTest.cs @@ -0,0 +1,191 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentImportsIntegrationTest : RazorIntegrationTestBase + { + internal override string FileKind => FileKinds.ComponentImport; + + [Fact] + public void NoErrorsForUsingStatements() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@using System.Text +@using System.Reflection +@* This is allowed in imports *@ +"); + + // Assert + Assert.Empty(result.Diagnostics); + } + + [Fact] + public void NoErrorsForRazorComments() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@* This is allowed in imports *@ +"); + + // Assert + Assert.Empty(result.Diagnostics); + } + + [Fact] + public void NoErrorsForSupportedDirectives() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@inject FooService Foo +@typeparam TItem +@implements ISomeInterface +@inherits SomeNamespace.SomeBaseType +"); + + // Assert + Assert.Empty(result.Diagnostics); + } + + [Fact] + public void ErrorsForPageDirective() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@page ""/"" +"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ9987", item.Id); + Assert.Equal(@"The '@page' directive specified in _Imports.razor file will not be imported. The directive must appear at the top of each Razor file", item.GetMessage()); + }); + } + + [Fact] + public void ErrorsForTagHelperDirectives() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@addTagHelper *, TestAssembly +@removeTagHelper *, TestAssembly +@tagHelperPrefix th: +"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ9978", item.Id); + Assert.Equal(0, item.Span.LineIndex); + Assert.Equal(@"The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. Use '@using ' directive instead.", item.GetMessage()); + }, + item => + { + Assert.Equal("RZ9978", item.Id); + Assert.Equal(1, item.Span.LineIndex); + Assert.Equal(@"The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. Use '@using ' directive instead.", item.GetMessage()); + }, + item => + { + Assert.Equal("RZ9978", item.Id); + Assert.Equal(2, item.Span.LineIndex); + Assert.Equal(@"The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. Use '@using ' directive instead.", item.GetMessage()); + }); + } + + [Fact] + public void ErrorsForFunctionsDirective() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@functions { + public class Test + { + } +} +"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ10003", item.Id); + Assert.Equal(@"Markup, code and block directives are not valid in component imports.", item.GetMessage()); + }); + } + + [Fact] + public void ErrorsForSectionDirective() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@section Foo { +} +"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ10003", item.Id); + Assert.Equal(@"Markup, code and block directives are not valid in component imports.", item.GetMessage()); + }); + } + + [Fact] + public void ErrorsForMarkup() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +
    asdf
    +"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ10003", item.Id); + Assert.Equal(@"Markup, code and block directives are not valid in component imports.", item.GetMessage()); + }); + } + + [Fact] + public void ErrorsForCode() + { + // Arrange/Act + var result = CompileToCSharp("_Imports.razor", @" +@Foo +@(Bar) +@{ + var x = Foo; +}"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("RZ10003", item.Id); + Assert.Equal(0, item.Span.LineIndex); + Assert.Equal(@"Markup, code and block directives are not valid in component imports.", item.GetMessage()); + }, + item => + { + Assert.Equal("RZ10003", item.Id); + Assert.Equal(1, item.Span.LineIndex); + Assert.Equal(@"Markup, code and block directives are not valid in component imports.", item.GetMessage()); + }, + item => + { + Assert.Equal("RZ10003", item.Id); + Assert.Equal(2, item.Span.LineIndex); + Assert.Equal(@"Markup, code and block directives are not valid in component imports.", item.GetMessage()); + }); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRuntimeCodeGenerationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRuntimeCodeGenerationTest.cs new file mode 100644 index 0000000000..dd49348086 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentRuntimeCodeGenerationTest.cs @@ -0,0 +1,9 @@ +// 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.Razor.Language.IntegrationTests +{ + public class ComponentRuntimeCodeGenerationTest : ComponentCodeGenerationTestBase + { + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs new file mode 100644 index 0000000000..93d206b87a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs @@ -0,0 +1,131 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentTemplateIntegrationTest : RazorIntegrationTestBase + { + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + // Razor doesn't parse this as a template, we don't need much special handling for + // it because it will just be invalid in general. + [Fact] + public void Template_ImplicitExpressionInMarkupAttribute_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    "" />", throwOnFailure: false); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ1005", diagnostic.Id); + } + + [Fact] + public void Template_ExplicitExpressionInMarkupAttribute_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9994", diagnostic.Id); + } + + // Razor doesn't parse this as a template, we don't need much special handling for + // it because it will just be invalid in general. + [Fact] + public void Template_ImplicitExpressionInComponentAttribute_CreatesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@"
    "" />", throwOnFailure: false); + + // Assert + Assert.Collection( + generated.Diagnostics, + d => Assert.Equal("RZ9986", d.Id), + d => Assert.Equal("RZ1005", d.Id)); + } + + [Fact] + public void Template_ExplicitExpressionInComponentAttribute_CreatesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9994", diagnostic.Id); + } + + [Fact] + public void Template_ExplicitExpressionInRef_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9994", diagnostic.Id); + } + + + [Fact] + public void Template_ExplicitExpressionInBind_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9994", diagnostic.Id); + } + + [Fact] + public void Template_ExplicitExpressionInEventHandler_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ9994", diagnostic.Id); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTypingTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTypingTest.cs new file mode 100644 index 0000000000..b3b8fc19e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTypingTest.cs @@ -0,0 +1,130 @@ +// 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.Linq; +using Xunit; +using Xunit.Sdk; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Similar to design time code generation tests, but goes a character at a time. + // Don't add many of these since they are slow - instead add features to existing + // tests here, and use these as smoke tests, not for detailed regression testing. + public class ComponentTypingTest : RazorIntegrationTestBase + { + internal override bool DesignTime => true; + + internal override string FileKind => FileKinds.Component; + + internal override bool UseTwoPhaseCompilation => true; + + [Fact] + public void DoSomeTyping() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public int Value { get; set; } + [Parameter] public Action ValueChanged { get; set; } + [Parameter] public string AnotherValue { get; set; } + } + + public class ModelState + { + public Action Bind(Func func) => throw null; + } +} +")); + var text = @" +
    + + x)"" /> + +
    + +@functions { + Test.ModelState ModelState { get; set; } +}"; + + for (var i = 0; i <= text.Length; i++) + { + try + { + CompileToCSharp(text.Substring(0, i), throwOnFailure: false); + } + catch (Exception ex) + { + throw new XunitException($@" +Code generation failed on iteration {i} with source text: +{text.Substring(0, i)} + +Exception: +{ex} +"); + } + } + } + + [Fact] // Regression test for #1068 + public void Regression_1068() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@functions { + Test.ModelState ModelState { get; set; } +} +", throwOnFailure: false); + + // Assert + } + + [Fact] + public void MalformedAttributeContent() + { + // Act + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public int Value { get; set; } + [Parameter] public Action ValueChanged { get; set; } + [Parameter] public string AnotherValue { get; set; } + } + + public class ModelState + { + public Action Bind(Func func) => throw null; + } +} +")); + var generated = CompileToCSharp(@" + await SaveAsync(false))> +@functions { + Test.ModelState ModelState { get; set; } +}", throwOnFailure: false); + + // Assert - does not throw + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ExtensibleDirectiveTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ExtensibleDirectiveTest.cs new file mode 100644 index 0000000000..924d143593 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ExtensibleDirectiveTest.cs @@ -0,0 +1,39 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Extensible directives only have codegen for design time, so we're only testing that. + public class ExtensibleDirectiveTest : IntegrationTestBase + { + public ExtensibleDirectiveTest() + : base(generateBaselines: null) + { + } + + [Fact] + public void NamespaceToken() + { + // Arrange + var engine = CreateProjectEngine(builder => + { + builder.ConfigureDocumentClassifier(); + + builder.AddDirective(DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddNamespaceToken())); + }); + + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = engine.ProcessDesignTime(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + AssertCSharpDocumentMatchesBaseline(codeDocument.GetCSharpDocument()); + AssertLinePragmas(codeDocument, designTime: true); + AssertSourceMappingsMatchBaseline(codeDocument); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/HtmlAttributeIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/HtmlAttributeIntegrationTest.cs new file mode 100644 index 0000000000..7fd26ffd80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/HtmlAttributeIntegrationTest.cs @@ -0,0 +1,36 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class HtmlAttributeIntegrationTest : IntegrationTestBase + { + [Fact] + public void HtmlWithDataDashAttribute() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + } + + [Fact] + public void HtmlWithConditionalAttribute() + { + // Arrange + var projectItem = CreateProjectItemFromFile(); + + // Act + var compiled = CompileToCSharp(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode()); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TagHelpersIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TagHelpersIntegrationTest.cs new file mode 100644 index 0000000000..c5c9810e76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TagHelpersIntegrationTest.cs @@ -0,0 +1,126 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class TagHelpersIntegrationTest : IntegrationTestBase + { + [Fact] + public void SimpleTagHelpers() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly") + }; + + var projectEngine = CreateProjectEngine(builder => builder.AddTagHelpers(descriptors)); + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + } + + [Fact] + public void TagHelpersWithBoundAttributes() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.String"), + }) + }; + + var projectEngine = CreateProjectEngine(builder => builder.AddTagHelpers(descriptors)); + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + } + + [Fact] + public void NestedTagHelpers() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "p", + typeName: "PTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "form", + typeName: "FormTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("value") + .PropertyName("FooProp") + .TypeName("System.String"), + }) + }; + + var projectEngine = CreateProjectEngine(builder => builder.AddTagHelpers(descriptors)); + var projectItem = CreateProjectItemFromFile(); + + // Act + var codeDocument = projectEngine.Process(projectItem); + + // Assert + var syntaxTree = codeDocument.GetSyntaxTree(); + var irTree = codeDocument.GetDocumentIntermediateNode(); + AssertDocumentNodeMatchesBaseline(codeDocument.GetDocumentIntermediateNode()); + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BoundAttributeDescriptor(attributeBuilder); + } + } + + builder.TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + + var descriptor = builder.Build(); + + return descriptor; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs new file mode 100644 index 0000000000..d2034b18e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs @@ -0,0 +1,637 @@ +// 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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class TestTagHelperDescriptors + { + public static IEnumerable SimpleTagHelperDescriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "span", + typeName: "SpanTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "div", + typeName: "DivTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("value") + .PropertyName("FooProp") + .TypeName("System.String"), + builder => builder + .Name("bound") + .PropertyName("BoundProp") + .TypeName("System.String"), + builder => builder + .Name("age") + .PropertyName("AgeProp") + .TypeName("System.Int32"), + }) + }; + } + } + + public static IEnumerable MinimizedBooleanTagHelperDescriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "span", + typeName: "SpanTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "div", + typeName: "DivTagHelper", + assemblyName: "TestAssembly"), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("value") + .PropertyName("FooProp") + .TypeName("System.String"), + builder => builder + .Name("bound") + .PropertyName("BoundProp") + .TypeName("System.Boolean"), + builder => builder + .Name("age") + .PropertyName("AgeProp") + .TypeName("System.Int32"), + }) + }; + } + } + + public static IEnumerable CssSelectorTagHelperDescriptors + { + get + { + var inputTypePropertyInfo = typeof(TestType).GetRuntimeProperty("Type"); + var inputCheckedPropertyInfo = typeof(TestType).GetRuntimeProperty("Checked"); + + return new[] + { + CreateTagHelperDescriptor( + tagName: "a", + typeName: "TestNamespace.ATagHelper", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("href") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("~/") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch)), + }), + CreateTagHelperDescriptor( + tagName: "a", + typeName: "TestNamespace.ATagHelperMultipleSelectors", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("href") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("~/") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch)) + .RequireAttributeDescriptor(attribute => attribute + .Name("href") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("?hello=world") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch)), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", inputTypePropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("type") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("text") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch)), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper2", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", inputTypePropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("ty") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)), + }), + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("href") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("~/") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch)), + }), + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper2", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("type") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)), + }), + }; + } + } + + public static IEnumerable EnumTagHelperDescriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("catch-all") + .PropertyName("CatchAll") + .AsEnum() + .TypeName($"{typeof(TestTagHelperDescriptors).FullName}.{nameof(MyEnum)}"), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("value") + .PropertyName("Value") + .AsEnum() + .TypeName($"{typeof(TestTagHelperDescriptors).FullName}.{nameof(MyEnum)}"), + }), + }; + } + } + + public static IEnumerable SymbolBoundTagHelperDescriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("[item]") + .PropertyName("ListItems") + .TypeName("System.Collections.Generic.List"), + builder => builder + .Name("[(item)]") + .PropertyName("ArrayItems") + .TypeName(typeof(string[]).FullName), + builder => builder + .Name("(click)") + .PropertyName("Event1") + .TypeName(typeof(Action).FullName), + builder => builder + .Name("(^click)") + .PropertyName("Event2") + .TypeName(typeof(Action).FullName), + builder => builder + .Name("*something") + .PropertyName("StringProperty1") + .TypeName(typeof(string).FullName), + builder => builder + .Name("#local") + .PropertyName("StringProperty2") + .TypeName(typeof(string).FullName), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("bound")), + }), + }; + } + } + + public static IEnumerable MinimizedTagHelpers_Descriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("catchall-bound-string") + .PropertyName("BoundRequiredString") + .TypeName(typeof(string).FullName), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("catchall-unbound-required")), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("input-bound-required-string") + .PropertyName("BoundRequiredString") + .TypeName(typeof(string).FullName), + builder => builder + .Name("input-bound-string") + .PropertyName("BoundString") + .TypeName(typeof(string).FullName), + }, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute.Name("input-bound-required-string")) + .RequireAttributeDescriptor(attribute => attribute.Name("input-unbound-required")), + }), + CreateTagHelperDescriptor( + tagName: "div", + typeName: "DivTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("boundbool") + .PropertyName("BoundBoolProp") + .TypeName(typeof(bool).FullName), + builder => builder + .Name("booldict") + .PropertyName("BoolDictProp") + .TypeName("System.Collections.Generic.IDictionary") + .AsDictionaryAttribute("booldict-prefix-", typeof(bool).FullName), + }), + }; + } + } + + public static IEnumerable DynamicAttributeTagHelpers_Descriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(string).FullName) + }), + }; + } + } + + public static IEnumerable DuplicateTargetTagHelperDescriptors + { + get + { + var typePropertyInfo = typeof(TestType).GetRuntimeProperty("Type"); + var checkedPropertyInfo = typeof(TestType).GetRuntimeProperty("Checked"); + return new[] + { + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", typePropertyInfo), + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "checked", checkedPropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("type")), + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("checked")) + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", typePropertyInfo), + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "checked", checkedPropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("type")), + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("checked")) + }) + }; + } + } + + public static IEnumerable AttributeTargetingTagHelperDescriptors + { + get + { + var inputTypePropertyInfo = typeof(TestType).GetRuntimeProperty("Type"); + var inputCheckedPropertyInfo = typeof(TestType).GetRuntimeProperty("Checked"); + return new[] + { + CreateTagHelperDescriptor( + tagName: "p", + typeName: "TestNamespace.PTagHelper", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("class")), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", inputTypePropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("type")), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper2", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", inputTypePropertyInfo), + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "checked", inputCheckedPropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute.Name("type")) + .RequireAttributeDescriptor(attribute => attribute.Name("checked")), + }), + CreateTagHelperDescriptor( + tagName: "*", + typeName: "TestNamespace.CatchAllTagHelper", + assemblyName: "TestAssembly", + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("catchAll")), + }), + }; + } + } + + public static IEnumerable PrefixedAttributeTagHelperDescriptors + { + get + { + return new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper1", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("int-prefix-grabber") + .PropertyName("IntProperty") + .TypeName(typeof(int).FullName), + builder => builder + .Name("int-dictionary") + .PropertyName("IntDictionaryProperty") + .TypeName("System.Collections.Generic.IDictionary") + .AsDictionaryAttribute("int-prefix-", typeof(int).FullName), + builder => builder + .Name("string-prefix-grabber") + .PropertyName("StringProperty") + .TypeName(typeof(string).FullName), + builder => builder + .Name("string-dictionary") + .PropertyName("StringDictionaryProperty") + .TypeName("Namespace.DictionaryWithoutParameterlessConstructor") + .AsDictionaryAttribute("string-prefix-", typeof(string).FullName), + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper2", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("int-dictionary") + .PropertyName("IntDictionaryProperty") + .TypeName(typeof(int).FullName) + .AsDictionaryAttribute("int-prefix-", typeof(int).FullName), + builder => builder + .Name("string-dictionary") + .PropertyName("StringDictionaryProperty") + .TypeName("Namespace.DictionaryWithoutParameterlessConstructor") + .AsDictionaryAttribute("string-prefix-", typeof(string).FullName), + }), + }; + } + } + + public static IEnumerable TagHelpersInSectionDescriptors + { + get + { + var propertyInfo = typeof(TestType).GetRuntimeProperty("BoundProperty"); + return new[] + { + CreateTagHelperDescriptor( + tagName: "MyTagHelper", + typeName: "TestNamespace.MyTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "BoundProperty", propertyInfo), + }), + CreateTagHelperDescriptor( + tagName: "NestedTagHelper", + typeName: "TestNamespace.NestedTagHelper", + assemblyName: "TestAssembly"), + }; + } + } + + public static IEnumerable DefaultPAndInputTagHelperDescriptors + { + get + { + var pAgePropertyInfo = typeof(TestType).GetRuntimeProperty("Age"); + var inputTypePropertyInfo = typeof(TestType).GetRuntimeProperty("Type"); + var checkedPropertyInfo = typeof(TestType).GetRuntimeProperty("Checked"); + + return new[] + { + CreateTagHelperDescriptor( + tagName: "p", + typeName: "TestNamespace.PTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "age", pAgePropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireTagStructure(TagStructure.NormalOrSelfClosing) + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", inputTypePropertyInfo), + }, + ruleBuilders: new Action[] + { + builder => builder.RequireTagStructure(TagStructure.WithoutEndTag) + }), + CreateTagHelperDescriptor( + tagName: "input", + typeName: "TestNamespace.InputTagHelper2", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "type", inputTypePropertyInfo), + builder => BuildBoundAttributeDescriptorFromPropertyInfo(builder, "checked", checkedPropertyInfo), + }), + }; + } + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null, + IEnumerable> ruleBuilders = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BoundAttributeDescriptor(attributeBuilder); + } + } + + if (ruleBuilders != null) + { + foreach (var ruleBuilder in ruleBuilders) + { + builder.TagMatchingRuleDescriptor(innerRuleBuilder => + { + innerRuleBuilder.RequireTagName(tagName); + ruleBuilder(innerRuleBuilder); + }); + } + } + else + { + builder.TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + } + + var descriptor = builder.Build(); + + return descriptor; + } + + private static void BuildBoundAttributeDescriptorFromPropertyInfo( + BoundAttributeDescriptorBuilder builder, + string name, + PropertyInfo propertyInfo) + { + builder + .Name(name) + .PropertyName(propertyInfo.Name) + .TypeName(propertyInfo.PropertyType.FullName); + + if (propertyInfo.PropertyType.GetTypeInfo().IsEnum) + { + builder.AsEnum(); + } + } + + private class TestType + { + public int Age { get; set; } + + public string Type { get; set; } + + public bool Checked { get; set; } + + public string BoundProperty { get; set; } + } + + public enum MyEnum + { + MyValue, + MySecondValue + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs new file mode 100644 index 0000000000..f4813684e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs @@ -0,0 +1,217 @@ +// 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.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + public class DefaultRazorIntermediateNodeBuilderTest + { + [Fact] + public void Ctor_CreatesEmptyBuilder() + { + // Arrange & Act + var builder = new DefaultRazorIntermediateNodeBuilder(); + var current = builder.Current; + + // Assert + Assert.Null(current); + } + + [Fact] + public void Push_WhenEmpty_AddsNode() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + var node = new BasicIntermediateNode(); + + // Act + builder.Push(node); + + // Assert + Assert.Same(node, builder.Current); + } + + [Fact] + public void Push_WhenNonEmpty_SetsUpChild() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var parent = new BasicIntermediateNode(); + builder.Push(parent); + + var node = new BasicIntermediateNode(); + + // Act + builder.Push(node); + + // Assert + Assert.Same(node, builder.Current); + Assert.Collection(parent.Children, n => Assert.Same(node, n)); + } + + [Fact] + public void Pop_ThrowsWhenEmpty() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + // Act & Assert + ExceptionAssert.Throws( + () => builder.Pop(), + "The 'Pop' operation is not valid when the builder is empty."); + } + + [Fact] + public void Pop_SingleNodeDepth_RemovesAndReturnsNode() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var node = new BasicIntermediateNode(); + builder.Push(node); + + // Act + var result = builder.Pop(); + + // Assert + Assert.Same(node, result); + Assert.Null(builder.Current); + } + + [Fact] + public void Pop_MultipleNodeDepth_RemovesAndReturnsNode() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var parent = new BasicIntermediateNode(); + builder.Push(parent); + + var node = new BasicIntermediateNode(); + builder.Push(node); + + // Act + var result = builder.Pop(); + + // Assert + Assert.Same(node, result); + Assert.Same(parent, builder.Current); + } + + [Fact] + public void Add_AddsToChildrenAndSetsParent() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var parent = new BasicIntermediateNode(); + builder.Push(parent); + + var node = new BasicIntermediateNode(); + + // Act + builder.Add(node); + + // Assert + Assert.Same(parent, builder.Current); + Assert.Collection(parent.Children, n => Assert.Same(node, n)); + } + + [Fact] + public void Insert_AddsToChildren_EmptyCollection() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var parent = new BasicIntermediateNode(); + builder.Push(parent); + + var node = new BasicIntermediateNode(); + + // Act + builder.Insert(0, node); + + // Assert + Assert.Same(parent, builder.Current); + Assert.Collection(parent.Children, n => Assert.Same(node, n)); + } + + [Fact] + public void Insert_AddsToChildren_NonEmpyCollection() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var parent = new BasicIntermediateNode(); + builder.Push(parent); + + var child = new BasicIntermediateNode(); + builder.Add(child); + + var node = new BasicIntermediateNode(); + + // Act + builder.Insert(0, node); + + // Assert + Assert.Same(parent, builder.Current); + Assert.Collection(parent.Children, n => Assert.Same(node, n), n => Assert.Same(child, n)); + } + + [Fact] + public void Insert_AddsToChildren_NonEmpyCollection_AtEnd() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var parent = new BasicIntermediateNode(); + builder.Push(parent); + + var child = new BasicIntermediateNode(); + builder.Add(child); + + var node = new BasicIntermediateNode(); + + // Act + builder.Insert(1, node); + + // Assert + Assert.Same(parent, builder.Current); + Assert.Collection(parent.Children, n => Assert.Same(child, n), n => Assert.Same(node, n)); + } + + [Fact] + public void Build_PopsMultipleLevels() + { + // Arrange + var builder = new DefaultRazorIntermediateNodeBuilder(); + + var document = new DocumentIntermediateNode(); + builder.Push(document); + + var node = new BasicIntermediateNode(); + builder.Push(node); + + // Act + var result = builder.Build(); + + // Assert + Assert.Same(document, result); + Assert.Null(builder.Current); + } + + private class BasicIntermediateNode : IntermediateNode + { + public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection(); + + public override void Accept(IntermediateNodeVisitor visitor) + { + throw new NotImplementedException(); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs new file mode 100644 index 0000000000..8def071acc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/DocumentIntermediateNodeExtensionsTest.cs @@ -0,0 +1,113 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + public class DocumentIntermediateNodeExtensionsTest + { + [Fact] + public void FindPrimaryClass_FindsClassWithAnnotation() + { + // Arrange + var document = new DocumentIntermediateNode(); + var @class = new ClassDeclarationIntermediateNode(); + @class.Annotations[CommonAnnotations.PrimaryClass] = CommonAnnotations.PrimaryClass; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Add(@class); + + // Act + var result = document.FindPrimaryClass(); + + // Assert + Assert.Same(@class, result); + } + + [Fact] + public void FindPrimaryMethod_FindsMethodWithAnnotation() + { + // Arrange + var document = new DocumentIntermediateNode(); + var method = new MethodDeclarationIntermediateNode(); + method.Annotations[CommonAnnotations.PrimaryMethod] = CommonAnnotations.PrimaryMethod; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Add(method); + + // Act + var result = document.FindPrimaryMethod(); + + // Assert + Assert.Same(method, result); + } + + [Fact] + public void FindPrimaryNamespace_FindsNamespaceWithAnnotation() + { + // Arrange + var document = new DocumentIntermediateNode(); + var @namespace = new NamespaceDeclarationIntermediateNode(); + @namespace.Annotations[CommonAnnotations.PrimaryNamespace] = CommonAnnotations.PrimaryNamespace; + + var builder = IntermediateNodeBuilder.Create(document); + builder.Add(@namespace); + + // Act + var result = document.FindPrimaryNamespace(); + + // Assert + Assert.Same(@namespace, result); + } + + [Fact] + public void FindDirectiveReferences_FindsMatchingDirectives() + { + // Arrange + var directive = DirectiveDescriptor.CreateSingleLineDirective("test"); + var directive2 = DirectiveDescriptor.CreateSingleLineDirective("test"); + + var document = new DocumentIntermediateNode(); + var @namespace = new NamespaceDeclarationIntermediateNode(); + + var builder = IntermediateNodeBuilder.Create(document); + builder.Push(@namespace); + + var match1 = new DirectiveIntermediateNode() + { + Directive = directive, + }; + builder.Add(match1); + + var nonMatch = new DirectiveIntermediateNode() + { + Directive = directive2, + }; + builder.Add(nonMatch); + + var match2 = new DirectiveIntermediateNode() + { + Directive = directive, + }; + builder.Add(match2); + + // Act + var results = document.FindDirectiveReferences(directive); + + // Assert + Assert.Collection( + results, + r => + { + Assert.Same(@namespace, r.Parent); + Assert.Same(match1, r.Node); + }, + r => + { + Assert.Same(@namespace, r.Parent); + Assert.Same(match2, r.Node); + }); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/ExtensionIntermediateNodeTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/ExtensionIntermediateNodeTest.cs new file mode 100644 index 0000000000..a4bf7950ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/ExtensionIntermediateNodeTest.cs @@ -0,0 +1,92 @@ +// 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; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + // These tests cover the methods on ExtensionIntermediateNode that are used to implement visitors + // that special case an extension node. + public class ExtensionIntermediateNodeTest + { + [Fact] + public void Accept_CallsStandardVisitExtension_ForStandardVisitor() + { + // Arrange + var node = new TestExtensionIntermediateNode(); + var visitor = new StandardVisitor(); + + // Act + node.Accept(visitor); + + // Assert + Assert.True(visitor.WasStandardMethodCalled); + Assert.False(visitor.WasSpecificMethodCalled); + } + + [Fact] + public void Accept_CallsSpecialVisitExtension_ForSpecialVisitor() + { + // Arrange + var node = new TestExtensionIntermediateNode(); + var visitor = new SpecialVisitor(); + + // Act + node.Accept(visitor); + + // Assert + Assert.False(visitor.WasStandardMethodCalled); + Assert.True(visitor.WasSpecificMethodCalled); + } + + private class TestExtensionIntermediateNode : ExtensionIntermediateNode + { + public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; + + public override void Accept(IntermediateNodeVisitor visitor) + { + // This is the standard visitor boilerplate for an extension node. + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(CodeTarget target, CodeRenderingContext context) + { + throw new NotImplementedException(); + } + } + + private class StandardVisitor : IntermediateNodeVisitor + { + public bool WasStandardMethodCalled { get; private set; } + public bool WasSpecificMethodCalled { get; private set; } + + public override void VisitExtension(ExtensionIntermediateNode node) + { + WasStandardMethodCalled = true; + } + + public void VisitExtension(TestExtensionIntermediateNode node) + { + WasSpecificMethodCalled = true; + } + } + + private class SpecialVisitor : IntermediateNodeVisitor, IExtensionIntermediateNodeVisitor + { + public bool WasStandardMethodCalled { get; private set; } + public bool WasSpecificMethodCalled { get; private set; } + + public override void VisitExtension(ExtensionIntermediateNode node) + { + WasStandardMethodCalled = true; + } + + public void VisitExtension(TestExtensionIntermediateNode node) + { + WasSpecificMethodCalled = true; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/IntermediateNodeReferenceTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/IntermediateNodeReferenceTest.cs new file mode 100644 index 0000000000..2adbe06a4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/IntermediateNodeReferenceTest.cs @@ -0,0 +1,510 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + public class IntermediateNodeReferenceTest + { + [Fact] + public void InsertAfter_SingleNode_AddsNodeAfterNode() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + + parent.Children.Add(node1); + parent.Children.Add(node3); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act + reference.InsertAfter(node2); + + // Assert + Assert.Equal(new[] { node1, node2, node3, }, parent.Children); + } + + [Fact] + public void InsertAfter_SingleNode_AddsNodeAfterNode_AtEnd() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + + parent.Children.Add(node1); + parent.Children.Add(node2); + + var reference = new IntermediateNodeReference(parent, node2); + + // Act + reference.InsertAfter(node3); + + // Assert + Assert.Equal(new[] { node1, node2, node3, }, parent.Children); + } + + [Fact] + public void InsertAfter_MultipleNodes_AddsNodesAfterNode() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + var node4 = new BasicIntermediateNode("Node4"); + + parent.Children.Add(node1); + parent.Children.Add(node4); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act + reference.InsertAfter(new[] { node2, node3 }); + + // Assert + Assert.Equal(new[] { node1, node2, node3, node4, }, parent.Children); + } + + [Fact] + public void InsertAfter_MultipleNodes_AddsNodesAfterNode_AtEnd() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + var node4 = new BasicIntermediateNode("Node4"); + + parent.Children.Add(node1); + parent.Children.Add(node2); + + var reference = new IntermediateNodeReference(parent, node2); + + // Act + reference.InsertAfter(new[] { node3, node4 }); + + // Assert + Assert.Equal(new[] { node1, node2, node3, node4, }, parent.Children); + } + + [Fact] + public void InsertBefore_SingleNode_AddsNodeBeforeNode() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + + parent.Children.Add(node1); + parent.Children.Add(node3); + + var reference = new IntermediateNodeReference(parent, node3); + + // Act + reference.InsertBefore(node2); + + // Assert + Assert.Equal(new[] { node1, node2, node3, }, parent.Children); + } + + [Fact] + public void InsertBefore_SingleNode_AddsNodeBeforeNode_AtBeginning() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + + parent.Children.Add(node2); + parent.Children.Add(node3); + + var reference = new IntermediateNodeReference(parent, node2); + + // Act + reference.InsertBefore(node1); + + // Assert + Assert.Equal(new[] { node1, node2, node3, }, parent.Children); + } + + [Fact] + public void InsertBefore_MultipleNodes_AddsNodesBeforeNode() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + var node4 = new BasicIntermediateNode("Node4"); + + parent.Children.Add(node1); + parent.Children.Add(node4); + + var reference = new IntermediateNodeReference(parent, node4); + + // Act + reference.InsertBefore(new[] { node2, node3 }); + + // Assert + Assert.Equal(new[] { node1, node2, node3, node4, }, parent.Children); + } + + [Fact] + public void InsertAfter_MultipleNodes_AddsNodesBeforeNode_AtBeginning() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + var node4 = new BasicIntermediateNode("Node4"); + + parent.Children.Add(node3); + parent.Children.Add(node4); + + var reference = new IntermediateNodeReference(parent, node3); + + // Act + reference.InsertBefore(new[] { node1, node2 }); + + // Assert + Assert.Equal(new[] { node1, node2, node3, node4, }, parent.Children); + } + + [Fact] + public void Remove_RemovesNode() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + + parent.Children.Add(node1); + parent.Children.Add(node3); + parent.Children.Add(node2); + + var reference = new IntermediateNodeReference(parent, node3); + + // Act + reference.Remove(); + + // Assert + Assert.Equal(new[] { node1, node2,}, parent.Children); + } + + [Fact] + public void Replace_ReplacesNode() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + var node2 = new BasicIntermediateNode("Node2"); + var node3 = new BasicIntermediateNode("Node3"); + var node4 = new BasicIntermediateNode("Node4"); + + parent.Children.Add(node1); + parent.Children.Add(node4); + parent.Children.Add(node3); + + var reference = new IntermediateNodeReference(parent, node4); + + // Act + reference.Replace(node2); + + // Assert + Assert.Equal(new[] { node1, node2, node3, }, parent.Children); + } + + [Fact] + public void InsertAfter_SingleNode_ThrowsForReferenceNotInitialized() + { + // Arrange + var reference = new IntermediateNodeReference(); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertAfter(new BasicIntermediateNode("_"))); + Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message); + } + + [Fact] + public void InsertAfter_MulipleNodes_ThrowsForReferenceNotInitialized() + { + // Arrange + var reference = new IntermediateNodeReference(); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertAfter(new[] { new BasicIntermediateNode("_") })); + Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message); + } + + [Fact] + public void InsertBefore_SingleNode_ThrowsForReferenceNotInitialized() + { + // Arrange + var reference = new IntermediateNodeReference(); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertBefore(new BasicIntermediateNode("_"))); + Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message); + } + + [Fact] + public void InsertBefore_MulipleNodes_ThrowsForReferenceNotInitialized() + { + // Arrange + var reference = new IntermediateNodeReference(); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertBefore(new[] { new BasicIntermediateNode("_") })); + Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message); + } + + [Fact] + public void Remove_ThrowsForReferenceNotInitialized() + { + // Arrange + var reference = new IntermediateNodeReference(); + + // Act & Assert + var exception = Assert.Throws(() => reference.Remove()); + Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message); + } + + [Fact] + public void Replace_ThrowsForReferenceNotInitialized() + { + // Arrange + var reference = new IntermediateNodeReference(); + + // Act & Assert + var exception = Assert.Throws(() => reference.Replace(new BasicIntermediateNode("_"))); + Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message); + } + + [Fact] + public void InsertAfter_SingleNode_ThrowsForReadOnlyCollection() + { + // Arrange + var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertAfter(new BasicIntermediateNode("_"))); + Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message); + } + + [Fact] + public void InsertAfter_MulipleNodes_ThrowsForReadOnlyCollection() + { + // Arrange + var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertAfter(new[] { new BasicIntermediateNode("_") })); + Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message); + } + + [Fact] + public void InsertBefore_SingleNode_ThrowsForReadOnlyCollection() + { + // Arrange + var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertBefore(new BasicIntermediateNode("_"))); + Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message); + } + + [Fact] + public void InsertBefore_MulipleNodes_ThrowsForReadOnlyCollection() + { + // Arrange + var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertBefore(new[] { new BasicIntermediateNode("_") })); + Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message); + } + + [Fact] + public void Remove_ThrowsForReadOnlyCollection() + { + // Arrange + var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.Remove()); + Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message); + } + + [Fact] + public void Replace_ThrowsForReadOnlyCollection() + { + // Arrange + var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.Replace(new BasicIntermediateNode("_"))); + Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message); + } + + [Fact] + public void InsertAfter_SingleNode_ThrowsForNodeNotFound() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertAfter(new BasicIntermediateNode("_"))); + Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message); + } + + [Fact] + public void InsertAfter_MulipleNodes_ThrowsForNodeNotFound() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertAfter(new[] { new BasicIntermediateNode("_") })); + Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message); + } + + [Fact] + public void InsertBefore_SingleNode_ThrowsForNodeNotFound() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertBefore(new BasicIntermediateNode("_"))); + Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message); + } + + [Fact] + public void InsertBefore_MulipleNodes_ThrowsForNodeNotFound() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.InsertBefore(new[] { new BasicIntermediateNode("_") })); + Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message); + } + + [Fact] + public void Remove_ThrowsForNodeNotFound() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.Remove()); + Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message); + } + + [Fact] + public void Replace_ThrowsForNodeNotFound() + { + // Arrange + var parent = new BasicIntermediateNode("Parent"); + + var node1 = new BasicIntermediateNode("Node1"); + + var reference = new IntermediateNodeReference(parent, node1); + + // Act & Assert + var exception = Assert.Throws(() => reference.Replace(new BasicIntermediateNode("_"))); + Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message); + } + + private class BasicIntermediateNode : IntermediateNode + { + public BasicIntermediateNode(string name) + : this(name, new IntermediateNodeCollection()) + { + Name = name; + } + + public BasicIntermediateNode(string name, IntermediateNodeCollection children) + { + Name = name; + Children = children; + } + + public string Name { get; } + + public override IntermediateNodeCollection Children { get; } + + public override void Accept(IntermediateNodeVisitor visitor) + { + throw new System.NotImplementedException(); + } + + public override string ToString() => Name; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/IntermediateNodeWalkerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/IntermediateNodeWalkerTest.cs new file mode 100644 index 0000000000..f91735f9c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Intermediate/IntermediateNodeWalkerTest.cs @@ -0,0 +1,140 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + public class IntermediateNodeWalkerTest + { + [Fact] + public void IntermediateNodeWalker_Visit_TraversesEntireGraph() + { + // Arrange + var walker = new DerivedIntermediateNodeWalker(); + + var nodes = new IntermediateNode[] + { + new BasicIntermediateNode("Root"), + new BasicIntermediateNode("Root->A"), + new BasicIntermediateNode("Root->B"), + new BasicIntermediateNode("Root->B->1"), + new BasicIntermediateNode("Root->B->2"), + new BasicIntermediateNode("Root->C"), + }; + + var builder = new DefaultRazorIntermediateNodeBuilder(); + builder.Push(nodes[0]); + builder.Add(nodes[1]); + builder.Push(nodes[2]); + builder.Add(nodes[3]); + builder.Add(nodes[4]); + builder.Pop(); + builder.Add(nodes[5]); + + var root = builder.Pop(); + + // Act + walker.Visit(root); + + // Assert + Assert.Equal(nodes, walker.Visited.ToArray()); + } + + [Fact] + public void IntermediateNodeWalker_Visit_SetsParentAndAncestors() + { + // Arrange + var walker = new DerivedIntermediateNodeWalker(); + + var nodes = new IntermediateNode[] + { + new BasicIntermediateNode("Root"), + new BasicIntermediateNode("Root->A"), + new BasicIntermediateNode("Root->B"), + new BasicIntermediateNode("Root->B->1"), + new BasicIntermediateNode("Root->B->2"), + new BasicIntermediateNode("Root->C"), + }; + + var ancestors = new Dictionary() + { + { "Root", new string[]{ } }, + { "Root->A", new string[] { "Root" } }, + { "Root->B", new string[] { "Root" } }, + { "Root->B->1", new string[] { "Root->B", "Root" } }, + { "Root->B->2", new string[] { "Root->B", "Root" } }, + { "Root->C", new string[] { "Root" } }, + }; + + walker.OnVisiting = (n) => + { + Assert.Equal(ancestors[((BasicIntermediateNode)n).Name], walker.Ancestors.Cast().Select(b => b.Name)); + Assert.Equal(ancestors[((BasicIntermediateNode)n).Name].FirstOrDefault(), ((BasicIntermediateNode)walker.Parent)?.Name); + }; + + var builder = new DefaultRazorIntermediateNodeBuilder(); + builder.Push(nodes[0]); + builder.Add(nodes[1]); + builder.Push(nodes[2]); + builder.Add(nodes[3]); + builder.Add(nodes[4]); + builder.Pop(); + builder.Add(nodes[5]); + + var root = builder.Pop(); + + // Act & Assert + walker.Visit(root); + } + + private class DerivedIntermediateNodeWalker : IntermediateNodeWalker + { + public new IReadOnlyList Ancestors => base.Ancestors; + + public new IntermediateNode Parent => base.Parent; + + public List Visited { get; } = new List(); + + public Action OnVisiting { get; set; } + + public override void VisitDefault(IntermediateNode node) + { + Visited.Add(node); + + OnVisiting?.Invoke(node); + base.VisitDefault(node); + } + + public virtual void VisitBasic(BasicIntermediateNode node) + { + VisitDefault(node); + } + } + + private class BasicIntermediateNode : IntermediateNode + { + public BasicIntermediateNode(string name) + { + Name = name; + } + + public string Name { get; } + + public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection(); + + public override void Accept(IntermediateNodeVisitor visitor) + { + ((DerivedIntermediateNodeWalker)visitor).VisitBasic(this); + } + + public override string ToString() + { + return Name; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/LargeTextSourceDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/LargeTextSourceDocumentTest.cs new file mode 100644 index 0000000000..fb47799b23 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/LargeTextSourceDocumentTest.cs @@ -0,0 +1,172 @@ +using System.IO; +using System.Text; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test +{ + public class LargeTextSourceDocumentTest + { + private const int ChunkTestLength = 10; + + [Fact] + public void GetChecksum_ReturnsCopiedChecksum() + { + // Arrange + var contentString = "Hello World"; + var stream = TestRazorSourceDocument.CreateStreamContent(contentString); + var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var firstChecksum = document.GetChecksum(); + var secondChecksum = document.GetChecksum(); + + // Assert + Assert.Equal(firstChecksum, secondChecksum); + Assert.NotSame(firstChecksum, secondChecksum); + } + + [Fact] + public void GetChecksum_ComputesCorrectChecksum_UTF8() + { + // Arrange + var contentString = "Hello World"; + var stream = TestRazorSourceDocument.CreateStreamContent(contentString); + var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF8, RazorSourceDocumentProperties.Default); + var expectedChecksum = new byte[] { 10, 77, 85, 168, 215, 120, 229, 2, 47, 171, 112, 25, 119, 197, 216, 64, 187, 196, 134, 208 }; + + // Act + var checksum = document.GetChecksum(); + + // Assert + Assert.Equal(expectedChecksum, checksum); + } + + [Fact] + public void GetChecksum_ComputesCorrectChecksum_UTF32() + { + // Arrange + var contentString = "Hello World"; + var stream = TestRazorSourceDocument.CreateStreamContent(contentString, Encoding.UTF32); + var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); + var document = new LargeTextSourceDocument(reader, 5, Encoding.UTF32, RazorSourceDocumentProperties.Default); + var expectedChecksum = new byte[] { 108, 172, 130, 171, 42, 19, 155, 176, 211, 80, 224, 121, 169, 133, 25, 134, 48, 228, 199, 141 }; + + // Act + var checksum = document.GetChecksum(); + + // Assert + Assert.Equal(expectedChecksum, checksum); + } + + [Theory] + [InlineData(ChunkTestLength - 1)] + [InlineData(ChunkTestLength)] + [InlineData(ChunkTestLength + 1)] + [InlineData(ChunkTestLength * 2 - 1)] + [InlineData(ChunkTestLength * 2)] + [InlineData(ChunkTestLength * 2 + 1)] + public void Indexer_ProvidesCharacterAccessToContent(int contentLength) + { + // Arrange + var content = new char[contentLength]; + + for (var i = 0; i < contentLength - 1; i++) + { + content[i] = 'a'; + } + content[contentLength - 1] = 'b'; + var contentString = new string(content); + + var stream = TestRazorSourceDocument.CreateStreamContent(new string(content)); + var reader = new StreamReader(stream, true); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var output = new char[contentLength]; + for (var i = 0; i < document.Length; i++) + { + output[i] = document[i]; + } + var outputString = new string(output); + + // Assert + Assert.Equal(contentLength, document.Length); + Assert.Equal(contentString, outputString); + } + + [Theory] + [InlineData("test.cshtml")] + [InlineData(null)] + public void FilePath(string filePath) + { + // Arrange + var stream = TestRazorSourceDocument.CreateStreamContent("abc"); + var reader = new StreamReader(stream, true); + + // Act + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: filePath, relativePath: null)); + + // Assert + Assert.Equal(filePath, document.FilePath); + } + + [Theory] + [InlineData("test.cshtml")] + [InlineData(null)] + public void RelativePath(string relativePath) + { + // Arrange + var stream = TestRazorSourceDocument.CreateStreamContent("abc"); + var reader = new StreamReader(stream, true); + + // Act + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: relativePath)); + + // Assert + Assert.Equal(relativePath, document.RelativePath); + } + + [Fact] + public void Lines() + { + // Arrange + var stream = TestRazorSourceDocument.CreateStreamContent("abc\ndef\nghi"); + var reader = new StreamReader(stream, true); + + // Act + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Assert + Assert.Equal(3, document.Lines.Count); + } + + [Theory] + [InlineData("", 0, 0, 0)] // Nothing to copy + [InlineData("a", 0, 100, 1)] // Destination index different from start + [InlineData("j", ChunkTestLength - 1, 0, 1)] // One char just before the chunk limit + [InlineData("k", ChunkTestLength, 0, 1)] // One char one the chunk limit + [InlineData("l", ChunkTestLength + 1, 0, 1)] // One char just after the chunk limit + [InlineData("jk", ChunkTestLength - 1, 0, 2)] // Two char that are on both chunk sides + [InlineData("abcdefghijklmnopqrstuvwxy", 0, 100, 25)] // Everything except the last + [InlineData("abcdefghijklmnopqrstuvwxyz", 0, 0, 26)] // Copy all + [InlineData("xyz", 23, 0, 3)] // The last chars + public void CopyTo(string expected, int sourceIndex, int destinationIndex, int count) + { + // Arrange + var stream = TestRazorSourceDocument.CreateStreamContent("abcdefghijklmnopqrstuvwxyz"); + + var reader = new StreamReader(stream, true); + var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var destination = new char[1000]; + document.CopyTo(sourceIndex, destination, destinationIndex, count); + + // Assert + var copy = new string(destination, destinationIndex, count); + Assert.Equal(expected, copy); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/BaselineWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/BaselineWriter.cs new file mode 100644 index 0000000000..eee1a8fd58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/BaselineWriter.cs @@ -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 System.Diagnostics; +using System.IO; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public static class BaselineWriter + { + private static object baselineLock = new object(); + + [Conditional("GENERATE_BASELINES")] + public static void WriteBaseline(string baselineFile, string output) + { + var root = RecursiveFind("Razor.sln", Path.GetFullPath(".")); + var baselinePath = Path.Combine(root, baselineFile); + + // Serialize writes to minimize contention for file handles and directory access. + lock (baselineLock) + { + // Update baseline + using (var stream = File.Open(baselinePath, FileMode.Create, FileAccess.Write)) + { + using (var writer = new StreamWriter(stream)) + { + writer.Write(output); + } + } + } + } + + private static string RecursiveFind(string path, string start) + { + var test = Path.Combine(start, path); + if (File.Exists(test)) + { + return start; + } + else + { + return RecursiveFind(path, new DirectoryInfo(start).Parent.FullName); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpAutoCompleteTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpAutoCompleteTest.cs new file mode 100644 index 0000000000..7e4ae9cf5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpAutoCompleteTest.cs @@ -0,0 +1,53 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpAutoCompleteTest : ParserTestBase + { + [Fact] + public void FunctionsDirectiveAutoCompleteAtEOF() + { + // Arrange, Act & Assert + ParseDocumentTest("@functions{", new[] { FunctionsDirective.Directive }); + } + + [Fact] + public void SectionDirectiveAutoCompleteAtEOF() + { + // Arrange, Act & Assert + ParseDocumentTest("@section Header {", new[] { SectionDirective.Directive }); + } + + [Fact] + public void VerbatimBlockAutoCompleteAtEOF() + { + ParseDocumentTest("@{"); + } + + [Fact] + public void FunctionsDirectiveAutoCompleteAtStartOfFile() + { + // Arrange, Act & Assert + ParseDocumentTest("@functions{" + Environment.NewLine + "foo", new[] { FunctionsDirective.Directive }); + } + + [Fact] + public void SectionDirectiveAutoCompleteAtStartOfFile() + { + // Arrange, Act & Assert + ParseDocumentTest("@section Header {" + Environment.NewLine + "

    Foo

    ", new[] { SectionDirective.Directive }); + } + + [Fact] + public void VerbatimBlockAutoCompleteAtStartOfFile() + { + ParseDocumentTest("@{" + Environment.NewLine + "

    "); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs new file mode 100644 index 0000000000..b6efbe507a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs @@ -0,0 +1,748 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpBlockTest : ParserTestBase + { + [Fact] + public void CSharpBlock_SingleLineControlFlowStatement_Error() + { + ParseDocumentTest( +@"@{ + var time = DateTime.Now; + if (time.ToBinary() % 2 == 0)

    The time: @time

    + + if (time.ToBinary() %3 == 0) + // For some reason we want to render the time now? +

    The confusing time: @time

    + + if (time.ToBinary() % 4 == 0) + @:

    The time: @time

    + + if (time.ToBinary() % 5 == 0) @@SomeGitHubUserName Hi! +}"); + } + + [Fact] + public void CSharpBlock_SingleLineControlFlowStatement() + { + ParseDocumentTest( +@"@{ + var time = DateTime.Now; + if (time.ToBinary() % 2 == 0) @time +}"); + } + + [Fact] + public void LocalFunctionsWithRazor() + { + ParseDocumentTest( +@"@{ + void Foo() + { + var time = DateTime.Now + Hello the time is @time + } +}"); + } + + [Fact] + public void LocalFunctionsWithGenerics() + { + ParseDocumentTest( +@"@{ + void Foo() + { + Hello the time is @{ DisplayCount(new List()); } + } + + void DisplayCount(List something) + { + The count is something.Count + } +}"); + } + + [Fact] + public void NestedCodeBlockWithCSharpAt() + { + ParseDocumentTest("@{ if (true) { var val = @x; if (val != 3) { } } }"); + } + + [Fact] + public void NestedCodeBlockWithMarkupSetsDotAsMarkup() + { + ParseDocumentTest("@if (true) { @if(false) {
    @something.
    } }"); + } + + [Fact] + public void BalancingBracketsIgnoresStringLiteralCharactersAndBrackets() + { + // BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideSingleLineComments + ParseDocumentTest(@"@if(foo) { + // bar } "" baz ' + zoop(); +}"); + } + + [Fact] + public void NestedCodeBlockWithAtDoesntCauseError() + { + ParseDocumentTest("@if (true) { @if(false) { } }"); + } + + [Fact] + public void BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideBlockComments() + { + ParseDocumentTest( + @"@if(foo) { + /* bar } "" */ ' baz } ' + zoop(); +}"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForKeyword + ParseDocumentTest( + "@for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForeachKeyword + ParseDocumentTest( + "@foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsWhileKeyword + ParseDocumentTest( + "@while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsUsingKeywordFollowedByParen + ParseDocumentTest( + "@using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void SupportsUsingsNestedWithinOtherBlocks() + { + ParseDocumentTest( + "@if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches + ParseDocumentTest( + "@if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void AllowsEmptyBlockStatement() + { + ParseDocumentTest("@if(false) { }"); + } + + [Fact] + public void TerminatesParenBalancingAtEOF() + { + ParseDocumentTest("@Html.En(code()"); + } + + [Fact] + public void SupportsBlockCommentBetweenIfAndElseClause() + { + ParseDocumentTest( + "@if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }"); + } + + [Fact] + public void SupportsRazorCommentBetweenIfAndElseClause() + { + RunRazorCommentBetweenClausesTest( + "@if(foo) { bar(); } ", " else { baz(); }"); + } + + [Fact] + public void SupportsBlockCommentBetweenElseIfAndElseClause() + { + ParseDocumentTest( + "@if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }"); + } + + [Fact] + public void SupportsRazorCommentBetweenElseIfAndElseClause() + { + RunRazorCommentBetweenClausesTest( + "@if(foo) { bar(); } else if(bar) { baz(); } ", " else { baz(); }"); + } + + [Fact] + public void SupportsBlockCommentBetweenIfAndElseIfClause() + { + ParseDocumentTest( + "if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }"); + } + + [Fact] + public void SupportsRazorCommentBetweenIfAndElseIfClause() + { + RunRazorCommentBetweenClausesTest("@if(foo) { bar(); } ", " else if(bar) { baz(); }"); + } + + [Fact] + public void SupportsLineCommentBetweenIfAndElseClause() + { + ParseDocumentTest(@"@if(foo) { bar(); } +// Foo +// Bar +else { baz(); }"); + } + + [Fact] + public void SupportsLineCommentBetweenElseIfAndElseClause() + { + ParseDocumentTest(@"@if(foo) { bar(); } else if(bar) { baz(); } +// Foo +// Bar +else { biz(); }"); + } + + [Fact] + public void SupportsLineCommentBetweenIfAndElseIfClause() + { + ParseDocumentTest(@"@if(foo) { bar(); } +// Foo +// Bar +else if(bar) { baz(); }"); + } + + [Fact] + public void ParsesElseIfBranchesOfIfStatement() + { + const string ifStatement = @"@if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""foo } bar""); +}"; + const string elseIfBranch = @" else if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""bar } baz""); +}"; + const string document = ifStatement + elseIfBranch; + + ParseDocumentTest(document); + } + + [Fact] + public void ParsesMultipleElseIfBranchesOfIfStatement() + { + const string ifStatement = @"@if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""foo } bar""); +}"; + const string elseIfBranch = @" else if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""bar } baz""); +}"; + const string document = ifStatement + elseIfBranch + elseIfBranch + elseIfBranch + elseIfBranch; + ParseDocumentTest(document); + } + + [Fact] + public void ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch() + { + const string ifStatement = @"@if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""foo } bar""); +}"; + const string elseIfBranch = @" else if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""bar } baz""); +}"; + const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }"; + const string document = ifStatement + elseIfBranch + elseIfBranch + elseBranch; + + ParseDocumentTest(document); + } + + [Fact] + public void StopsParsingCodeAfterElseBranch() + { + const string ifStatement = @"@if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""foo } bar""); +}"; + const string elseIfBranch = @" else if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""bar } baz""); +}"; + const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }"; + const string document = ifStatement + elseIfBranch + elseBranch + elseIfBranch; + + ParseDocumentTest(document); + } + + [Fact] + public void StopsParsingIfIfStatementNotFollowedByElse() + { + const string document = @"@if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""foo } bar""); +}"; + + ParseDocumentTest(document); + } + + [Fact] + public void AcceptsElseIfWithNoCondition() + { + // We don't want to be a full C# parser - If the else if is missing it's condition, the C# compiler + // can handle that, we have all the info we need to keep parsing + const string ifBranch = @"@if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) { + Debug.WriteLine(@""foo } bar""); +}"; + const string elseIfBranch = @" else if { foo(); }"; + const string document = ifBranch + elseIfBranch; + + ParseDocumentTest(document); + } + + [Fact] + public void CorrectlyParsesDoWhileBlock() + { + ParseDocumentTest( + "@do { var foo = bar; } while(foo != bar);"); + } + + [Fact] + public void CorrectlyParsesDoWhileBlockMissingSemicolon() + { + ParseDocumentTest("@do { var foo = bar; } while(foo != bar)"); + } + + [Fact] + public void CorrectlyParsesDoWhileBlockMissingWhileCondition() + { + ParseDocumentTest("@do { var foo = bar; } while"); + } + + [Fact] + public void CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon() + { + ParseDocumentTest( + "@do { var foo = bar; } while;"); + } + + [Fact] + public void CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely() + { + ParseDocumentTest("@do { var foo = bar; } narf;"); + } + + [Fact] + public void SupportsBlockCommentBetweenDoAndWhileClause() + { + ParseDocumentTest( + "@do { var foo = bar; } /* Foo */ /* Bar */ while(true);"); + } + + [Fact] + public void SupportsLineCommentBetweenDoAndWhileClause() + { + ParseDocumentTest(@"@do { var foo = bar; } +// Foo +// Bar +while(true);"); + } + + [Fact] + public void SupportsRazorCommentBetweenDoAndWhileClause() + { + RunRazorCommentBetweenClausesTest( + "@do { var foo = bar; } ", " while(true);"); + } + + [Fact] + public void CorrectlyParsesMarkupInDoWhileBlock() + { + ParseDocumentTest("@do { var foo = bar;

    Foo

    foo++; } while (foo);"); + } + + [Fact] + public void SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsSwitchKeyword + ParseDocumentTest(@"@switch(foo) { + case 0: + break; + case 1: + { + break; + } + case 2: + return; + default: + return; +}"); + } + + [Fact] + public void ThenBalancesBracesIfFirstIdentifierIsLockKeyword() + { + // ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsLockKeyword + ParseDocumentTest( + "@lock(foo) { Debug.WriteLine(@\"foo } bar\"); }"); + } + + [Fact] + public void HasErrorsIfNamespaceImportMissingSemicolon() + { + ParseDocumentTest( + "@using Foo.Bar.Baz"); + } + + [Fact] + public void HasErrorsIfNamespaceAliasMissingSemicolon() + { + ParseDocumentTest( + "@using Foo.Bar.Baz = FooBarBaz"); + } + + [Fact] + public void ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat() + { + ParseDocumentTest( + "@using Foo.Bar.Baz;"); + } + + [Fact] + public void DoesntCaptureWhitespaceAfterUsing() + { + ParseDocumentTest("@using Foo "); + } + + [Fact] + public void CapturesNewlineAfterUsing() + { + ParseDocumentTest($"@using Foo{Environment.NewLine}"); + } + + [Fact] + public void ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat() + { + ParseDocumentTest( + "@using FooBarBaz = FooBarBaz;"); + } + + [Fact] + public void TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock() + { + ParseDocumentTest("@using "); + } + + [Fact] + public void TerminatesSingleLineCommentAtEndOfFile() + { + const string document = "@foreach(var f in Foo) { // foo bar baz"; + ParseDocumentTest(document); + } + + [Fact] + public void TerminatesBlockCommentAtEndOfFile() + { + const string document = "@foreach(var f in Foo) { /* foo bar baz"; + ParseDocumentTest(document); + } + + [Fact] + public void TerminatesSingleSlashAtEndOfFile() + { + const string document = "@foreach(var f in Foo) { / foo bar baz"; + ParseDocumentTest(document); + } + + [Fact] + public void SupportsBlockCommentBetweenTryAndFinallyClause() + { + ParseDocumentTest("@try { bar(); } /* Foo */ /* Bar */ finally { baz(); }"); + } + + [Fact] + public void SupportsRazorCommentBetweenTryAndFinallyClause() + { + RunRazorCommentBetweenClausesTest("@try { bar(); } ", " finally { biz(); }"); + } + + [Fact] + public void SupportsBlockCommentBetweenCatchAndFinallyClause() + { + ParseDocumentTest( + "@try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }"); + } + + [Fact] + public void SupportsRazorCommentBetweenCatchAndFinallyClause() + { + RunRazorCommentBetweenClausesTest( + "@try { bar(); } catch(bar) { baz(); } ", " finally { biz(); }"); + } + + [Fact] + public void SupportsBlockCommentBetweenTryAndCatchClause() + { + ParseDocumentTest("@try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }"); + } + + [Fact] + public void SupportsRazorCommentBetweenTryAndCatchClause() + { + RunRazorCommentBetweenClausesTest("@try { bar(); }", " catch(bar) { baz(); }"); + } + + [Fact] + public void SupportsLineCommentBetweenTryAndFinallyClause() + { + ParseDocumentTest(@"@try { bar(); } +// Foo +// Bar +finally { baz(); }"); + } + + [Fact] + public void SupportsLineCommentBetweenCatchAndFinallyClause() + { + ParseDocumentTest(@"@try { bar(); } catch(bar) { baz(); } +// Foo +// Bar +finally { biz(); }"); + } + + [Fact] + public void SupportsLineCommentBetweenTryAndCatchClause() + { + ParseDocumentTest(@"@try { bar(); } +// Foo +// Bar +catch(bar) { baz(); }"); + } + + [Fact] + public void SupportsTryStatementWithNoAdditionalClauses() + { + ParseDocumentTest("@try { var foo = new { } }"); + } + + [Fact] + public void SupportsMarkupWithinTryClause() + { + RunSimpleWrappedMarkupTest( + prefix: "@try {", + markup: "

    Foo

    ", + suffix: "}"); + } + + [Fact] + public void SupportsTryStatementWithOneCatchClause() + { + ParseDocumentTest("@try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }"); + } + + [Fact] + public void SupportsMarkupWithinCatchClause() + { + RunSimpleWrappedMarkupTest( + prefix: "@try { var foo = new { } } catch(Foo Bar Baz) {", + markup: "

    Foo

    ", + suffix: "}"); + } + + [Fact] + public void SupportsTryStatementWithMultipleCatchClause() + { + ParseDocumentTest( + "@try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " + + "{ var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }"); + } + + [Fact] + public void SupportsExceptionLessCatchClauses() + { + ParseDocumentTest("@try { var foo = new { } } catch { var foo = new { } }"); + } + + [Fact] + public void SupportsMarkupWithinAdditionalCatchClauses() + { + RunSimpleWrappedMarkupTest( + prefix: "@try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " + + "{ var foo = new { } } catch(Foo Bar Baz) {", + markup: "

    Foo

    ", + suffix: "}"); + } + + [Fact] + public void SupportsTryStatementWithFinallyClause() + { + ParseDocumentTest("@try { var foo = new { } } finally { var foo = new { } }"); + } + + [Fact] + public void SupportsMarkupWithinFinallyClause() + { + RunSimpleWrappedMarkupTest( + prefix: "@try { var foo = new { } } finally {", + markup: "

    Foo

    ", + suffix: "}"); + } + + [Fact] + public void StopsParsingCatchClausesAfterFinallyBlock() + { + var content = "@try { var foo = new { } } finally { var foo = new { } }"; + ParseDocumentTest(content + " catch(Foo Bar Baz) { }"); + } + + [Fact] + public void DoesNotAllowMultipleFinallyBlocks() + { + var content = "@try { var foo = new { } } finally { var foo = new { } }"; + ParseDocumentTest(content + " finally { }"); + } + + [Fact] + public void AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode() + { + // Arrange + ParseDocumentTest("@if(foo) { @foo. }"); + } + + [Fact] + public void ParsesExpressionOnSwitchCharacterFollowedByOpenParen() + { + // Arrange + ParseDocumentTest("@if(foo) { @(foo + bar) }"); + } + + [Fact] + public void ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart() + { + // Arrange + ParseDocumentTest("@if(foo) { @foo[4].bar() }"); + } + + [Fact] + public void TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart() + { + // Arrange + ParseDocumentTest("@if(foo) { @@class.Foo() }"); + } + + [Fact] + public void TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement() + { + // Arrange + ParseDocumentTest("@if(foo) { @@@@class.Foo() }"); + } + + [Fact] + public void DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon() + { + // ParseBlockDoesNotParseMarkupStatementOrExpressionOnSwitchCharacterNotFollowedByOpenAngleOrColon + // Arrange + ParseDocumentTest("@if(foo) { @\"Foo\".ToString(); }"); + } + + [Fact] + public void ParsersCanNestRecursively() + { + // Arrange + ParseDocumentTest("@foreach(var c in db.Categories) {" + Environment.NewLine + + "
    " + Environment.NewLine + + "

    @c.Name

    " + Environment.NewLine + + "
      " + Environment.NewLine + + " @foreach(var p in c.Products) {" + Environment.NewLine + + "
    • @p.Name
    • " + Environment.NewLine + + " }" + Environment.NewLine + + "
    " + Environment.NewLine + + "
    " + Environment.NewLine + + " }"); + } + + [Fact] + public void WithDoubleTransitionInAttributeValue_DoesNotThrow() + { + var input = "@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow() + { + var input = "@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow() + { + var input = "@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransitionBetweenAttributeValue_DoesNotThrow() + { + var input = "@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransitionWithExpressionBlock_DoesNotThrow() + { + var input = "@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransitionInEmail_DoesNotThrow() + { + var input = "@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransitionInRegex_DoesNotThrow() + { + var input = @"@{}"; + ParseDocumentTest(input); + } + + [Fact] + public void WithDoubleTransition_EndOfFile_Throws() + { + ParseDocumentTest("@{}"); + } + + private void RunRazorCommentBetweenClausesTest(string preComment, string postComment, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any) + { + ParseDocumentTest(preComment + "@* Foo *@ @* Bar *@" + postComment); + } + + private void RunSimpleWrappedMarkupTest(string prefix, string markup, string suffix) + { + ParseDocumentTest(prefix + markup + suffix); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpCodeParserTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpCodeParserTest.cs new file mode 100644 index 0000000000..250eff4f40 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpCodeParserTest.cs @@ -0,0 +1,215 @@ +// 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.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy +{ + public class CSharpCodeParserTest + { + public static TheoryData InvalidTagHelperPrefixData + { + get + { + var directiveLocation = new SourceLocation(1, 2, 3); + + RazorDiagnostic InvalidPrefixError(int length, char character, string prefix) + { + return RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, length), SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix); + } + + return new TheoryData> + { + { + "th ", + directiveLocation, + new[] + { + InvalidPrefixError(3, ' ', "th "), + } + }, + { + "th\t", + directiveLocation, + new[] + { + InvalidPrefixError(3, '\t', "th\t"), + } + }, + { + "th" + Environment.NewLine, + directiveLocation, + new[] + { + InvalidPrefixError(2 + Environment.NewLine.Length, Environment.NewLine[0], "th" + Environment.NewLine), + } + }, + { + " th ", + directiveLocation, + new[] + { + InvalidPrefixError(4, ' ', " th "), + } + }, + { + "@", + directiveLocation, + new[] + { + InvalidPrefixError(1, '@', "@"), + } + }, + { + "t@h", + directiveLocation, + new[] + { + InvalidPrefixError(3, '@', "t@h"), + } + }, + { + "!", + directiveLocation, + new[] + { + InvalidPrefixError(1, '!', "!"), + } + }, + { + "!th", + directiveLocation, + new[] + { + InvalidPrefixError(3, '!', "!th"), + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(InvalidTagHelperPrefixData))] + public void ValidateTagHelperPrefix_ValidatesPrefix( + string directiveText, + SourceLocation directiveLocation, + object expectedErrors) + { + // Arrange + var expectedDiagnostics = (IEnumerable)expectedErrors; + var source = TestRazorSourceDocument.Create(); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var parser = new CSharpCodeParser(context); + var diagnostics = new List(); + + // Act + parser.ValidateTagHelperPrefix(directiveText, directiveLocation, diagnostics); + + // Assert + Assert.Equal(expectedDiagnostics, diagnostics); + } + + [Theory] + [InlineData("foo,assemblyName", 4)] + [InlineData("foo, assemblyName", 5)] + [InlineData(" foo, assemblyName", 8)] + [InlineData(" foo , assemblyName", 11)] + [InlineData("foo, assemblyName", 8)] + [InlineData(" foo , assemblyName ", 14)] + public void ParseAddOrRemoveDirective_CalculatesAssemblyLocationInLookupText(string text, int assemblyLocation) + { + // Arrange + var source = TestRazorSourceDocument.Create(); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var parser = new CSharpCodeParser(context); + + var directive = new CSharpCodeParser.ParsedDirective() + { + DirectiveText = text, + }; + + var diagnostics = new List(); + var expected = new SourceLocation(assemblyLocation, 0, assemblyLocation); + + // Act + var result = parser.ParseAddOrRemoveDirective(directive, SourceLocation.Zero, diagnostics); + + // Assert + Assert.Empty(diagnostics); + Assert.Equal("foo", result.TypePattern); + Assert.Equal("assemblyName", result.AssemblyName); + } + + [Theory] + [InlineData("", 1)] + [InlineData("*,", 2)] + [InlineData("?,", 2)] + [InlineData(",", 1)] + [InlineData(",,,", 3)] + [InlineData("First, ", 7)] + [InlineData("First , ", 8)] + [InlineData(" ,Second", 8)] + [InlineData(" , Second", 9)] + [InlineData("SomeType,", 9)] + [InlineData("SomeAssembly", 12)] + [InlineData("First,Second,Third", 18)] + public void ParseAddOrRemoveDirective_CreatesErrorIfInvalidLookupText_DoesNotThrow(string directiveText, int errorLength) + { + // Arrange + var source = TestRazorSourceDocument.Create(); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var parser = new CSharpCodeParser(context); + + var directive = new CSharpCodeParser.ParsedDirective() + { + DirectiveText = directiveText + }; + + var diagnostics = new List(); + var expectedError = RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(1, 2, 3), errorLength), directiveText); + + // Act + var result = parser.ParseAddOrRemoveDirective(directive, new SourceLocation(1, 2, 3), diagnostics); + + // Assert + Assert.Same(directive, result); + + var error = Assert.Single(diagnostics); + Assert.Equal(expectedError, error); + } + + [Fact] + public void TagHelperPrefixDirective_DuplicatesCauseError() + { + // Arrange + var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix"); + var source = TestRazorSourceDocument.Create( + @"@tagHelperPrefix ""th:"" +@tagHelperPrefix ""th""", + filePath: null); + + // Act + var document = RazorSyntaxTree.Parse(source); + + // Assert + var erroredNode = document.Root.DescendantNodes().Last(n => n.GetSpanContext()?.ChunkGenerator is TagHelperPrefixDirectiveChunkGenerator); + var chunkGenerator = Assert.IsType(erroredNode.GetSpanContext().ChunkGenerator); + var diagnostic = Assert.Single(chunkGenerator.Diagnostics); + Assert.Equal(expectedDiagnostic, diagnostic); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpErrorTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpErrorTest.cs new file mode 100644 index 0000000000..bc3284ee23 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpErrorTest.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpErrorTest : ParserTestBase + { + [Fact] + public void HandlesQuotesAfterTransition() + { + ParseDocumentTest("@\""); + } + + [Fact] + public void WithHelperDirectiveProducesError() + { + ParseDocumentTest("@helper fooHelper { }"); + } + + [Fact] + public void WithNestedCodeBlockProducesError() + { + ParseDocumentTest("@if { @{} }"); + } + + [Fact] + public void CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode() + { + // ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode + ParseDocumentTest( + "@using " + Environment.NewLine + Environment.NewLine); + } + + [Fact] + public void MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace() + { + ParseDocumentTest("@{"); + } + + [Fact] + public void MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void MethodProducesErrorIfNewlineFollowsTransition() + { + ParseDocumentTest("@" + Environment.NewLine); + } + + [Fact] + public void MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr() + { + // ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression + ParseDocumentTest("@{" + Environment.NewLine + + " @ {}" + Environment.NewLine + + "}"); + } + + [Fact] + public void MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression() + { + ParseDocumentTest("@{" + Environment.NewLine + + " @"); + } + + [Fact] + public void MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace() + { + ParseDocumentTest("@!!!"); + } + + [Fact] + public void ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed() + { + // ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed + ParseDocumentTest("@(foo bar" + Environment.NewLine + + "baz"); + } + + [Fact] + public void ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed() + { + // ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed + ParseDocumentTest("@(foo bar" + Environment.NewLine + + "" + Environment.NewLine + + "baz" + Environment.NewLine + + "@Html.Foo(Bar);" + Environment.NewLine); + } + + [Fact] + // Test for fix to Dev10 884975 - Incorrect Error Messaging + public void ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed() + { + // ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed + ParseDocumentTest("@Foo(Bar(Baz)" + Environment.NewLine + + "Biz" + Environment.NewLine + + "Boz"); + } + + [Fact] + // Test for fix to Dev10 884975 - Incorrect Error Messaging + public void ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed() + { + // ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed + ParseDocumentTest("@Foo(Bar(Baz)" + Environment.NewLine + + "Biz" + Environment.NewLine + + "" + Environment.NewLine + + "Boz" + Environment.NewLine + + ""); + } + + [Fact] + // Test for fix to Dev10 884975 - Incorrect Error Messaging + public void ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed() + { + // ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed + ParseDocumentTest("@Foo[Bar[Baz]" + Environment.NewLine + + "Biz" + Environment.NewLine + + "Boz"); + } + + [Fact] + // Test for fix to Dev10 884975 - Incorrect Error Messaging + public void ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed() + { + // ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed + ParseDocumentTest("@Foo[Bar[Baz]" + Environment.NewLine + + "Biz" + Environment.NewLine + + "" + Environment.NewLine + + "Boz" + Environment.NewLine + + ""); + } + + // Simple EOF handling errors: + [Fact] + public void ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF() + { + ParseDocumentTest("@{ var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfClassBlockUnterminatedAtEOF() + { + ParseDocumentTest( + "@functions { var foo = bar; if(foo != null) { bar(); } ", + new[] { FunctionsDirective.Directive }); + } + + [Fact] + public void ReportsErrorIfIfBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@if"); + } + + [Fact] + public void ReportsErrorIfElseBlockUnterminatedAtEOF() + { + ParseDocumentTest("@if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfElseIfBlockUnterminatedAtEOF() + { + ParseDocumentTest("@if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfDoBlockUnterminatedAtEOF() + { + ParseDocumentTest("@do { var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfTryBlockUnterminatedAtEOF() + { + ParseDocumentTest("@try { var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfCatchBlockUnterminatedAtEOF() + { + ParseDocumentTest("@try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfFinallyBlockUnterminatedAtEOF() + { + ParseDocumentTest("@try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } "); + } + + [Fact] + public void ReportsErrorIfForBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@for"); + } + + [Fact] + public void ReportsErrorIfForeachBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@foreach"); + } + + [Fact] + public void ReportsErrorIfWhileBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@while"); + } + + [Fact] + public void ReportsErrorIfSwitchBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@switch"); + } + + [Fact] + public void ReportsErrorIfLockBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@lock"); + } + + [Fact] + public void ReportsErrorIfUsingBlockUnterminatedAtEOF() + { + RunUnterminatedSimpleKeywordBlock("@using"); + } + + [Fact] + public void RequiresControlFlowStatementsToHaveBraces() + { + ParseDocumentTest("@if(foo)

    Bar

    else if(bar)

    Baz

    else

    Boz

    "); + } + + [Fact] + public void IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError() + { + ParseDocumentTest("@if(foo)) { var bar = foo; }"); + } + + [Fact] + public void OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart() + { + ParseDocumentTest("@if(foo) { @

    Bar

    }"); + } + + [Fact] + public void TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen() + { + ParseDocumentTest("@if(foo bar" + Environment.NewLine + + "baz"); + } + + [Fact] + public void TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen() + { + ParseDocumentTest("@foreach(foo bar" + Environment.NewLine + + "baz"); + } + + [Fact] + public void TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen() + { + ParseDocumentTest("@do { } while(foo bar" + Environment.NewLine + + "baz"); + } + + [Fact] + public void TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen() + { + ParseDocumentTest("@using(foo bar" + Environment.NewLine + + "baz"); + } + + [Fact] + public void ResumesIfStatementAfterOpenParen() + { + ParseDocumentTest("@if(" + Environment.NewLine + + "else {

    Foo

    }"); + } + + [Fact] + public void TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing() + { + ParseDocumentTest("@if(foo) {" + Environment.NewLine + + " var p = \"foo bar baz" + Environment.NewLine + + ";" + Environment.NewLine + + "}"); + } + + [Fact] + public void TerminatesNormalStringAtEndOfFile() + { + ParseDocumentTest("@if(foo) { var foo = \"blah blah blah blah blah"); + } + + [Fact] + public void TerminatesVerbatimStringAtEndOfFile() + { + ParseDocumentTest("@if(foo) { var foo = @\"blah " + Environment.NewLine + + "blah; " + Environment.NewLine + + "

    Foo

    " + Environment.NewLine + + "blah " + Environment.NewLine + + "blah"); + } + + [Fact] + public void CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement() + { + ParseDocumentTest("@if(foo) {" + Environment.NewLine + + " var foo = \"foo bar baz" + Environment.NewLine + + "

    Foo is @foo

    " + Environment.NewLine + + "}"); + } + + [Fact] + public void CorrectlyParsesAtSignInDelimitedBlock() + { + ParseDocumentTest("@(Request[\"description\"] ?? @photo.Description)"); + } + + [Fact] + public void CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode() + { + ParseDocumentTest("@{string.Format(}"); + } + + private void RunUnterminatedSimpleKeywordBlock(string keyword) + { + ParseDocumentTest( + keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } "); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs new file mode 100644 index 0000000000..fdb782cf69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs @@ -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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpExplicitExpressionTest : ParserTestBase + { + [Fact] + public void ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty() + { + ParseDocumentTest("@()"); + } + + [Fact] + public void ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr() + { + // ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression + ParseDocumentTest("@("); + } + + [Fact] + public void ShouldAcceptEscapedQuoteInNonVerbatimStrings() + { + ParseDocumentTest("@(\"\\\"\")"); + } + + [Fact] + public void ShouldAcceptEscapedQuoteInVerbatimStrings() + { + ParseDocumentTest("@(@\"\"\"\")"); + } + + [Fact] + public void ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings() + { + ParseDocumentTest("@(@\"\"\"\"\"\")"); + } + + [Fact] + public void ShouldAcceptMultiLineVerbatimStrings() + { + ParseDocumentTest(@"@(@""" + Environment.NewLine + + @"Foo" + Environment.NewLine + + @"Bar" + Environment.NewLine + + @"Baz" + Environment.NewLine + + @""")"); + } + + [Fact] + public void ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings() + { + ParseDocumentTest("@(\"\\\"hello, world\\\"\")"); + } + + [Fact] + public void ShouldAcceptMultipleEscapedQuotesInVerbatimStrings() + { + ParseDocumentTest("@(@\"\"\"hello, world\"\"\")"); + } + + [Fact] + public void ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings() + { + ParseDocumentTest("@(\"\\\"\\\"\")"); + } + + [Fact] + public void ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings() + { + ParseDocumentTest("@(@\"\"\"\"\"\")"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs new file mode 100644 index 0000000000..f50d91b295 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpFunctionsTest.cs @@ -0,0 +1,175 @@ +// 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.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpFunctionsTest : ParserTestBase + { + [Fact] + public void Functions_SingleLineControlFlowStatement_Error() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + string GetAnnouncmentText(string message) + { + if (message.Length > 0)

    Message: @message

    + + if (message == null) + // Nothing to render +

    Message was null

    + + if (DateTime.Now.ToBinary() % 2 == 0) + @:

    The time: @time

    + + if (message != null) @@SomeGitHubUserName @message + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void Functions_SingleLineControlFlowStatement() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + string GetAnnouncmentText(string message) + { + if (message.Length > 0) return ""Anouncement: "" + message; + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void MarkupInFunctionsBlock_DoesNotParseWhenNotSupported() + { + ParseDocumentTest( + RazorLanguageVersion.Version_2_1, + @" +@functions { + void Announcment(string message) + { +

    @message

    + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void MarkupInFunctionsBlock_ParsesMarkupInsideMethod() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + void Announcment(string message) + { +

    @message

    + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + // This will parse correctly in Razor, but will generate invalid C#. + [Fact] + public void MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + void Announcment(string message) =>

    @message

    +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void MarkupInFunctionsBlock_DoesNotParseMarkupInString() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + void Announcment(string message) => ""

    @message

    ""; +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + void Announcment(string message) => @""

    @message

    ""; +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void MarkupInFunctionsBlock_CanContainCurlyBraces() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + void Announcment(string message) + { +
    + @if (message.Length > 0) + { +

    @message.Length

    + } +
    + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void MarkupInFunctionsBlock_MarkupCanContainTemplate() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + void Announcment(string message) + { +
    + @if (message.Length > 0) + { + Repeat(@

    @message.Length

    ); + } +
    + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + + [Fact] + public void ReservedKeywordsInFunctionsBlock_WithMarkup() + { + ParseDocumentTest( + RazorLanguageVersion.Version_3_0, + @" +@functions { + class Person + { + public void DoSomething() + { +

    Just do it!

    + } + } +} +", new[] { FunctionsDirective.Directive, }, designTime: false); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpImplicitExpressionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpImplicitExpressionTest.cs new file mode 100644 index 0000000000..4fdcc42df0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpImplicitExpressionTest.cs @@ -0,0 +1,564 @@ +// 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.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpImplicitExpressionTest : ParserTestBase + { + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket1() + { + // Act & Assert + ParseDocumentTest("@val??["); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket2() + { + // Act & Assert + ParseDocumentTest("@val??[0"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket3() + { + // Act & Assert + ParseDocumentTest("@val?["); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket4() + { + // Act & Assert + ParseDocumentTest("@val?("); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket5() + { + // Act & Assert + ParseDocumentTest("@val?[more"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket6() + { + // Act & Assert + ParseDocumentTest("@val?[0]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket7() + { + // Act & Assert + ParseDocumentTest("@val?[

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket8() + { + // Act & Assert + ParseDocumentTest("@val?[more.

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket9() + { + // Act & Assert + ParseDocumentTest("@val??[more

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket10() + { + // Act & Assert + ParseDocumentTest("@val?[-1]?"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket11() + { + // Act & Assert + ParseDocumentTest("@val?[abc]?[def"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket12() + { + // Act & Assert + ParseDocumentTest("@val?[abc]?[2]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket13() + { + // Act & Assert + ParseDocumentTest("@val?[abc]?.more?[def]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket14() + { + // Act & Assert + ParseDocumentTest("@val?[abc]?.more?.abc"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket15() + { + // Act & Assert + ParseDocumentTest("@val?[null ?? true]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Bracket16() + { + // Act & Assert + ParseDocumentTest("@val?[abc?.gef?[-1]]"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot1() + { + // Act & Assert + ParseDocumentTest("@val?"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot2() + { + // Act & Assert + ParseDocumentTest("@val??"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot3() + { + // Act & Assert + ParseDocumentTest("@val??more"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot4() + { + // Act & Assert + ParseDocumentTest("@val?!"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot5() + { + // Act & Assert + ParseDocumentTest("@val?."); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot6() + { + // Act & Assert + ParseDocumentTest("@val??."); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot7() + { + // Act & Assert + ParseDocumentTest("@val?.(abc)"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot8() + { + // Act & Assert + ParseDocumentTest("@val?.

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot9() + { + // Act & Assert + ParseDocumentTest("@val?.more"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot10() + { + // Act & Assert + ParseDocumentTest("@val?.more

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot11() + { + // Act & Assert + ParseDocumentTest("@val??.more

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot12() + { + // Act & Assert + ParseDocumentTest("@val?.more(false)?.

    "); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot13() + { + // Act & Assert + ParseDocumentTest("@val?.more(false)?.abc"); + } + + [Fact] + public void ParsesNullConditionalOperatorImplicitExpression_Dot14() + { + // Act & Assert + ParseDocumentTest("@val?.more(null ?? true)?.abc"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock() + { + // Act & Assert + ParseDocumentTest("@{ @val!.Name![0]!?.Bar }"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock() + { + // Act & Assert + ParseDocumentTest("@functions { public void Foo() { @Model!.Name![0]!?.Bar } }", new[] { FunctionsDirective.Directive }); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket() + { + // Act & Assert + ParseDocumentTest("@val!!["); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket() + { + // Act & Assert + ParseDocumentTest("@val!["); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis() + { + // Act & Assert + ParseDocumentTest("@val!("); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier() + { + // Act & Assert + ParseDocumentTest("@val![more"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Brackets() + { + // Act & Assert + ParseDocumentTest("@val![0]"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml() + { + // Act & Assert + ParseDocumentTest("@val![

    "); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket() + { + // Act & Assert + ParseDocumentTest("@val![more.

    "); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional() + { + // Act & Assert + ParseDocumentTest("@val?![more

    "); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_SingleOperator() + { + // Act & Assert + ParseDocumentTest("@val![-1]!"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete() + { + // Act & Assert + ParseDocumentTest("@val![abc]![def"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Multiple() + { + // Act & Assert + ParseDocumentTest("@val![abc]![2]"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed() + { + // Act & Assert + ParseDocumentTest("@val![abc]!.more![def]"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2() + { + // Act & Assert + ParseDocumentTest("@val![abc]!.more!.abc"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Bracket15() + { + // Act & Assert + ParseDocumentTest("@val![null! ?? true]"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Nested() + { + // Act & Assert + ParseDocumentTest("@val![abc!.gef![-1]]"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Ending() + { + // Act & Assert + ParseDocumentTest("@val!"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional() + { + // Act & Assert + ParseDocumentTest("@val!?"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Combined() + { + // Act & Assert + ParseDocumentTest("@val!?.more"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator() + { + // Act & Assert + ParseDocumentTest("@val!."); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding() + { + // Act & Assert + ParseDocumentTest("@val!?."); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding() + { + // Act & Assert + ParseDocumentTest("@val!.(abc)"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml() + { + // Act & Assert + ParseDocumentTest("@val!.

    "); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_FullExpression() + { + // Act & Assert + ParseDocumentTest("@val!.more"); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml() + { + // Act & Assert + ParseDocumentTest("@val!.more

    "); + } + + [Fact] + public void ParsesNullForgivenessOperatorImplicitExpression_Complex() + { + // Act & Assert + ParseDocumentTest("@val!.more(false)!.

    "); + } + + [Fact] + public void NestedImplicitExpression() + { + ParseDocumentTest("if (true) { @foo }"); + } + + [Fact] + public void AcceptsNonEnglishCharactersThatAreValidIdentifiers() + { + ParseDocumentTest("@हळूँजद॔."); + } + + [Fact] + public void OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition() + { + ParseDocumentTest("@/"); + } + + [Fact] + public void OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition() + { + ParseDocumentTest("@"); + } + + [Fact] + public void SupportsSlashesWithinComplexImplicitExpressions() + { + ParseDocumentTest("@DataGridColumn.Template(\"Years of Service\", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))"); + } + + [Fact] + public void ParsesSingleIdentifierAsImplicitExpression() + { + ParseDocumentTest("@foo"); + } + + [Fact] + public void DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace() + { + ParseDocumentTest("@foo ;"); + } + + [Fact] + public void IgnoresSemicolonAtEndOfSimpleImplicitExpression() + { + ParseDocumentTest("@foo;"); + } + + [Fact] + public void ParsesDottedIdentifiersAsImplicitExpression() + { + ParseDocumentTest("@foo.bar.baz"); + } + + [Fact] + public void IgnoresSemicolonAtEndOfDottedIdentifiers() + { + ParseDocumentTest("@foo.bar.baz;"); + } + + [Fact] + public void DoesNotIncludeDotAtEOFInImplicitExpression() + { + ParseDocumentTest("@foo.bar."); + } + + [Fact] + public void DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1() + { + // ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression1 + ParseDocumentTest("@foo.bar.0"); + } + + [Fact] + public void DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2() + { + // ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression2 + ParseDocumentTest("@foo.bar.

    "); + } + + [Fact] + public void DoesNotIncludeSemicolonAfterDot() + { + ParseDocumentTest("@foo.bar.;"); + } + + [Fact] + public void TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr() + { + // ParseBlockMethodTerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpression + ParseDocumentTest("@foo.bar

    "); + } + + [Fact] + public void ProperlyParsesParenthesesAndBalancesThemInImplicitExpression() + { + ParseDocumentTest(@"@foo().bar(""bi\""z"", 4)(""chained method; call"").baz(@""bo""""z"", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))"); + } + + [Fact] + public void ProperlyParsesBracketsAndBalancesThemInImplicitExpression() + { + ParseDocumentTest(@"@foo.bar[4 * (8 + 7)][""fo\""o""].baz"); + } + + [Fact] + public void TerminatesImplicitExpressionAtHtmlEndTag() + { + ParseDocumentTest("@foo().bar.baz

    zoop"); + } + + [Fact] + public void TerminatesImplicitExpressionAtHtmlStartTag() + { + ParseDocumentTest("@foo().bar.baz

    zoop"); + } + + [Fact] + public void TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar() + { + // ParseBlockTerminatesImplicitExpressionBeforeDotIfDotNotFollowedByIdentifierStartCharacter + ParseDocumentTest("@foo().bar.baz.42"); + } + + [Fact] + public void StopsBalancingParenthesesAtEOF() + { + ParseDocumentTest("@foo(()"); + } + + [Fact] + public void TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace() + { + ParseDocumentTest("@foo.bar() (baz)"); + } + + [Fact] + public void TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace() + { + ParseDocumentTest("@foo .bar() (baz)"); + } + + [Fact] + public void TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace() + { + ParseDocumentTest("@foo. bar() (baz)"); + } + + [Fact] + public void OutputExpressionIfModuleTokenNotFollowedByBrace() + { + ParseDocumentTest("@module.foo()"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpLanguageCharacteristicsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpLanguageCharacteristicsTest.cs new file mode 100644 index 0000000000..84802523b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpLanguageCharacteristicsTest.cs @@ -0,0 +1,20 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpLanguageCharacteristicsTest + { + [Fact] + public void GetSample_RightShiftAssign_ReturnsCorrectToken() + { + // Arrange & Act + var token = CSharpLanguageCharacteristics.Instance.GetSample(SyntaxKind.RightShiftAssign); + + // Assert + Assert.Equal(">>=", token); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpNestedStatementsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpNestedStatementsTest.cs new file mode 100644 index 0000000000..613cdca2a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpNestedStatementsTest.cs @@ -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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpNestedStatementsTest : ParserTestBase + { + [Fact] + public void NestedSimpleStatement() + { + ParseDocumentTest("@while(true) { foo(); }"); + } + + [Fact] + public void NestedKeywordStatement() + { + ParseDocumentTest("@while(true) { for(int i = 0; i < 10; i++) { foo(); } }"); + } + + [Fact] + public void NestedCodeBlock() + { + ParseDocumentTest("@while(true) { { { { foo(); } } } }"); + } + + [Fact] + public void NestedImplicitExpression() + { + ParseDocumentTest("@while(true) { @foo }"); + } + + [Fact] + public void NestedExplicitExpression() + { + ParseDocumentTest("@while(true) { @(foo) }"); + } + + [Fact] + public void NestedMarkupBlock() + { + ParseDocumentTest("@while(true) {

    Hello

    }"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpRazorCommentsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpRazorCommentsTest.cs new file mode 100644 index 0000000000..55d3edf1e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpRazorCommentsTest.cs @@ -0,0 +1,134 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpRazorCommentsTest : ParserTestBase + { + [Fact] + public void UnterminatedRazorComment() + { + ParseDocumentTest("@*"); + } + + [Fact] + public void EmptyRazorComment() + { + ParseDocumentTest("@**@"); + } + + [Fact] + public void RazorCommentInImplicitExpressionMethodCall() + { + ParseDocumentTest("@foo(" + Environment.NewLine + + "@**@" + Environment.NewLine); + } + + [Fact] + public void UnterminatedRazorCommentInImplicitExpressionMethodCall() + { + ParseDocumentTest("@foo(@*"); + } + + [Fact] + public void RazorMultilineCommentInBlock() + { + ParseDocumentTest(@" +@{ + @* +This is a comment + *@ +} +"); + } + + [Fact] + public void RazorCommentInVerbatimBlock() + { + ParseDocumentTest("@{" + Environment.NewLine + + " "); + } + + [Fact] + public void RazorCommentInClosingTagBlock() + { + ParseDocumentTest(""); + } + + [Fact] + public void UnterminatedRazorCommentInVerbatimBlock() + { + ParseDocumentTest("@{@*"); + } + + [Fact] + public void RazorCommentInMarkup() + { + ParseDocumentTest( + "

    " + Environment.NewLine + + "@**@" + Environment.NewLine + + "

    "); + } + + [Fact] + public void MultipleRazorCommentInMarkup() + { + ParseDocumentTest( + "

    " + Environment.NewLine + + " @**@ " + Environment.NewLine + + "@**@" + Environment.NewLine + + "

    "); + } + + [Fact] + public void MultipleRazorCommentsInSameLineInMarkup() + { + ParseDocumentTest( + "

    " + Environment.NewLine + + "@**@ @**@" + Environment.NewLine + + "

    "); + } + + [Fact] + public void RazorCommentsSurroundingMarkup() + { + ParseDocumentTest( + "

    " + Environment.NewLine + + "@* hello *@ content @* world *@" + Environment.NewLine + + "

    "); + } + + [Fact] + public void RazorCommentBetweenCodeBlockAndMarkup() + { + ParseDocumentTest( + "@{ }" + Environment.NewLine + + "@* Hello World *@" + Environment.NewLine + + "
    Foo
    " + ); + } + + [Fact] + public void RazorCommentWithExtraNewLineInMarkup() + { + ParseDocumentTest( + "

    " + Environment.NewLine + Environment.NewLine + + "@* content *@" + Environment.NewLine + + "@*" + Environment.NewLine + + "content" + Environment.NewLine + + "*@" + Environment.NewLine + Environment.NewLine + + "

    "); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpReservedWordsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpReservedWordsTest.cs new file mode 100644 index 0000000000..9132524166 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpReservedWordsTest.cs @@ -0,0 +1,22 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpReservedWordsTest : ParserTestBase + { + [Fact] + public void ReservedWord() + { + ParseDocumentTest("@namespace"); + } + + [Fact] + private void ReservedWordIsCaseSensitive() + { + ParseDocumentTest("@NameSpace"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpSectionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpSectionTest.cs new file mode 100644 index 0000000000..517dd4a83d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpSectionTest.cs @@ -0,0 +1,290 @@ +// 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.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpSectionTest : ParserTestBase + { + [Fact] + public void CapturesNewlineImmediatelyFollowing() + { + ParseDocumentTest( + "@section" + Environment.NewLine, + new[] { SectionDirective.Directive }); + } + + [Fact] + public void CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace() + { + ParseDocumentTest( + "@section Foo " + Environment.NewLine + " ", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void CapturesWhitespaceToEndOfLineInSectionStatementMissingName() + { + ParseDocumentTest( + "@section " + Environment.NewLine + " ", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void IgnoresSectionUnlessAllLowerCase() + { + ParseDocumentTest( + "@Section foo", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar() + { + // ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartCharacter + ParseDocumentTest( + "@section 9 {

    Foo

    }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace() + { + // ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace + ParseDocumentTest( + "@section foo-bar {

    Foo

    }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ParserOutputsErrorOnNestedSections() + { + ParseDocumentTest( + "@section foo { @section bar {

    Foo

    } }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ParserOutputsErrorOnMultipleNestedSections() + { + ParseDocumentTest( + "@section foo { @section bar {

    Foo

    @section baz { } } }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ParserDoesNotOutputErrorOtherNestedDirectives() + { + // This isn't a real scenario but we just want to verify we don't show misleading errors. + ParseDocumentTest( + "@section foo { @inherits Bar }", + new[] { SectionDirective.Directive, InheritsDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenBrace() + { + ParseDocumentTest( + "@section foo {", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenContent1() + { + + ParseDocumentTest( + "@section foo { ", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenContent2() + { + + ParseDocumentTest( + "@section foo {\n", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenContent3() + { + + ParseDocumentTest( + "@section foo {abc", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesEOFAfterOpenContent4() + { + + ParseDocumentTest( + "@section foo {\n abc", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesUnterminatedSection() + { + ParseDocumentTest( + "@section foo {

    Foo{}

    ", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void HandlesUnterminatedSectionWithNestedIf() + { + // Arrange + var newLine = Environment.NewLine; + var spaces = " "; + + // Act & Assert + ParseDocumentTest( + string.Format( + "@section Test{0}{{{0}{1}@if(true){0}{1}{{{0}{1}{1}

    Hello World

    {0}{1}}}", + newLine, + spaces), + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace() + { + // ParseSectionBlockReportsErrorAndAcceptsWhitespaceToEndOfLineIfSectionNotFollowedByOpenBrace + ParseDocumentTest( + "@section foo " + Environment.NewLine, + new[] { SectionDirective.Directive }); + } + + [Fact] + public void AcceptsOpenBraceMultipleLinesBelowSectionName() + { + ParseDocumentTest( + "@section foo " + + Environment.NewLine + + Environment.NewLine + + Environment.NewLine + + Environment.NewLine + + Environment.NewLine + + Environment.NewLine + + "{" + Environment.NewLine + + "

    Foo

    " + Environment.NewLine + + "}", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ParsesNamedSectionCorrectly() + { + ParseDocumentTest( + "@section foo {

    Foo

    }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void DoesNotRequireSpaceBetweenSectionNameAndOpenBrace() + { + ParseDocumentTest( + "@section foo{

    Foo

    }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void BalancesBraces() + { + ParseDocumentTest( + "@section foo { }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void AllowsBracesInCSharpExpression() + { + ParseDocumentTest( + "@section foo { I really want to render a close brace, so here I go: @(\"}\") }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock() + { + ParseDocumentTest( + "@section Foo {" + Environment.NewLine + + "@if(true) {" + Environment.NewLine + + "}" + Environment.NewLine + + "}", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace() + { + // SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlockNoWhitespace + ParseDocumentTest( + "@section Foo {" + Environment.NewLine + + "@if(true) {" + Environment.NewLine + + "}}", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup() + { + ParseDocumentTest( + "@section foo {something}", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ParsesComment() + { + ParseDocumentTest( + "@section s {}", + new[] { SectionDirective.Directive }); + } + + // This was a user reported bug (codeplex #710), the section parser wasn't handling + // comments. + [Fact] + public void ParsesCommentWithDelimiters() + { + ParseDocumentTest( + "@section s {}", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void CommentRecoversFromUnclosedTag() + { + ParseDocumentTest( + "@section s {" + Environment.NewLine + " \" '-->}", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void ParsesXmlProcessingInstruction() + { + ParseDocumentTest( + "@section s { }", + new[] { SectionDirective.Directive }); + } + + [Fact] + public void _WithDoubleTransition1() + { + ParseDocumentTest("@section s {}", new[] { SectionDirective.Directive }); + } + + [Fact] + public void _WithDoubleTransition2() + { + ParseDocumentTest("@section s {}", new[] { SectionDirective.Directive }); + } + + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpSpecialBlockTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpSpecialBlockTest.cs new file mode 100644 index 0000000000..d18b24759e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpSpecialBlockTest.cs @@ -0,0 +1,50 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpSpecialBlockTest : ParserTestBase + { + [Fact] + public void NonKeywordStatementInCodeBlockIsHandledCorrectly() + { + ParseDocumentTest( +@"@{ + List photos = gallery.Photo.ToList(); +}"); + } + + [Fact] + public void BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode() + { + // ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode + ParseDocumentTest("@{foo\"b}ar\" if(condition) { string.Format(\"{0}\"); } }"); + } + + [Fact] + public void BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr() + { + // ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression + ParseDocumentTest("@(foo\"b)ar\" if(condition) { string.Format(\"{0}\"); } )"); + } + + [Fact] + public void ParseBlockIgnoresSingleSlashAtStart() + { + ParseDocumentTest("@/ foo"); + } + + [Fact] + public void ParseBlockTerminatesSingleLineCommentAtEndOfLine() + { + ParseDocumentTest( +"@if(!false) {" + Environment.NewLine + +" // Foo" + Environment.NewLine + +"\t

    A real tag!

    " + Environment.NewLine + +"}"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpStatementTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpStatementTest.cs new file mode 100644 index 0000000000..a8da56d6a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpStatementTest.cs @@ -0,0 +1,247 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + // Basic Tests for C# Statements: + // * Basic case for each statement + // * Basic case for ALL clauses + + // This class DOES NOT contain + // * Error cases + // * Tests for various types of nested statements + // * Comment tests + + public class CSharpStatementTest : ParserTestBase + { + [Fact] + public void ForStatement() + { + ParseDocumentTest("@for(int i = 0; i++; i < length) { foo(); }"); + } + + [Fact] + public void ForEachStatement() + { + ParseDocumentTest("@foreach(var foo in bar) { foo(); }"); + } + + [Fact] + public void AwaitForEachStatement() + { + ParseDocumentTest("@await foreach(var foo in bar) { foo(); }"); + } + + [Fact] + public void MalformedAwaitForEachStatement() + { + ParseDocumentTest("@await foreach(var foo in bar { foo(); "); + } + + [Fact] + public void WhileStatement() + { + ParseDocumentTest("@while(true) { foo(); }"); + } + + [Fact] + public void SwitchStatement() + { + ParseDocumentTest("@switch(foo) { foo(); }"); + } + + [Fact] + public void LockStatement() + { + ParseDocumentTest("@lock(baz) { foo(); }"); + } + + [Fact] + public void IfStatement() + { + ParseDocumentTest("@if(true) { foo(); }"); + } + + [Fact] + public void ElseIfClause() + { + ParseDocumentTest("@if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }"); + } + + [Fact] + public void ElseClause() + { + ParseDocumentTest("@if(true) { foo(); } else { foo(); }"); + } + + [Fact] + public void TryStatement() + { + ParseDocumentTest("@try { foo(); }"); + } + + [Fact] + public void CatchClause() + { + ParseDocumentTest("@try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }"); + } + + [Fact] + public void ExceptionFilter_TryCatchWhenComplete_SingleLine() + { + ParseDocumentTest("@try { someMethod(); } catch(Exception) when (true) { handleIO(); }"); + } + + [Fact] + public void ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine() + { + ParseDocumentTest("@try { A(); } catch(Exception) when (true) { B(); } finally { C(); }"); + } + + [Fact] + public void ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine() + { + ParseDocumentTest("@try { A(); } catch(Exception) when (true) { B(); } catch(IOException) when (false) { C(); }"); + } + + [Fact] + public void ExceptionFilter_MultiLine() + { + ParseDocumentTest( +@"@try +{ +A(); +} +catch(Exception) when (true) +{ +B(); +} +catch(IOException) when (false) +{ +C(); +}"); + } + + [Fact] + public void ExceptionFilter_NestedTryCatchWhen() + { + ParseDocumentTest("@{try { someMethod(); } catch(Exception) when (true) { handleIO(); }}"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryCatchWhen() + { + ParseDocumentTest("@try { someMethod(); } catch(Exception) when"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryWhen() + { + ParseDocumentTest("@try { someMethod(); } when"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryCatchNoBodyWhen() + { + ParseDocumentTest("@try { someMethod(); } catch(Exception) when { anotherMethod(); }"); + } + + [Fact] + public void ExceptionFilter_IncompleteTryCatchWhenNoBodies() + { + ParseDocumentTest("@try { someMethod(); } catch(Exception) when (true)"); + } + + [Fact] + public void ExceptionFilterError_TryCatchWhen_InCompleteCondition() + { + ParseDocumentTest("@try { someMethod(); } catch(Exception) when ("); + } + + [Fact] + public void ExceptionFilterError_TryCatchWhen_InCompleteBody() + { + ParseDocumentTest("@try { someMethod(); } catch(Exception) when (true) {"); + } + + [Fact] + public void FinallyClause() + { + ParseDocumentTest("@try { foo(); } finally { Dispose(); }"); + } + + [Fact] + public void Using_VariableDeclaration_Simple() + { + ParseDocumentTest("@{ using var foo = someDisposable; }"); + } + + [Fact] + public void Using_VariableDeclaration_Complex() + { + ParseDocumentTest("@{ using Some.Disposable.TypeName foo = GetDisposable(() => { using var bar = otherDisposable; }); }"); + } + + [Fact] + public void StaticUsing_NoUsing() + { + ParseDocumentTest("@using static"); + } + + [Fact] + public void StaticUsing_SingleIdentifier() + { + ParseDocumentTest("@using static System"); + } + + [Fact] + public void StaticUsing_MultipleIdentifiers() + { + ParseDocumentTest("@using static System.Console"); + } + + [Fact] + public void StaticUsing_GlobalPrefix() + { + ParseDocumentTest("@using static global::System.Console"); + } + + [Fact] + public void StaticUsing_Complete_Spaced() + { + ParseDocumentTest("@using static global::System.Console "); + } + + [Fact] + public void UsingStatement() + { + ParseDocumentTest("@using(var foo = new Foo()) { foo.Bar(); }"); + } + + [Fact] + public void UsingTypeAlias() + { + ParseDocumentTest("@using StringDictionary = System.Collections.Generic.Dictionary"); + } + + [Fact] + public void UsingNamespaceImport() + { + ParseDocumentTest("@using System.Text.Encoding.ASCIIEncoding"); + } + + [Fact] + public void DoStatement() + { + ParseDocumentTest("@do { foo(); } while(true);"); + } + + [Fact] + public void NonBlockKeywordTreatedAsImplicitExpression() + { + ParseDocumentTest("@is foo"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTemplateTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTemplateTest.cs new file mode 100644 index 0000000000..55a2695afa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTemplateTest.cs @@ -0,0 +1,92 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpTemplateTest : ParserTestBase + { + [Fact] + public void HandlesSingleLineTemplate() + { + ParseDocumentTest("@{ var foo = @: bar" + Environment.NewLine + "; }"); + } + + [Fact] + public void HandlesSingleLineImmediatelyFollowingStatementChar() + { + ParseDocumentTest("@{i@: bar" + Environment.NewLine + "}"); + } + + [Fact] + public void HandlesSimpleTemplateInExplicitExpressionParens() + { + ParseDocumentTest("@(Html.Repeat(10, @

    Foo #@item

    ))"); + } + + [Fact] + public void HandlesSimpleTemplateInImplicitExpressionParens() + { + ParseDocumentTest("@Html.Repeat(10, @

    Foo #@item

    )"); + } + + [Fact] + public void HandlesTwoTemplatesInImplicitExpressionParens() + { + ParseDocumentTest("@Html.Repeat(10, @

    Foo #@item

    , @

    Foo #@item

    )"); + } + + [Fact] + public void ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens() + { + // ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInImplicitExpressionParens + ParseDocumentTest("@Html.Repeat(10, @

    Foo #@Html.Repeat(10, @

    @item

    )

    )"); + } + + [Fact] + public void HandlesSimpleTemplateInStatementWithinCodeBlock() + { + ParseDocumentTest("@foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

    Foo #@item

    ); }"); + } + + [Fact] + public void HandlesTwoTemplatesInStatementWithinCodeBlock() + { + ParseDocumentTest("@foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

    Foo #@item

    , @

    Foo #@item

    ); }"); + } + + [Fact] + public void ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock() + { + // ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinCodeBlock + ParseDocumentTest("@foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

    Foo #@Html.Repeat(10, @

    @item

    )

    ); }"); + } + + [Fact] + public void HandlesSimpleTemplateInStatementWithinStatementBlock() + { + ParseDocumentTest("@{ var foo = bar; Html.ExecuteTemplate(foo, @

    Foo #@item

    ); }"); + } + + [Fact] + public void HandlessTwoTemplatesInStatementWithinStatementBlock() + { + ParseDocumentTest("@{ var foo = bar; Html.ExecuteTemplate(foo, @

    Foo #@item

    , @

    Foo #@item

    ); }"); + } + + [Fact] + public void ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock() + { + // ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinStatementBlock + ParseDocumentTest("@{ var foo = bar; Html.ExecuteTemplate(foo, @

    Foo #@Html.Repeat(10, @

    @item

    )

    ); }"); + } + + [Fact] + public void _WithDoubleTransition_DoesNotThrow() + { + ParseDocumentTest("@{ var foo = bar; Html.ExecuteTemplate(foo, @

    Foo #@item

    ); }"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpToMarkupSwitchTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpToMarkupSwitchTest.cs new file mode 100644 index 0000000000..c427d580f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpToMarkupSwitchTest.cs @@ -0,0 +1,218 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpToMarkupSwitchTest : ParserTestBase + { + [Fact] + public void SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated() + { + ParseDocumentTest("@{ List< }"); + } + + [Fact] + public void GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode() + { + ParseDocumentTest("@Foo( @

    Foo

    )", designTime: true); + } + + [Fact] + public void GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode() + { + ParseDocumentTest("@Foo( " + Environment.NewLine + + "@:

    Foo

    " + Environment.NewLine + + ")", designTime: true); + } + + [Fact] + public void GivesSpacesToCodeOnTagTransitionInDesignTimeMode() + { + ParseDocumentTest("@{" + Environment.NewLine + + "

    Foo

    " + Environment.NewLine + + "}", designTime: true); + } + + [Fact] + public void GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode() + { + ParseDocumentTest("@{" + Environment.NewLine + + " @

    Foo

    " + Environment.NewLine + + "}", designTime: true); + } + + [Fact] + public void GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode() + { + ParseDocumentTest("@{" + Environment.NewLine + + " @:

    Foo

    " + Environment.NewLine + + "}", designTime: true); + } + + [Fact] + public void ShouldSupportSingleLineMarkupContainingStatementBlock() + { + ParseDocumentTest("@Repeat(10," + Environment.NewLine + + " @: @{}" + Environment.NewLine + + ")"); + } + + [Fact] + public void ShouldSupportMarkupWithoutPreceedingWhitespace() + { + ParseDocumentTest("@foreach(var file in files){" + Environment.NewLine + + Environment.NewLine + + Environment.NewLine + + "@:Baz" + Environment.NewLine + + "
    " + Environment.NewLine + + "Foo" + Environment.NewLine + + "@:Bar" + Environment.NewLine + + "}"); + } + + [Fact] + public void GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline() + { + // ParseBlockGivesAllWhitespaceOnSameLineExcludingPreceedingNewlineButIncludingTrailingNewLineToMarkup + ParseDocumentTest("@if(foo) {" + Environment.NewLine + + " var foo = \"After this statement there are 10 spaces\"; " + Environment.NewLine + + "

    " + Environment.NewLine + + " Foo" + Environment.NewLine + + " @bar" + Environment.NewLine + + "

    " + Environment.NewLine + + " @:Hello!" + Environment.NewLine + + " var biz = boz;" + Environment.NewLine + + "}"); + } + + [Fact] + public void AllowsMarkupInIfBodyWithBraces() + { + ParseDocumentTest("@if(foo) {

    Bar

    } else if(bar) {

    Baz

    } else {

    Boz

    }"); + } + + [Fact] + public void AllowsMarkupInIfBodyWithBracesWithinCodeBlock() + { + ParseDocumentTest("@{ if(foo) {

    Bar

    } else if(bar) {

    Baz

    } else {

    Boz

    } }"); + } + + [Fact] + public void SupportsMarkupInCaseAndDefaultBranchesOfSwitch() + { + // Arrange + ParseDocumentTest("@switch(foo) {" + Environment.NewLine + + " case 0:" + Environment.NewLine + + "

    Foo

    " + Environment.NewLine + + " break;" + Environment.NewLine + + " case 1:" + Environment.NewLine + + "

    Bar

    " + Environment.NewLine + + " return;" + Environment.NewLine + + " case 2:" + Environment.NewLine + + " {" + Environment.NewLine + + "

    Baz

    " + Environment.NewLine + + "

    Boz

    " + Environment.NewLine + + " }" + Environment.NewLine + + " default:" + Environment.NewLine + + "

    Biz

    " + Environment.NewLine + + "}"); + } + + [Fact] + public void SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock() + { + // Arrange + ParseDocumentTest("@{ switch(foo) {" + Environment.NewLine + + " case 0:" + Environment.NewLine + + "

    Foo

    " + Environment.NewLine + + " break;" + Environment.NewLine + + " case 1:" + Environment.NewLine + + "

    Bar

    " + Environment.NewLine + + " return;" + Environment.NewLine + + " case 2:" + Environment.NewLine + + " {" + Environment.NewLine + + "

    Baz

    " + Environment.NewLine + + "

    Boz

    " + Environment.NewLine + + " }" + Environment.NewLine + + " default:" + Environment.NewLine + + "

    Biz

    " + Environment.NewLine + + "} }"); + } + + [Fact] + public void ParsesMarkupStatementOnOpenAngleBracket() + { + ParseDocumentTest("@for(int i = 0; i < 10; i++) {

    Foo

    }"); + } + + [Fact] + public void ParsesMarkupStatementOnOpenAngleBracketInCodeBlock() + { + ParseDocumentTest("@{ for(int i = 0; i < 10; i++) {

    Foo

    } }"); + } + + [Fact] + public void ParsesMarkupStatementOnSwitchCharacterFollowedByColon() + { + // Arrange + ParseDocumentTest("@if(foo) { @:Bar" + Environment.NewLine + + "} zoop"); + } + + [Fact] + public void ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon() + { + // Arrange + ParseDocumentTest("@if(foo) { @::Sometext" + Environment.NewLine + + "}"); + } + + + [Fact] + public void ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon() + { + // Arrange + ParseDocumentTest("@if(foo) { @:::Sometext" + Environment.NewLine + + "}"); + } + + [Fact] + public void ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock() + { + // Arrange + ParseDocumentTest("@{ if(foo) { @:Bar" + Environment.NewLine + + "} } zoop"); + } + + [Fact] + public void CorrectlyReturnsFromMarkupBlockWithPseudoTag() + { + ParseDocumentTest("@if (i > 0) { ; }"); + } + + [Fact] + public void CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock() + { + ParseDocumentTest("@{ if (i > 0) { ; } }"); + } + + [Fact] + public void SupportsAllKindsOfImplicitMarkupInCodeBlock() + { + ParseDocumentTest("@{" + Environment.NewLine + + " if(true) {" + Environment.NewLine + + " @:Single Line Markup" + Environment.NewLine + + " }" + Environment.NewLine + + " foreach (var p in Enumerable.Range(1, 10)) {" + Environment.NewLine + + " The number is @p" + Environment.NewLine + + " }" + Environment.NewLine + + " if(!false) {" + Environment.NewLine + + "

    A real tag!

    " + Environment.NewLine + + " }" + Environment.NewLine + + "}"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerCommentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerCommentTest.cs new file mode 100644 index 0000000000..0a7c55cc34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerCommentTest.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpTokenizerCommentTest : CSharpTokenizerTestBase + { + private new SyntaxToken IgnoreRemaining => (SyntaxToken)base.IgnoreRemaining; + + [Fact] + public void Next_Ignores_Star_At_EOF_In_RazorComment() + { + TestTokenizer( + "@* Foo * Bar * Baz *", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, " Foo * Bar * Baz *")); + } + + [Fact] + public void Next_Ignores_Star_Without_Trailing_At() + { + TestTokenizer( + "@* Foo * Bar * Baz *@", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, " Foo * Bar * Baz "), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@")); + } + + [Fact] + public void Next_Returns_RazorComment_Token_For_Entire_Razor_Comment() + { + TestTokenizer( + "@* Foo Bar Baz *@", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, " Foo Bar Baz "), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@")); + } + + [Fact] + public void Next_Returns_Comment_Token_For_Entire_Single_Line_Comment() + { + TestTokenizer("// Foo Bar Baz", SyntaxFactory.Token(SyntaxKind.CSharpComment, "// Foo Bar Baz")); + } + + [Fact] + public void Single_Line_Comment_Is_Terminated_By_Newline() + { + TestTokenizer("// Foo Bar Baz\na", SyntaxFactory.Token(SyntaxKind.CSharpComment, "// Foo Bar Baz"), IgnoreRemaining); + } + + [Fact] + public void Multi_Line_Comment_In_Single_Line_Comment_Has_No_Effect() + { + TestTokenizer("// Foo/*Bar*/ Baz\na", SyntaxFactory.Token(SyntaxKind.CSharpComment, "// Foo/*Bar*/ Baz"), IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Comment_Token_For_Entire_Multi_Line_Comment() + { + TestTokenizer("/* Foo\nBar\nBaz */", SyntaxFactory.Token(SyntaxKind.CSharpComment, "/* Foo\nBar\nBaz */")); + } + + [Fact] + public void Multi_Line_Comment_Is_Terminated_By_End_Sequence() + { + TestTokenizer("/* Foo\nBar\nBaz */a", SyntaxFactory.Token(SyntaxKind.CSharpComment, "/* Foo\nBar\nBaz */"), IgnoreRemaining); + } + + [Fact] + public void Unterminated_Multi_Line_Comment_Captures_To_EOF() + { + TestTokenizer("/* Foo\nBar\nBaz", SyntaxFactory.Token(SyntaxKind.CSharpComment, "/* Foo\nBar\nBaz"), IgnoreRemaining); + } + + [Fact] + public void Nested_Multi_Line_Comments_Terminated_At_First_End_Sequence() + { + TestTokenizer("/* Foo/*\nBar\nBaz*/ */", SyntaxFactory.Token(SyntaxKind.CSharpComment, "/* Foo/*\nBar\nBaz*/"), IgnoreRemaining); + } + + [Fact] + public void Nested_Multi_Line_Comments_Terminated_At_Full_End_Sequence() + { + TestTokenizer("/* Foo\nBar\nBaz* */", SyntaxFactory.Token(SyntaxKind.CSharpComment, "/* Foo\nBar\nBaz* */"), IgnoreRemaining); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerIdentifierTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerIdentifierTest.cs new file mode 100644 index 0000000000..e5a3a466ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerIdentifierTest.cs @@ -0,0 +1,171 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpTokenizerIdentifierTest : CSharpTokenizerTestBase + { + [Fact] + public void Simple_Identifier_Is_Recognized() + { + TestTokenizer("foo", SyntaxFactory.Token(SyntaxKind.Identifier, "foo")); + } + + [Fact] + public void Identifier_Starting_With_Underscore_Is_Recognized() + { + TestTokenizer("_foo", SyntaxFactory.Token(SyntaxKind.Identifier, "_foo")); + } + + [Fact] + public void Identifier_Can_Contain_Digits() + { + TestTokenizer("foo4", SyntaxFactory.Token(SyntaxKind.Identifier, "foo4")); + } + + [Fact] + public void Identifier_Can_Start_With_Titlecase_Letter() + { + TestTokenizer("ῼfoo", SyntaxFactory.Token(SyntaxKind.Identifier, "ῼfoo")); + } + + [Fact] + public void Identifier_Can_Start_With_Letter_Modifier() + { + TestTokenizer("ᵊfoo", SyntaxFactory.Token(SyntaxKind.Identifier, "ᵊfoo")); + } + + [Fact] + public void Identifier_Can_Start_With_Other_Letter() + { + TestTokenizer("ƻfoo", SyntaxFactory.Token(SyntaxKind.Identifier, "ƻfoo")); + } + + [Fact] + public void Identifier_Can_Start_With_Number_Letter() + { + TestTokenizer("Ⅽool", SyntaxFactory.Token(SyntaxKind.Identifier, "Ⅽool")); + } + + [Fact] + public void Identifier_Can_Contain_Non_Spacing_Mark() + { + TestTokenizer("foo\u0300", SyntaxFactory.Token(SyntaxKind.Identifier, "foo\u0300")); + } + + [Fact] + public void Identifier_Can_Contain_Spacing_Combining_Mark() + { + TestTokenizer("fooः", SyntaxFactory.Token(SyntaxKind.Identifier, "fooः")); + } + + [Fact] + public void Identifier_Can_Contain_Non_English_Digit() + { + TestTokenizer("foo١", SyntaxFactory.Token(SyntaxKind.Identifier, "foo١")); + } + + [Fact] + public void Identifier_Can_Contain_Connector_Punctuation() + { + TestTokenizer("foo‿bar", SyntaxFactory.Token(SyntaxKind.Identifier, "foo‿bar")); + } + + [Fact] + public void Identifier_Can_Contain_Format_Character() + { + TestTokenizer("foo؃bar", SyntaxFactory.Token(SyntaxKind.Identifier, "foo؃bar")); + } + + [Fact] + public void Keywords_Are_Recognized_As_Keyword_Tokens() + { + TestKeyword("abstract", CSharpKeyword.Abstract); + TestKeyword("byte", CSharpKeyword.Byte); + TestKeyword("class", CSharpKeyword.Class); + TestKeyword("delegate", CSharpKeyword.Delegate); + TestKeyword("event", CSharpKeyword.Event); + TestKeyword("fixed", CSharpKeyword.Fixed); + TestKeyword("if", CSharpKeyword.If); + TestKeyword("internal", CSharpKeyword.Internal); + TestKeyword("new", CSharpKeyword.New); + TestKeyword("override", CSharpKeyword.Override); + TestKeyword("readonly", CSharpKeyword.Readonly); + TestKeyword("short", CSharpKeyword.Short); + TestKeyword("struct", CSharpKeyword.Struct); + TestKeyword("try", CSharpKeyword.Try); + TestKeyword("unsafe", CSharpKeyword.Unsafe); + TestKeyword("volatile", CSharpKeyword.Volatile); + TestKeyword("as", CSharpKeyword.As); + TestKeyword("do", CSharpKeyword.Do); + TestKeyword("is", CSharpKeyword.Is); + TestKeyword("params", CSharpKeyword.Params); + TestKeyword("ref", CSharpKeyword.Ref); + TestKeyword("switch", CSharpKeyword.Switch); + TestKeyword("ushort", CSharpKeyword.Ushort); + TestKeyword("while", CSharpKeyword.While); + TestKeyword("case", CSharpKeyword.Case); + TestKeyword("const", CSharpKeyword.Const); + TestKeyword("explicit", CSharpKeyword.Explicit); + TestKeyword("float", CSharpKeyword.Float); + TestKeyword("null", CSharpKeyword.Null); + TestKeyword("sizeof", CSharpKeyword.Sizeof); + TestKeyword("typeof", CSharpKeyword.Typeof); + TestKeyword("implicit", CSharpKeyword.Implicit); + TestKeyword("private", CSharpKeyword.Private); + TestKeyword("this", CSharpKeyword.This); + TestKeyword("using", CSharpKeyword.Using); + TestKeyword("extern", CSharpKeyword.Extern); + TestKeyword("return", CSharpKeyword.Return); + TestKeyword("stackalloc", CSharpKeyword.Stackalloc); + TestKeyword("uint", CSharpKeyword.Uint); + TestKeyword("base", CSharpKeyword.Base); + TestKeyword("catch", CSharpKeyword.Catch); + TestKeyword("continue", CSharpKeyword.Continue); + TestKeyword("double", CSharpKeyword.Double); + TestKeyword("for", CSharpKeyword.For); + TestKeyword("in", CSharpKeyword.In); + TestKeyword("lock", CSharpKeyword.Lock); + TestKeyword("object", CSharpKeyword.Object); + TestKeyword("protected", CSharpKeyword.Protected); + TestKeyword("static", CSharpKeyword.Static); + TestKeyword("false", CSharpKeyword.False); + TestKeyword("public", CSharpKeyword.Public); + TestKeyword("sbyte", CSharpKeyword.Sbyte); + TestKeyword("throw", CSharpKeyword.Throw); + TestKeyword("virtual", CSharpKeyword.Virtual); + TestKeyword("decimal", CSharpKeyword.Decimal); + TestKeyword("else", CSharpKeyword.Else); + TestKeyword("operator", CSharpKeyword.Operator); + TestKeyword("string", CSharpKeyword.String); + TestKeyword("ulong", CSharpKeyword.Ulong); + TestKeyword("bool", CSharpKeyword.Bool); + TestKeyword("char", CSharpKeyword.Char); + TestKeyword("default", CSharpKeyword.Default); + TestKeyword("foreach", CSharpKeyword.Foreach); + TestKeyword("long", CSharpKeyword.Long); + TestKeyword("void", CSharpKeyword.Void); + TestKeyword("enum", CSharpKeyword.Enum); + TestKeyword("finally", CSharpKeyword.Finally); + TestKeyword("int", CSharpKeyword.Int); + TestKeyword("out", CSharpKeyword.Out); + TestKeyword("sealed", CSharpKeyword.Sealed); + TestKeyword("true", CSharpKeyword.True); + TestKeyword("goto", CSharpKeyword.Goto); + TestKeyword("unchecked", CSharpKeyword.Unchecked); + TestKeyword("interface", CSharpKeyword.Interface); + TestKeyword("break", CSharpKeyword.Break); + TestKeyword("checked", CSharpKeyword.Checked); + TestKeyword("namespace", CSharpKeyword.Namespace); + TestKeyword("when", CSharpKeyword.When); + } + + private void TestKeyword(string keyword, CSharpKeyword keywordType) + { + TestTokenizer(keyword, SyntaxFactory.Token(SyntaxKind.Keyword, keyword)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerLiteralTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerLiteralTest.cs new file mode 100644 index 0000000000..c7c250cce3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerLiteralTest.cs @@ -0,0 +1,288 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpTokenizerLiteralTest : CSharpTokenizerTestBase + { + private new SyntaxToken IgnoreRemaining => (SyntaxToken)base.IgnoreRemaining; + + [Fact] + public void Simple_Integer_Literal_Is_Recognized() + { + TestSingleToken("01189998819991197253", SyntaxKind.IntegerLiteral); + } + + [Fact] + public void Integer_Type_Suffix_Is_Recognized() + { + TestSingleToken("42U", SyntaxKind.IntegerLiteral); + TestSingleToken("42u", SyntaxKind.IntegerLiteral); + + TestSingleToken("42L", SyntaxKind.IntegerLiteral); + TestSingleToken("42l", SyntaxKind.IntegerLiteral); + + TestSingleToken("42UL", SyntaxKind.IntegerLiteral); + TestSingleToken("42Ul", SyntaxKind.IntegerLiteral); + + TestSingleToken("42uL", SyntaxKind.IntegerLiteral); + TestSingleToken("42ul", SyntaxKind.IntegerLiteral); + + TestSingleToken("42LU", SyntaxKind.IntegerLiteral); + TestSingleToken("42Lu", SyntaxKind.IntegerLiteral); + + TestSingleToken("42lU", SyntaxKind.IntegerLiteral); + TestSingleToken("42lu", SyntaxKind.IntegerLiteral); + } + + [Fact] + public void Trailing_Letter_Is_Not_Part_Of_Integer_Literal_If_Not_Type_Sufix() + { + TestTokenizer("42a", SyntaxFactory.Token(SyntaxKind.IntegerLiteral, "42"), IgnoreRemaining); + } + + [Fact] + public void Simple_Hex_Literal_Is_Recognized() + { + TestSingleToken("0x0123456789ABCDEF", SyntaxKind.IntegerLiteral); + } + + [Fact] + public void Integer_Type_Suffix_Is_Recognized_In_Hex_Literal() + { + TestSingleToken("0xDEADBEEFU", SyntaxKind.IntegerLiteral); + TestSingleToken("0xDEADBEEFu", SyntaxKind.IntegerLiteral); + + TestSingleToken("0xDEADBEEFL", SyntaxKind.IntegerLiteral); + TestSingleToken("0xDEADBEEFl", SyntaxKind.IntegerLiteral); + + TestSingleToken("0xDEADBEEFUL", SyntaxKind.IntegerLiteral); + TestSingleToken("0xDEADBEEFUl", SyntaxKind.IntegerLiteral); + + TestSingleToken("0xDEADBEEFuL", SyntaxKind.IntegerLiteral); + TestSingleToken("0xDEADBEEFul", SyntaxKind.IntegerLiteral); + + TestSingleToken("0xDEADBEEFLU", SyntaxKind.IntegerLiteral); + TestSingleToken("0xDEADBEEFLu", SyntaxKind.IntegerLiteral); + + TestSingleToken("0xDEADBEEFlU", SyntaxKind.IntegerLiteral); + TestSingleToken("0xDEADBEEFlu", SyntaxKind.IntegerLiteral); + } + + [Fact] + public void Trailing_Letter_Is_Not_Part_Of_Hex_Literal_If_Not_Type_Sufix() + { + TestTokenizer("0xDEADBEEFz", SyntaxFactory.Token(SyntaxKind.IntegerLiteral, "0xDEADBEEF"), IgnoreRemaining); + } + + [Fact] + public void Dot_Followed_By_Non_Digit_Is_Not_Part_Of_Real_Literal() + { + TestTokenizer("3.a", SyntaxFactory.Token(SyntaxKind.IntegerLiteral, "3"), IgnoreRemaining); + } + + [Fact] + public void Simple_Real_Literal_Is_Recognized() + { + TestTokenizer("3.14159", SyntaxFactory.Token(SyntaxKind.RealLiteral, "3.14159")); + } + + [Fact] + public void Real_Literal_Between_Zero_And_One_Is_Recognized() + { + TestTokenizer(".14159", SyntaxFactory.Token(SyntaxKind.RealLiteral, ".14159")); + } + + [Fact] + public void Integer_With_Real_Type_Suffix_Is_Recognized() + { + TestSingleToken("42F", SyntaxKind.RealLiteral); + TestSingleToken("42f", SyntaxKind.RealLiteral); + TestSingleToken("42D", SyntaxKind.RealLiteral); + TestSingleToken("42d", SyntaxKind.RealLiteral); + TestSingleToken("42M", SyntaxKind.RealLiteral); + TestSingleToken("42m", SyntaxKind.RealLiteral); + } + + [Fact] + public void Integer_With_Exponent_Is_Recognized() + { + TestSingleToken("1e10", SyntaxKind.RealLiteral); + TestSingleToken("1E10", SyntaxKind.RealLiteral); + TestSingleToken("1e+10", SyntaxKind.RealLiteral); + TestSingleToken("1E+10", SyntaxKind.RealLiteral); + TestSingleToken("1e-10", SyntaxKind.RealLiteral); + TestSingleToken("1E-10", SyntaxKind.RealLiteral); + } + + [Fact] + public void Real_Number_With_Type_Suffix_Is_Recognized() + { + TestSingleToken("3.14F", SyntaxKind.RealLiteral); + TestSingleToken("3.14f", SyntaxKind.RealLiteral); + TestSingleToken("3.14D", SyntaxKind.RealLiteral); + TestSingleToken("3.14d", SyntaxKind.RealLiteral); + TestSingleToken("3.14M", SyntaxKind.RealLiteral); + TestSingleToken("3.14m", SyntaxKind.RealLiteral); + } + + [Fact] + public void Real_Number_With_Exponent_Is_Recognized() + { + TestSingleToken("3.14E10", SyntaxKind.RealLiteral); + TestSingleToken("3.14e10", SyntaxKind.RealLiteral); + TestSingleToken("3.14E+10", SyntaxKind.RealLiteral); + TestSingleToken("3.14e+10", SyntaxKind.RealLiteral); + TestSingleToken("3.14E-10", SyntaxKind.RealLiteral); + TestSingleToken("3.14e-10", SyntaxKind.RealLiteral); + } + + [Fact] + public void Real_Number_With_Exponent_And_Type_Suffix_Is_Recognized() + { + TestSingleToken("3.14E+10F", SyntaxKind.RealLiteral); + } + + [Fact] + public void Single_Character_Literal_Is_Recognized() + { + TestSingleToken("'f'", SyntaxKind.CharacterLiteral); + } + + [Fact] + public void Multi_Character_Literal_Is_Recognized() + { + TestSingleToken("'foo'", SyntaxKind.CharacterLiteral); + } + + [Fact] + public void Character_Literal_Is_Terminated_By_EOF_If_Unterminated() + { + TestSingleToken("'foo bar", SyntaxKind.CharacterLiteral); + } + + [Fact] + public void Character_Literal_Not_Terminated_By_Escaped_Quote() + { + TestSingleToken("'foo\\'bar'", SyntaxKind.CharacterLiteral); + } + + [Fact] + public void Character_Literal_Is_Terminated_By_EOL_If_Unterminated() + { + TestTokenizer("'foo\n", SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'foo"), IgnoreRemaining); + } + + [Fact] + public void Character_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash() + { + TestTokenizer("'foo\\\n", SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'foo\\"), IgnoreRemaining); + } + + [Fact] + public void Character_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() + { + TestTokenizer("'foo\\\nflarg", SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'foo\\"), IgnoreRemaining); + } + + [Fact] + public void Character_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash() + { + TestTokenizer("'foo\\" + Environment.NewLine, SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'foo\\"), IgnoreRemaining); + } + + [Fact] + public void Character_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() + { + TestTokenizer($"'foo\\{Environment.NewLine}flarg", SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'foo\\"), IgnoreRemaining); + } + + [Fact] + public void Character_Literal_Allows_Escaped_Escape() + { + TestTokenizer("'foo\\\\'blah", SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'foo\\\\'"), IgnoreRemaining); + } + + [Fact] + public void String_Literal_Is_Recognized() + { + TestSingleToken("\"foo\"", SyntaxKind.StringLiteral); + } + + [Fact] + public void String_Literal_Is_Terminated_By_EOF_If_Unterminated() + { + TestSingleToken("\"foo bar", SyntaxKind.StringLiteral); + } + + [Fact] + public void String_Literal_Not_Terminated_By_Escaped_Quote() + { + TestSingleToken("\"foo\\\"bar\"", SyntaxKind.StringLiteral); + } + + [Fact] + public void String_Literal_Is_Terminated_By_EOL_If_Unterminated() + { + TestTokenizer("\"foo\n", SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"foo"), IgnoreRemaining); + } + + [Fact] + public void String_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash() + { + TestTokenizer("\"foo\\\n", SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"foo\\"), IgnoreRemaining); + } + + [Fact] + public void String_Literal_Terminated_By_EOL_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() + { + TestTokenizer("\"foo\\\nflarg", SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"foo\\"), IgnoreRemaining); + } + + [Fact] + public void String_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash() + { + TestTokenizer("\"foo\\" + Environment.NewLine, SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"foo\\"), IgnoreRemaining); + } + + [Fact] + public void String_Literal_Terminated_By_CRLF_Even_When_Last_Char_Is_Slash_And_Followed_By_Stuff() + { + TestTokenizer($"\"foo\\{Environment.NewLine}flarg", SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"foo\\"), IgnoreRemaining); + } + + [Fact] + public void String_Literal_Allows_Escaped_Escape() + { + TestTokenizer("\"foo\\\\\"blah", SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"foo\\\\\""), IgnoreRemaining); + } + + [Fact] + public void Verbatim_String_Literal_Can_Contain_Newlines() + { + TestSingleToken("@\"foo\nbar\nbaz\"", SyntaxKind.StringLiteral); + } + + [Fact] + public void Verbatim_String_Literal_Not_Terminated_By_Escaped_Double_Quote() + { + TestSingleToken("@\"foo\"\"bar\"", SyntaxKind.StringLiteral); + } + + [Fact] + public void Verbatim_String_Literal_Is_Terminated_By_Slash_Double_Quote() + { + TestTokenizer("@\"foo\\\"bar\"", SyntaxFactory.Token(SyntaxKind.StringLiteral, "@\"foo\\\""), IgnoreRemaining); + } + + [Fact] + public void Verbatim_String_Literal_Is_Terminated_By_EOF() + { + TestSingleToken("@\"foo", SyntaxKind.StringLiteral); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs new file mode 100644 index 0000000000..fdf2718387 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerOperatorsTest.cs @@ -0,0 +1,297 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpTokenizerOperatorsTest : CSharpTokenizerTestBase + { + [Fact] + public void LeftBrace_Is_Recognized() + { + TestSingleToken("{", SyntaxKind.LeftBrace); + } + + [Fact] + public void Plus_Is_Recognized() + { + TestSingleToken("+", SyntaxKind.Plus); + } + + [Fact] + public void Assign_Is_Recognized() + { + TestSingleToken("=", SyntaxKind.Assign); + } + + [Fact] + public void Arrow_Is_Recognized() + { + TestSingleToken("->", SyntaxKind.Arrow); + } + + [Fact] + public void AndAssign_Is_Recognized() + { + TestSingleToken("&=", SyntaxKind.AndAssign); + } + + [Fact] + public void RightBrace_Is_Recognized() + { + TestSingleToken("}", SyntaxKind.RightBrace); + } + + [Fact] + public void Minus_Is_Recognized() + { + TestSingleToken("-", SyntaxKind.Minus); + } + + [Fact] + public void LessThan_Is_Recognized() + { + TestSingleToken("<", SyntaxKind.LessThan); + } + + [Fact] + public void Equals_Is_Recognized() + { + TestSingleToken("==", SyntaxKind.Equals); + } + + [Fact] + public void OrAssign_Is_Recognized() + { + TestSingleToken("|=", SyntaxKind.OrAssign); + } + + [Fact] + public void LeftBracket_Is_Recognized() + { + TestSingleToken("[", SyntaxKind.LeftBracket); + } + + [Fact] + public void Star_Is_Recognized() + { + TestSingleToken("*", SyntaxKind.Star); + } + + [Fact] + public void GreaterThan_Is_Recognized() + { + TestSingleToken(">", SyntaxKind.GreaterThan); + } + + [Fact] + public void NotEqual_Is_Recognized() + { + TestSingleToken("!=", SyntaxKind.NotEqual); + } + + [Fact] + public void XorAssign_Is_Recognized() + { + TestSingleToken("^=", SyntaxKind.XorAssign); + } + + [Fact] + public void RightBracket_Is_Recognized() + { + TestSingleToken("]", SyntaxKind.RightBracket); + } + + [Fact] + public void Slash_Is_Recognized() + { + TestSingleToken("/", SyntaxKind.Slash); + } + + [Fact] + public void QuestionMark_Is_Recognized() + { + TestSingleToken("?", SyntaxKind.QuestionMark); + } + + [Fact] + public void LessThanEqual_Is_Recognized() + { + TestSingleToken("<=", SyntaxKind.LessThanEqual); + } + + [Fact] + public void LeftShift_Is_Not_Specially_Recognized() + { + TestTokenizer("<<", + SyntaxFactory.Token(SyntaxKind.LessThan, "<"), + SyntaxFactory.Token(SyntaxKind.LessThan, "<")); + } + + [Fact] + public void LeftParen_Is_Recognized() + { + TestSingleToken("(", SyntaxKind.LeftParenthesis); + } + + [Fact] + public void Modulo_Is_Recognized() + { + TestSingleToken("%", SyntaxKind.Modulo); + } + + [Fact] + public void NullCoalesce_Is_Recognized() + { + TestSingleToken("??", SyntaxKind.NullCoalesce); + } + + [Fact] + public void GreaterThanEqual_Is_Recognized() + { + TestSingleToken(">=", SyntaxKind.GreaterThanEqual); + } + + [Fact] + public void EqualGreaterThan_Is_Recognized() + { + TestSingleToken("=>", SyntaxKind.GreaterThanEqual); + } + + [Fact] + public void RightParen_Is_Recognized() + { + TestSingleToken(")", SyntaxKind.RightParenthesis); + } + + [Fact] + public void And_Is_Recognized() + { + TestSingleToken("&", SyntaxKind.And); + } + + [Fact] + public void DoubleColon_Is_Recognized() + { + TestSingleToken("::", SyntaxKind.DoubleColon); + } + + [Fact] + public void PlusAssign_Is_Recognized() + { + TestSingleToken("+=", SyntaxKind.PlusAssign); + } + + [Fact] + public void Semicolon_Is_Recognized() + { + TestSingleToken(";", SyntaxKind.Semicolon); + } + + [Fact] + public void Tilde_Is_Recognized() + { + TestSingleToken("~", SyntaxKind.Tilde); + } + + [Fact] + public void DoubleOr_Is_Recognized() + { + TestSingleToken("||", SyntaxKind.DoubleOr); + } + + [Fact] + public void ModuloAssign_Is_Recognized() + { + TestSingleToken("%=", SyntaxKind.ModuloAssign); + } + + [Fact] + public void Colon_Is_Recognized() + { + TestSingleToken(":", SyntaxKind.Colon); + } + + [Fact] + public void Not_Is_Recognized() + { + TestSingleToken("!", SyntaxKind.Not); + } + + [Fact] + public void DoubleAnd_Is_Recognized() + { + TestSingleToken("&&", SyntaxKind.DoubleAnd); + } + + [Fact] + public void DivideAssign_Is_Recognized() + { + TestSingleToken("/=", SyntaxKind.DivideAssign); + } + + [Fact] + public void Comma_Is_Recognized() + { + TestSingleToken(",", SyntaxKind.Comma); + } + + [Fact] + public void Xor_Is_Recognized() + { + TestSingleToken("^", SyntaxKind.Xor); + } + + [Fact] + public void Decrement_Is_Recognized() + { + TestSingleToken("--", SyntaxKind.Decrement); + } + + [Fact] + public void MultiplyAssign_Is_Recognized() + { + TestSingleToken("*=", SyntaxKind.MultiplyAssign); + } + + [Fact] + public void Dot_Is_Recognized() + { + TestSingleToken(".", SyntaxKind.Dot); + } + + [Fact] + public void Or_Is_Recognized() + { + TestSingleToken("|", SyntaxKind.Or); + } + + [Fact] + public void Increment_Is_Recognized() + { + TestSingleToken("++", SyntaxKind.Increment); + } + + [Fact] + public void MinusAssign_Is_Recognized() + { + TestSingleToken("-=", SyntaxKind.MinusAssign); + } + + [Fact] + public void RightShift_Is_Not_Specially_Recognized() + { + TestTokenizer(">>", + SyntaxFactory.Token(SyntaxKind.GreaterThan, ">"), + SyntaxFactory.Token(SyntaxKind.GreaterThan, ">")); + } + + [Fact] + public void Hash_Is_Recognized() + { + TestSingleToken("#", SyntaxKind.Hash); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerTest.cs new file mode 100644 index 0000000000..5ee0715a7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerTest.cs @@ -0,0 +1,107 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpTokenizerTest : CSharpTokenizerTestBase + { + private new SyntaxToken IgnoreRemaining => (SyntaxToken)base.IgnoreRemaining; + + [Fact] + public void Next_Returns_Null_When_EOF_Reached() + { + TestTokenizer(""); + } + + [Fact] + public void Next_Returns_Newline_Token_For_Single_CR() + { + TestTokenizer( + "\r\ra", + SyntaxFactory.Token(SyntaxKind.NewLine, "\r"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r"), + IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Newline_Token_For_Single_LF() + { + TestTokenizer( + "\n\na", + SyntaxFactory.Token(SyntaxKind.NewLine, "\n"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\n"), + IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Newline_Token_For_Single_NEL() + { + // NEL: Unicode "Next Line" U+0085 + TestTokenizer( + "\u0085\u0085a", + SyntaxFactory.Token(SyntaxKind.NewLine, "\u0085"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\u0085"), + IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Newline_Token_For_Single_Line_Separator() + { + // Unicode "Line Separator" U+2028 + TestTokenizer( + "\u2028\u2028a", + SyntaxFactory.Token(SyntaxKind.NewLine, "\u2028"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\u2028"), + IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Newline_Token_For_Single_Paragraph_Separator() + { + // Unicode "Paragraph Separator" U+2029 + TestTokenizer( + "\u2029\u2029a", + SyntaxFactory.Token(SyntaxKind.NewLine, "\u2029"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\u2029"), + IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Single_Newline_Token_For_CRLF() + { + TestTokenizer( + "\r\n\r\na", + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n"), + IgnoreRemaining); + } + + [Fact] + public void Next_Returns_Token_For_Whitespace_Characters() + { + TestTokenizer( + " \f\t\u000B \n ", + SyntaxFactory.Token(SyntaxKind.Whitespace, " \f\t\u000B "), + SyntaxFactory.Token(SyntaxKind.NewLine, "\n"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " ")); + } + + [Fact] + public void Transition_Is_Recognized() + { + TestSingleToken("@", SyntaxKind.Transition); + } + + [Fact] + public void Transition_Is_Recognized_As_SingleCharacter() + { + TestTokenizer( + "@(", + SyntaxFactory.Token(SyntaxKind.Transition, "@"), + SyntaxFactory.Token(SyntaxKind.LeftParenthesis, "(")); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerTestBase.cs new file mode 100644 index 0000000000..83b2adc684 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpTokenizerTestBase.cs @@ -0,0 +1,27 @@ +// 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.Syntax.InternalSyntax; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public abstract class CSharpTokenizerTestBase : TokenizerTestBase + { + private static SyntaxToken _ignoreRemaining = SyntaxFactory.Token(SyntaxKind.Marker, string.Empty); + + internal override object IgnoreRemaining + { + get { return _ignoreRemaining; } + } + + internal override object CreateTokenizer(ITextDocument source) + { + return new CSharpTokenizer(source); + } + + internal void TestSingleToken(string text, SyntaxKind expectedTokenKind) + { + TestTokenizer(text, SyntaxFactory.Token(expectedTokenKind, text)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpVerbatimBlockTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpVerbatimBlockTest.cs new file mode 100644 index 0000000000..a2f4509a6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpVerbatimBlockTest.cs @@ -0,0 +1,49 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpVerbatimBlockTest : ParserTestBase + { + private const string TestExtraKeyword = "model"; + + [Fact] + public void VerbatimBlock() + { + ParseDocumentTest("@{ foo(); }"); + } + + [Fact] + public void InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan() + { + ParseDocumentTest("@{@}"); + } + + [Fact] + public void InnerImplicitExprDoesNotAcceptDotAfterAt() + { + ParseDocumentTest("@{@.}"); + } + + [Fact] + public void InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime() + { + ParseDocumentTest("@{" + Environment.NewLine + " @" + Environment.NewLine + "}", designTime: true); + } + + [Fact] + public void InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode() + { + ParseDocumentTest("@{@foo." + Environment.NewLine + "}"); + } + + [Fact] + public void InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode() + { + ParseDocumentTest("@{@foo." + Environment.NewLine + "}", designTime: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpWhitespaceHandlingTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpWhitespaceHandlingTest.cs new file mode 100644 index 0000000000..67ce3318dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpWhitespaceHandlingTest.cs @@ -0,0 +1,17 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class CSharpWhitespaceHandlingTest : ParserTestBase + { + [Fact] + public void StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor() + { + ParseDocumentTest("@{@: @if (true) { }" + Environment.NewLine + "}"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CodeBlockEditHandlerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CodeBlockEditHandlerTest.cs new file mode 100644 index 0000000000..add5518809 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/CodeBlockEditHandlerTest.cs @@ -0,0 +1,293 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test.Legacy +{ + public class CodeBlockEditHandlerTest + { + [Fact] + public void IsAcceptableReplacement_AcceptableReplacement_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), "H3ll0"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableReplacement_AcceptableReplacement_WithMarkup_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello
    @world
    ."); + var change = new SourceChange(new SourceSpan(0, 5), "H3ll0"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableReplacement_ChangeModifiesInvalidContent_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(6, 1), "!"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableReplacement_ChangeAddsOpenAngle_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello
    ."); + var change = new SourceChange(new SourceSpan(6, 1), "<"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableReplacement_ChangeToComment_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello @"); + var change = new SourceChange(new SourceSpan(6, 1), "@*"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableReplacement_ChangeContainsInvalidContent_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 0), "{"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableReplacement_NotReplace_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableReplacement(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletion_ValidChange_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableDeletion(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableDeletion_InvalidChange_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(5, 3), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableDeletion(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletion_NotDelete_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "world"); + var change = new SourceChange(new SourceSpan(0, 0), "hello"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableDeletion(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void ModifiesInvalidContent_ValidContent_ReturnsFalse() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(0, 5), string.Empty); + + // Act + var result = CodeBlockEditHandler.ModifiesInvalidContent(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void ModifiesInvalidContent_InvalidContent_ReturnsTrue() + { + // Arrange + var span = GetSpan(SourceLocation.Zero, "Hello {world}."); + var change = new SourceChange(new SourceSpan(5, 7), string.Empty); + + // Act + var result = CodeBlockEditHandler.ModifiesInvalidContent(span, change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableInsertion_ValidChange_ReturnsTrue() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), "hello"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsAcceptableInsertion_InvalidChange_ReturnsFalse() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), "{"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertion_InvalidChange_Transition_ReturnsFalse() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), "@"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertion_InvalidChange_TemplateTransition_ReturnsFalse() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), "<"); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertion_NotInsert_ReturnsFalse() + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 2), string.Empty); + + // Act + var result = CodeBlockEditHandler.IsAcceptableInsertion(change); + + // Assert + Assert.False(result); + } + + [Theory] + [InlineData("{")] + [InlineData("}")] + [InlineData("if (true) { }")] + [InlineData("@
    ")] + [InlineData("
    ")] + [InlineData("*")] + public void ContainsInvalidContent_InvalidContent_ReturnsTrue(string content) + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), content); + + // Act + var result = CodeBlockEditHandler.ContainsInvalidContent(change); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("var x = true;")] + [InlineData("if (true) Console.WriteLine('!')")] + public void ContainsInvalidContent_ValidContent_ReturnsFalse(string content) + { + // Arrange + var change = new SourceChange(new SourceSpan(0, 0), content); + + // Act + var result = CodeBlockEditHandler.ContainsInvalidContent(change); + + // Assert + Assert.False(result); + } + + private static SyntaxNode GetSpan(SourceLocation start, string content) + { + var builder = SyntaxListBuilder.Create(); + var tokens = CSharpLanguageCharacteristics.Instance.TokenizeString(content).ToArray(); + foreach (var token in tokens) + { + builder.Add((SyntaxToken)token.CreateRed()); + } + var node = SyntaxFactory.CSharpStatementLiteral(builder.ToList()); + + return node; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DirectiveCSharpTokenizerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DirectiveCSharpTokenizerTest.cs new file mode 100644 index 0000000000..7f6e8db88a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DirectiveCSharpTokenizerTest.cs @@ -0,0 +1,48 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class DirectiveCSharpTokenizerTest : CSharpTokenizerTestBase + { + [Fact] + public void Next_ReturnsNull_AfterTokenizingFirstDirective() + { + TestTokenizer( + "\r\n @something \r\n @this is ignored", + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.Transition, "@"), + SyntaxFactory.Token(SyntaxKind.Identifier, "something"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n")); + } + + [Fact] + public void Next_IncludesComments_ReturnsNull_AfterTokenizingFirstDirective() + { + TestTokenizer( + "@*included*@\r\n @something \"value\"\r\n @this is ignored", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, "included"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.Transition, "@"), + SyntaxFactory.Token(SyntaxKind.Identifier, "something"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"value\""), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n")); + } + + internal override object CreateTokenizer(ITextDocument source) + { + return new DirectiveCSharpTokenizer(source); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DirectiveHtmlTokenizerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DirectiveHtmlTokenizerTest.cs new file mode 100644 index 0000000000..ffee2ab489 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DirectiveHtmlTokenizerTest.cs @@ -0,0 +1,42 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class DirectiveHtmlTokenizerTest : HtmlTokenizerTestBase + { + [Fact] + public void Next_ReturnsNull_WhenHtmlIsSeen() + { + TestTokenizer( + "\r\n
    Ignored
    ", + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.OpenAngle, "<")); + } + + [Fact] + public void Next_IncludesRazorComments_ReturnsNull_WhenHtmlIsSeen() + { + TestTokenizer( + "\r\n @*included*@
    Ignored
    ", + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, "included"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.Whitespace, " "), + SyntaxFactory.Token(SyntaxKind.OpenAngle, "<")); + } + + internal override object CreateTokenizer(ITextDocument source) + { + return new DirectiveHtmlTokenizer(source); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DisposableActionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DisposableActionTest.cs new file mode 100644 index 0000000000..8f14f832c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/DisposableActionTest.cs @@ -0,0 +1,25 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class DisposableActionTest + { + [Fact] + public void ActionIsExecutedOnDispose() + { + // Arrange + var called = false; + var action = new DisposableAction(() => { called = true; }); + + // Act + action.Dispose(); + + // Assert + Assert.True(called, "The action was not run when the DisposableAction was disposed"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs new file mode 100644 index 0000000000..5706173abc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs @@ -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 System; +using System.Linq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class HtmlAttributeTest : ParserTestBase + { + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace1() + { + var attributeName = "[item]"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace2() + { + var attributeName = "[(item,"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace3() + { + var attributeName = "(click)"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace4() + { + var attributeName = "(^click)"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace5() + { + var attributeName = "*something"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_BeforeEqualWhitespace6() + { + var attributeName = "#local"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace1() + { + var attributeName = "[item]"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace2() + { + var attributeName = "[(item,"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace3() + { + var attributeName = "(click)"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace4() + { + var attributeName = "(^click)"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace5() + { + var attributeName = "*something"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes_Whitespace6() + { + var attributeName = "#local"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes1() + { + var attributeName = "[item]"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes2() + { + var attributeName = "[(item,"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes3() + { + var attributeName = "(click)"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes4() + { + var attributeName = "(^click)"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes5() + { + var attributeName = "*something"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SymbolBoundAttributes6() + { + var attributeName = "#local"; + ParseDocumentTest($"@{{}}"); + } + + [Fact] + public void SimpleLiteralAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SimpleLiteralAttributeWithWhitespaceSurroundingEquals() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void DynamicAttributeWithWhitespaceSurroundingEquals() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void MultiPartLiteralAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void DoubleQuotedLiteralAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void NewLinePrecedingAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void NewLineBetweenAttributes() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void WhitespaceAndNewLinePrecedingAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void UnquotedLiteralAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SimpleExpressionAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void MultiValueExpressionAttribute() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void VirtualPathAttributesWorkWithConditionalAttributes() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void UnquotedAttributeWithCodeWithSpacesInBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void UnquotedAttributeWithCodeWithSpacesInDocument() + { + ParseDocumentTest("}"); + } + + [Fact] + public void ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag() + { + ParseDocumentTest(RazorLanguageVersion.Experimental, "@{}", directives: null, designTime: false); + } + + [Fact] + public void ConditionalAttributesAreDisabledForDataAttributesInBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void ConditionalAttributesAreDisabledForDataAttributesInDocument() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void ComponentFileKind_ParsesDirectiveAttributesAsMarkup() + { + ParseDocumentTest("", fileKind: FileKinds.Component); + } + + [Fact] + public void ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup() + { + ParseDocumentTest("", fileKind: FileKinds.Component); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlBlockTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlBlockTest.cs new file mode 100644 index 0000000000..f44b9d2421 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlBlockTest.cs @@ -0,0 +1,279 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class HtmlBlockTest : ParserTestBase + { + [Fact] + public void HandlesUnbalancedTripleDashHTMLComments() + { + ParseDocumentTest( +@"@{ + +}"); + } + + [Fact] + public void HandlesOpenAngleAtEof() + { + ParseDocumentTest("@{" + Environment.NewLine + + "<"); + } + + [Fact] + public void HandlesOpenAngleWithProperTagFollowingIt() + { + ParseDocumentTest("@{" + Environment.NewLine + + "<" + Environment.NewLine + + "", + designTime: true); + } + + [Fact] + public void TagWithoutCloseAngleDoesNotTerminateBlock() + { + ParseDocumentTest("@{< " + Environment.NewLine + + " "); + } + + [Fact] + public void AllowsStartAndEndTagsToDifferInCase() + { + ParseDocumentTest("@{
  • Foo

  • }"); + } + + [Fact] + public void ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon() + { + ParseDocumentTest("@{@:
  • Foo Bar Baz" + Environment.NewLine + + "bork}"); + } + + [Fact] + public void StopsParsingSingleLineBlockAtEOFIfNoEOLReached() + { + ParseDocumentTest("@{@:foo bar"); + } + + [Fact] + public void StopsAtMatchingCloseTagToStartTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void WithSelfClosingTagJustEmitsTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void CanHandleSelfClosingTagsWithinBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SupportsTagsWithAttributes() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted() + { + ParseDocumentTest("@{\" />}"); + } + + [Fact] + public void AllowsCloseAngleBracketInAttributeValueIfSingleQuoted() + { + ParseDocumentTest("@{\' />}"); + } + + [Fact] + public void AllowsSlashInAttributeValueIfDoubleQuoted() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void AllowsSlashInAttributeValueIfSingleQuoted() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void TerminatesAtEOF() + { + ParseDocumentTest("@{"); + } + + [Fact] + public void SupportsCommentAsBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SupportsCommentWithExtraDashAsBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SupportsCommentWithinBlock() + { + ParseDocumentTest("@{barbaz}"); + } + + [Fact] + public void HtmlCommentSupportsMultipleDashes() + { + ParseDocumentTest( +@"
    +
    +
    +
    +"); + } + + [Fact] + public void ProperlyBalancesCommentStartAndEndTags() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void TerminatesAtEOFWhenParsingComment() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void TerminatesCommentAtFirstOccurrenceOfEndSequence() + { + ParseDocumentTest("@{-->}"); + } + + [Fact] + public void TreatsMalformedTagsAsContent() + { + ParseDocumentTest("@{}"); + } + + + [Fact] + public void ParsesSGMLDeclarationAsEmptyTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void TerminatesSGMLDeclarationAtFirstCloseAngle() + { + ParseDocumentTest("@{ baz>}"); + } + + [Fact] + public void ParsesXMLProcessingInstructionAsEmptyTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair() + { + ParseDocumentTest("@{ baz}"); + } + + [Fact] + public void DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark() + { + // ParseBlockDoesNotTerminateXMLProcessingInstructionAtCloseAngleUnlessPreceededByQuestionMark + ParseDocumentTest("@{ baz?>}"); + } + + [Fact] + public void SupportsScriptTagsWithLessThanSignsInThem() + { + ParseDocumentTest(@"@{}"); + } + + [Fact] + public void SupportsScriptTagsWithSpacedLessThanSignsInThem() + { + ParseDocumentTest(@"@{}"); + } + + [Fact] + public void AcceptsEmptyTextTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void AcceptsTextTagAsOuterTagButDoesNotRender() + { + ParseDocumentTest("@{Foo Bar Baz zoop}"); + } + + [Fact] + public void RendersLiteralTextTagIfDoubled() + { + ParseDocumentTest("@{Foo Bar Baz zoop}"); + } + + [Fact] + public void DoesNotConsiderPsuedoTagWithinMarkupBlock() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void StopsParsingMidEmptyTagIfEOFReached() + { + ParseDocumentTest("@{
    Foo @if(true) {} Bar
  • }"); + } + + [Fact] + public void IgnoresTagsInContentsOfScriptTag() + { + ParseDocumentTest(@"@{}"); + } + + [Fact] + public void HandlesForwardSlashInAttributeContent() + { + ParseDocumentTest(@"@{

    }"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlDocumentTest.cs new file mode 100644 index 0000000000..9b28275bc5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlDocumentTest.cs @@ -0,0 +1,265 @@ +// 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.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class HtmlDocumentTest : ParserTestBase + { + private static readonly TestFile Nested1000 = TestFile.Create("TestFiles/nested-1000.html", typeof(HtmlDocumentTest)); + + [Fact] + public void NestedCodeBlockWithMarkupSetsDotAsMarkup() + { + ParseDocumentTest("@if (true) { @if(false) {

    @something.
    } }"); + } + + [Fact] + public void OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString() + { + ParseDocumentTest(string.Empty); + } + + [Fact] + public void OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan() + { + ParseDocumentTest(" "); + } + + [Fact] + public void AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan() + { + ParseDocumentTest("@"); + } + + [Fact] + public void CorrectlyHandlesOddlySpacedHTMLElements() + { + ParseDocumentTest("

    Foo

    "); + } + + [Fact] + public void CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement() + { + ParseDocumentTest("
    Foo @if(true) {} Bar
    "); + } + + [Fact] + public void WithinSectionDoesNotCreateDocumentLevelSpan() + { + ParseDocumentTest("@section Foo {" + Environment.NewLine + + " " + Environment.NewLine + + "}", + new[] { SectionDirective.Directive, }); + } + + [Fact] + public void ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered() + { + ParseDocumentTest("foo baz"); + } + + [Fact] + public void HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput() + { + ParseDocumentTest("foo @bar baz"); + } + + [Fact] + public void EmitsAtSignAsMarkupIfAtEndOfFile() + { + ParseDocumentTest("foo @"); + } + + [Fact] + public void EmitsCodeBlockIfFirstCharacterIsSwapCharacter() + { + ParseDocumentTest("@bar"); + } + + [Fact] + public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText() + { + ParseDocumentTest("example@microsoft.com"); + } + + [Fact] + public void DoesNotSwitchToCodeOnEmailAddressInAttribute() + { + ParseDocumentTest("Email me"); + } + + [Fact] + public void DoesNotReturnErrorOnMismatchedTags() + { + ParseDocumentTest("Foo

    Baz"); + } + + [Fact] + public void ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered() + { + ParseDocumentTest("Foo BazBar"); + + // Act + var token = sut.AcceptAllButLastDoubleHyphens(); + + // Assert + Assert.True(doubleHyphenToken.IsEquivalentTo(token)); + Assert.True(sut.At(SyntaxKind.CloseAngle)); + Assert.True(doubleHyphenToken.IsEquivalentTo(sut.PreviousToken)); + } + + [Fact] + public void AcceptAllButLastDoubleHypens_ReturnsTheDoubleHyphenTokenAfterAcceptingTheDash() + { + // Arrange + var sut = CreateTestParserForContent("--->"); + + // Act + var token = sut.AcceptAllButLastDoubleHyphens(); + + // Assert + Assert.True(doubleHyphenToken.IsEquivalentTo(token)); + Assert.True(sut.At(SyntaxKind.CloseAngle)); + Assert.True(HtmlMarkupParser.IsHyphen(sut.PreviousToken)); + } + + [Fact] + public void IsHtmlCommentAhead_ReturnsTrueForEmptyCommentTag() + { + // Arrange + var sut = CreateTestParserForContent(""); + + // Act & Assert + Assert.True(sut.IsHtmlCommentAhead()); + } + + [Fact] + public void IsHtmlCommentAhead_ReturnsTrueForValidCommentTag() + { + // Arrange + var sut = CreateTestParserForContent(""); + + // Act & Assert + Assert.True(sut.IsHtmlCommentAhead()); + } + + [Fact] + public void IsHtmlCommentAhead_ReturnsTrueForValidCommentTagWithExtraDashesAtClosingTag() + { + // Arrange + var sut = CreateTestParserForContent(""); + + // Act & Assert + Assert.True(sut.IsHtmlCommentAhead()); + } + + [Fact] + public void IsHtmlCommentAhead_ReturnsFalseForContentWithBadEndingAndExtraDash() + { + // Arrange + var sut = CreateTestParserForContent(""); + + // Act & Assert + Assert.False(sut.IsHtmlCommentAhead()); + } + + [Fact] + public void IsHtmlCommentAhead_ReturnsTrueForValidCommentTagWithExtraInfoAfter() + { + // Arrange + var sut = CreateTestParserForContent(" the first part is a valid comment without the Open angle and bang tokens"); + + // Act & Assert + Assert.True(sut.IsHtmlCommentAhead()); + } + + [Fact] + public void IsHtmlCommentAhead_ReturnsFalseForNotClosedComment() + { + // Arrange + var sut = CreateTestParserForContent(""); + + // Act & Assert + Assert.True(sut.IsHtmlCommentAhead()); + } + + [Fact] + public void IsCommentContentEndingInvalid_ReturnsFalseForAllowedContent() + { + // Arrange + var expectedToken1 = SyntaxFactory.Token(SyntaxKind.Text, "a"); + var sequence = Enumerable.Range((int)'a', 26).Select(item => SyntaxFactory.Token(SyntaxKind.Text, ((char)item).ToString())); + + // Act & Assert + Assert.False(HtmlMarkupParser.IsCommentContentEndingInvalid(sequence)); + } + + [Fact] + public void IsCommentContentEndingInvalid_ReturnsTrueForDisallowedContent() + { + // Arrange + var expectedToken1 = SyntaxFactory.Token(SyntaxKind.Text, "a"); + var sequence = new[] + { + SyntaxFactory.Token(SyntaxKind.OpenAngle, "<"), + SyntaxFactory.Token(SyntaxKind.Bang, "!"), + SyntaxFactory.Token(SyntaxKind.Text, "-") + }; + + // Act & Assert + Assert.True(HtmlMarkupParser.IsCommentContentEndingInvalid(sequence)); + } + + [Fact] + public void IsCommentContentEndingInvalid_ReturnsFalseForEmptyContent() + { + // Arrange + var expectedToken1 = SyntaxFactory.Token(SyntaxKind.Text, "a"); + var sequence = Array.Empty(); + + // Act & Assert + Assert.False(HtmlMarkupParser.IsCommentContentEndingInvalid(sequence)); + } + + private class TestHtmlMarkupParser : HtmlMarkupParser + { + public new SyntaxToken PreviousToken + { + get => base.PreviousToken; + } + + public new bool IsHtmlCommentAhead() + { + return base.IsHtmlCommentAhead(); + } + + public TestHtmlMarkupParser(ParserContext context) : base(context) + { + EnsureCurrent(); + } + + public new SyntaxToken AcceptAllButLastDoubleHyphens() + { + return base.AcceptAllButLastDoubleHyphens(); + } + } + + private static TestHtmlMarkupParser CreateTestParserForContent(string content) + { + var source = TestRazorSourceDocument.Create(content); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + return new TestHtmlMarkupParser(context); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTagsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTagsTest.cs new file mode 100644 index 0000000000..cf4852999d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTagsTest.cs @@ -0,0 +1,187 @@ +// 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.Text; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class HtmlTagsTest : ParserTestBase + { + private static readonly string[] VoidElementNames = new[] + { + "area", + "base", + "br", + "col", + "command", + "embed", + "hr", + "img", + "input", + "keygen", + "link", + "meta", + "param", + "source", + "track", + "wbr", + }; + + [Fact] + public void EmptyTagNestsLikeNormalTag() + { + ParseDocumentTest("@{

    Bar}"); + } + + [Fact] + public void EmptyTag() + { + // This can happen in situations where a user is in VS' HTML editor and they're modifying + // the contents of an HTML tag. + ParseDocumentTest("@{<> Bar}"); + } + + [Fact] + public void CommentTag() + { + ParseDocumentTest("@{ Bar}"); + } + + [Fact] + public void DocTypeTag() + { + ParseDocumentTest("@{ foo}"); + } + + [Fact] + public void ProcessingInstructionTag() + { + ParseDocumentTest("@{ foo}"); + } + + [Fact] + public void ElementTags() + { + ParseDocumentTest("@{

    Foo

    Bar}"); + } + + [Fact] + public void TextTags() + { + ParseDocumentTest("@{Foo}"); + } + + [Fact] + public void CDataTag() + { + ParseDocumentTest("@{ Bar}"); + } + + [Fact] + public void ScriptTag() + { + ParseDocumentTest(""); + } + + [Fact] + public void ScriptTag_WithNestedMalformedTag() + { + ParseDocumentTest(""); + } + + [Fact] + public void ScriptTag_WithNestedEndTag() + { + ParseDocumentTest(""); + } + + [Fact] + public void ScriptTag_WithNestedBeginTag() + { + ParseDocumentTest(""); + } + + [Fact] + public void ScriptTag_WithNestedTag() + { + ParseDocumentTest(""); + } + + [Fact] + public void ScriptTag_Incomplete() + { + ParseDocumentTest(" }"); + } + + [Fact] + public void VoidElementFollowedByContent() + { + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine("@{"); + content.AppendLine("<" + tagName + ">var x = true;"); + content.AppendLine("}"); + } + + // Act & Assert + ParseDocumentTest(content.ToString()); + } + + [Fact] + public void VoidElementFollowedByOtherTag() + { + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine(@"{"); + content.AppendLine("<" + tagName + "> var x = true;"); + content.AppendLine("}"); + } + + // Act & Assert + ParseDocumentTest(content.ToString()); + } + + [Fact] + public void VoidElementFollowedByCloseTag() + { + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine("@{"); + content.AppendLine("<" + tagName + "> var x = true;"); + content.AppendLine("}"); + } + + // Act & Assert + ParseDocumentTest(content.ToString()); + } + + [Fact] + public void IncompleteVoidElementEndTag() + { + // Arrange + var content = new StringBuilder(); + foreach (var tagName in VoidElementNames) + { + content.AppendLine("@{"); + content.AppendLine("<" + tagName + ">foo#@i

    }"); + } + + [Fact] + public void SwitchesToCodeWhenSwapCharacterEncounteredMidTag() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SwitchesToCodeWhenSwapCharacterEncounteredInTagContent() + { + ParseDocumentTest("@{@bar@boz}"); + } + + [Fact] + public void ParsesCodeWithinSingleLineMarkup() + { + // TODO: Fix at a later date, HTML should be a tag block: https://github.com/aspnet/Razor/issues/101 + ParseDocumentTest("@{@:
  • Foo @Bar Baz" + Environment.NewLine + + "bork}"); + } + + [Fact] + public void SupportsCodeWithinComment() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SupportsCodeWithinSGMLDeclaration() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SupportsCodeWithinCDataDeclaration() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void SupportsCodeWithinXMLProcessingInstruction() + { + ParseDocumentTest("@{}"); + } + + [Fact] + public void DoesNotSwitchToCodeOnEmailAddressInText() + { + ParseDocumentTest("@{anurse@microsoft.com}"); + } + + [Fact] + public void DoesNotSwitchToCodeOnEmailAddressInAttribute() + { + ParseDocumentTest("@{Email me}"); + } + + [Fact] + public void GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine() + { + ParseDocumentTest("@{
      " + Environment.NewLine + + " @foreach(var p in Products) {" + Environment.NewLine + + "
    • Product: @p.Name
    • " + Environment.NewLine + + " }" + Environment.NewLine + + "
    }"); + } + + [Fact] + public void ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine() + { + ParseDocumentTest("
      " + Environment.NewLine + + " @foreach(var p in Products) {" + Environment.NewLine + + "
    • Product: @p.Name
    • " + Environment.NewLine + + " }" + Environment.NewLine + + "
    "); + } + + [Fact] + public void SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine() + { + ParseDocumentTest("@{@section foo {" + Environment.NewLine + + "
      " + Environment.NewLine + + " @foreach(var p in Products) {" + Environment.NewLine + + "
    • Product: @p.Name
    • " + Environment.NewLine + + " }" + Environment.NewLine + + "
    " + Environment.NewLine + + "}}", + new[] { SectionDirective.Directive, }); + } + + [Fact] + public void CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode() + { + ParseDocumentTest("@{
      " + Environment.NewLine + + " @foreach(var p in Products) {" + Environment.NewLine + + "
    • Product: @p.Name
    • " + Environment.NewLine + + " }" + Environment.NewLine + + "
    }", + designTime: true); + } + + // Tests for "@@" escape sequence: + [Fact] + public void TreatsTwoAtSignsAsEscapeSequence() + { + ParseDocumentTest("@{@@bar}"); + } + + [Fact] + public void TreatsPairsOfAtSignsAsEscapeSequence() + { + ParseDocumentTest("@{@@@@@bar}"); + } + + [Fact] + public void ParseDocumentTreatsTwoAtSignsAsEscapeSequence() + { + ParseDocumentTest("@@bar"); + } + + [Fact] + public void ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence() + { + ParseDocumentTest("@@@@@bar"); + } + + [Fact] + public void SectionBodyTreatsTwoAtSignsAsEscapeSequence() + { + ParseDocumentTest( + "@section Foo { @@bar }", + new[] { SectionDirective.Directive, }); + } + + [Fact] + public void SectionBodyTreatsPairsOfAtSignsAsEscapeSequence() + { + ParseDocumentTest( + "@section Foo { @@@@@bar }", + new[] { SectionDirective.Directive, }); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTokenizerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTokenizerTest.cs new file mode 100644 index 0000000000..92091fa278 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTokenizerTest.cs @@ -0,0 +1,164 @@ +// 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.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class HtmlTokenizerTest : HtmlTokenizerTestBase + { + [Fact] + public void Next_Returns_Null_When_EOF_Reached() + { + TestTokenizer(""); + } + + [Fact] + public void Text_Is_Recognized() + { + TestTokenizer("foo-9309&smlkmb;::-3029022,.sdkq92384", + SyntaxFactory.Token(SyntaxKind.Text, "foo-9309&smlkmb;::-3029022,.sdkq92384")); + } + + [Fact] + public void Whitespace_Is_Recognized() + { + TestTokenizer(" \t\f ", + SyntaxFactory.Token(SyntaxKind.Whitespace, " \t\f ")); + } + + [Fact] + public void Newline_Is_Recognized() + { + TestTokenizer("\n\r\r\n", + SyntaxFactory.Token(SyntaxKind.NewLine, "\n"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r"), + SyntaxFactory.Token(SyntaxKind.NewLine, "\r\n")); + } + + [Fact] + public void Transition_Is_Not_Recognized_Mid_Text_If_Surrounded_By_Alphanumeric_Characters() + { + TestSingleToken("foo@bar", SyntaxKind.Text); + } + + [Fact] + public void OpenAngle_Is_Recognized() + { + TestSingleToken("<", SyntaxKind.OpenAngle); + } + + [Fact] + public void Bang_Is_Recognized() + { + TestSingleToken("!", SyntaxKind.Bang); + } + + [Fact] + public void Solidus_Is_Recognized() + { + TestSingleToken("/", SyntaxKind.ForwardSlash); + } + + [Fact] + public void QuestionMark_Is_Recognized() + { + TestSingleToken("?", SyntaxKind.QuestionMark); + } + + [Fact] + public void LeftBracket_Is_Recognized() + { + TestSingleToken("[", SyntaxKind.LeftBracket); + } + + [Fact] + public void CloseAngle_Is_Recognized() + { + TestSingleToken(">", SyntaxKind.CloseAngle); + } + + [Fact] + public void RightBracket_Is_Recognized() + { + TestSingleToken("]", SyntaxKind.RightBracket); + } + + [Fact] + public void Equals_Is_Recognized() + { + TestSingleToken("=", SyntaxKind.Equals); + } + + [Fact] + public void DoubleQuote_Is_Recognized() + { + TestSingleToken("\"", SyntaxKind.DoubleQuote); + } + + [Fact] + public void SingleQuote_Is_Recognized() + { + TestSingleToken("'", SyntaxKind.SingleQuote); + } + + [Fact] + public void Transition_Is_Recognized() + { + TestSingleToken("@", SyntaxKind.Transition); + } + + [Fact] + public void DoubleHyphen_Is_Recognized() + { + TestSingleToken("--", SyntaxKind.DoubleHyphen); + } + + [Fact] + public void SingleHyphen_Is_Not_Recognized() + { + TestSingleToken("-", SyntaxKind.Text); + } + + [Fact] + public void SingleHyphen_Mid_Text_Is_Not_Recognized_As_Separate_Token() + { + TestSingleToken("foo-bar", SyntaxKind.Text); + } + + [Fact] + public void Next_Ignores_Star_At_EOF_In_RazorComment() + { + TestTokenizer( + "@* Foo * Bar * Baz *", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, " Foo * Bar * Baz *")); + } + + [Fact] + public void Next_Ignores_Star_Without_Trailing_At() + { + TestTokenizer( + "@* Foo * Bar * Baz *@", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, " Foo * Bar * Baz "), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@")); + } + + [Fact] + public void Next_Returns_RazorComment_Token_For_Entire_Razor_Comment() + { + TestTokenizer( + "@* Foo Bar Baz *@", + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@"), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentLiteral, " Foo Bar Baz "), + SyntaxFactory.Token(SyntaxKind.RazorCommentStar, "*"), + SyntaxFactory.Token(SyntaxKind.RazorCommentTransition, "@")); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTokenizerTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTokenizerTestBase.cs new file mode 100644 index 0000000000..0b6250d6d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlTokenizerTestBase.cs @@ -0,0 +1,27 @@ +// 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.Syntax.InternalSyntax; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public abstract class HtmlTokenizerTestBase : TokenizerTestBase + { + private static SyntaxToken _ignoreRemaining = SyntaxFactory.Token(SyntaxKind.Marker, string.Empty); + + internal override object IgnoreRemaining + { + get { return _ignoreRemaining; } + } + + internal override object CreateTokenizer(ITextDocument source) + { + return new HtmlTokenizer(source); + } + + internal void TestSingleToken(string text, SyntaxKind expectedTokenKind) + { + TestTokenizer(text, SyntaxFactory.Token(expectedTokenKind, text)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/ImplicitExpressionEditHandlerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/ImplicitExpressionEditHandlerTest.cs new file mode 100644 index 0000000000..bf71526ede --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/ImplicitExpressionEditHandlerTest.cs @@ -0,0 +1,463 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class ImplicitExpressionEditHandlerTest + { + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionStartNotInBalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(Hell)(o)"); + var change = new SourceChange(new SourceSpan(6, 1), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionEndNotInBalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(Hell)(o)"); + var change = new SourceChange(new SourceSpan(5, 1), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionOverlapsBalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(Hell)(o)"); + var change = new SourceChange(new SourceSpan(5, 2), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableDeletionInBalancedParenthesis_DeletionDoesNotImpactBalancedParenthesis_ReturnsTrue() + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(H(ell)o)"); + var change = new SourceChange(new SourceSpan(3, 3), string.Empty); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableDeletionInBalancedParenthesis(span, change); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("(")] + [InlineData(")")] + public void IsAcceptableInsertionInBalancedParenthesis_ReturnsFalseIfChangeIsParenthesis(string changeText) + { + // Arrange + var change = new SourceChange(0, 1, changeText); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(null, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryUpdateCountFromContent_SingleLeftParenthesis_CountsCorrectly() + { + // Arrange + var content = "("; + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateCountFromContent_SingleRightParenthesis_CountsCorrectly() + { + // Arrange + var content = ")"; + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateCountFromContent_CorrectCount_ReturnsTrue() + { + // Arrange + var content = "\"(()("; + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(2, count); + } + + [Fact] + public void TryUpdateCountFromContent_ExistingCountAndNonParenthesisContent_ReturnsTrue() + { + // Arrange + var content = "'(abc)de)fg"; + var count = 1; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.True(result); + Assert.Equal(0, count); + } + + [Fact] + public void TryUpdateCountFromContent_InvalidParenthesis_ReturnsFalse() + { + // Arrange + var content = "'())))))"; + var count = 4; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateCountFromContent(content, ref count); + + // Assert + Assert.False(result); + Assert.Equal(4, count); + } + + [Fact] + public void TryUpdateBalanceCount_SingleLeftParenthesis_CountsCorrectly() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.LeftParenthesis, "("); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateBalanceCount_SingleRightParenthesis_CountsCorrectly() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.RightParenthesis, ")"); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(1, count); + } + + [Fact] + public void TryUpdateBalanceCount_IncompleteStringLiteral_CountsCorrectly() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"(("); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(4, count); + } + + [Fact] + public void TryUpdateBalanceCount_IncompleteCharacterLiteral_CountsCorrectly() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'(("); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(4, count); + } + + [Fact] + public void TryUpdateBalanceCount_CompleteStringLiteral_CountsCorrectly() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.StringLiteral, "\"((\""); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(2, count); + } + + [Fact] + public void TryUpdateBalanceCount_CompleteCharacterLiteral_CountsCorrectly() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "'('"); + var count = 2; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.True(result); + Assert.Equal(2, count); + } + + [Fact] + public void TryUpdateBalanceCount_InvalidParenthesis_ReturnsFalse() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.RightParenthesis, ")"); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.False(result); + Assert.Equal(0, count); + } + + [Fact] + public void TryUpdateBalanceCount_InvalidParenthesisStringLiteral_ReturnsFalse() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.StringLiteral, "\")"); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.False(result); + Assert.Equal(0, count); + } + + [Fact] + public void TryUpdateBalanceCount_InvalidParenthesisCharacterLiteral_ReturnsFalse() + { + // Arrange + var token = Syntax.SyntaxFactory.Token(SyntaxKind.CharacterLiteral, "')"); + var count = 0; + + // Act + var result = ImplicitExpressionEditHandler.TryUpdateBalanceCount(token, ref count); + + // Assert + Assert.False(result); + Assert.Equal(0, count); + } + + [Fact] + public void ContainsPosition_AtStartOfToken_ReturnsTrue() + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(4, token); + + // Assert + Assert.True(result); + } + + [Fact] + public void ContainsPosition_InsideOfToken_ReturnsTrue() + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(6, token); + + // Assert + Assert.True(result); + } + + [Fact] + public void ContainsPosition_AtEndOfToken_ReturnsFalse() + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(9, token); + + // Assert + Assert.False(result); + } + + [Theory] + [InlineData(10)] + [InlineData(2)] + public void ContainsPosition_OutsideOfToken_ReturnsFalse(int position) + { + // Arrange + var token = GetTokens(new SourceLocation(4, 1, 2), "hello").Single(); + + // Act + var result = ImplicitExpressionEditHandler.ContainsPosition(position, token); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_SurroundedByCompleteParenthesis_ReturnsFalse() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "(hello)point(world)"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(9, tokens); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_InvalidParenthesis_ReturnsFalse() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "(hello))point)"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(10, tokens); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_NoParenthesis_ReturnsFalse() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "Hello World"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(3, tokens); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsInsideParenthesis_InBalancedParenthesis_ReturnsTrue() + { + // Arrange + var tokens = GetTokens(SourceLocation.Zero, "Foo(GetValue(), DoSomething(point))"); + + // Act + var result = ImplicitExpressionEditHandler.IsInsideParenthesis(30, tokens); + + // Assert + Assert.True(result); + } + + [Theory] + [InlineData("(")] + [InlineData(")")] + public void IsAcceptableInsertionInBalancedParenthesis_InsertingParenthesis_ReturnsFalse(string text) + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(Hello World)"); + var change = new SourceChange(new SourceSpan(3, 0), text); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertionInBalancedParenthesis_UnbalancedParenthesis_ReturnsFalse() + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(Hello"); + var change = new SourceChange(new SourceSpan(6, 0), " World"); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(span, change); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsAcceptableInsertionInBalancedParenthesis_BalancedParenthesis_ReturnsTrue() + { + // Arrange + var span = GetSyntaxNode(SourceLocation.Zero, "(Hello)"); + var change = new SourceChange(new SourceSpan(6, 0), " World"); + + // Act + var result = ImplicitExpressionEditHandler.IsAcceptableInsertionInBalancedParenthesis(span, change); + + // Assert + Assert.True(result); + } + + private static Syntax.MarkupTextLiteralSyntax GetSyntaxNode(SourceLocation start, string content) + { + var builder = SyntaxListBuilder.Create(); + var tokens = CSharpLanguageCharacteristics.Instance.TokenizeString(content).ToArray(); + foreach (var token in tokens) + { + builder.Add(token); + } + var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(parent: null, position: start.AbsoluteIndex); + + return (Syntax.MarkupTextLiteralSyntax)node; + } + + private static IReadOnlyList GetTokens(SourceLocation start, string content) + { + var parent = GetSyntaxNode(start, content); + return parent.LiteralTokens; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/LineTrackingStringBufferTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/LineTrackingStringBufferTest.cs new file mode 100644 index 0000000000..27179a9f6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/LineTrackingStringBufferTest.cs @@ -0,0 +1,26 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class LineTrackingStringBufferTest + { + [Fact] + public void CtorInitializesProperties() + { + var buffer = new LineTrackingStringBuffer(string.Empty, "test.cshtml"); + Assert.Equal(0, buffer.Length); + } + + [Fact] + public void CharAtCorrectlyReturnsLocation() + { + var buffer = new LineTrackingStringBuffer("foo\rbar\nbaz\r\nbiz", "test.cshtml"); + var chr = buffer.CharAt(14); + Assert.Equal('i', chr.Character); + Assert.Equal(new SourceLocation("test.cshtml", 14, 3, 1), chr.Location); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/MarkupElementGroupingTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/MarkupElementGroupingTest.cs new file mode 100644 index 0000000000..f1167e3eb8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/MarkupElementGroupingTest.cs @@ -0,0 +1,154 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class MarkupElementGroupingTest : ParserTestBase + { + [Fact] + public void Handles_ValidTags() + { + // Arrange + var content = @" +
    Foo
    +

    Bar

    +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_ValidNestedTags() + { + // Arrange + var content = @" +
    + Foo +

    Bar

    + Baz +
    "; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_ValidNestedTagsMixedWithCode() + { + // Arrange + var content = @" +
    + Foo +

    @Bar

    + @{ var x = Bar; } +
    +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_EndTagsWithMissingStartTags() + { + // Arrange + var content = @" +Foo
  • +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_StartTagsWithMissingEndTags() + { + // Arrange + var content = @" +
    + Foo +

    + Bar + +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_SelfClosingTags() + { + // Arrange + var content = @" +
    Foo +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_MalformedTags_RecoversSuccessfully() + { + // Arrange + var content = @" +

    contentfooter
    +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_MisplacedEndTags_RecoversSuccessfully() + { + // Arrange + var content = @" +
    contentfooter
    +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_DoesNotSpecialCase_VoidTags() + { + // Arrange + var content = @" +Foo +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_SpecialCasesVoidTags_WithNoEndTags() + { + // Arrange + var content = @" + +"; + + // Act & Assert + ParseDocumentTest(content); + } + + [Fact] + public void Handles_IncompleteTags() + { + // Arrange + var content = @" +<
    >Foo< > +"; + + // Act & Assert + ParseDocumentTest(content); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs new file mode 100644 index 0000000000..946fea9b51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs @@ -0,0 +1,978 @@ +// 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.Extensions; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class RazorDirectivesTest : ParserTestBase + { + [Fact] + public void DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + builder => + { + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.AddTypeToken(); + }); + + // Act & Assert + ParseDocumentTest( +@"@custom System.Text.Encoding.ASCIIEncoding +@custom System.Text.Encoding.UTF8Encoding", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + builder => + { + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.AddTypeToken(); + }); + + // Act & Assert + ParseDocumentTest( +@"@custom System.Text.Encoding.ASCIIEncoding +@custom System.Text.Encoding.UTF8Encoding", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives() + { + // Arrange + var customDescriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + builder => + { + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.AddTypeToken(); + }); + var somethingDescriptor = DirectiveDescriptor.CreateDirective( + "something", + DirectiveKind.SingleLine, + builder => + { + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.AddMemberToken(); + }); + + // Act & Assert + ParseDocumentTest( +@"@custom System.Text.Encoding.ASCIIEncoding +@something Else", + new[] { customDescriptor, somethingDescriptor }); + } + + [Fact] + public void DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives() + { + // Arrange + var customDescriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + builder => + { + builder.Usage = DirectiveUsage.FileScopedSinglyOccurring; + builder.AddTypeToken(); + }); + var somethingDescriptor = DirectiveDescriptor.CreateDirective( + "something", + DirectiveKind.SingleLine, + builder => + { + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.AddMemberToken(); + }); + + // Act & Assert + ParseDocumentTest( +@"@* There are two directives beneath this *@ +@custom System.Text.Encoding.ASCIIEncoding + +@something Else + +

    This is extra

    ", + new[] { customDescriptor, somethingDescriptor }); + } + + [Fact] + public void DirectiveDescriptor_TokensMustBeSeparatedBySpace() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken().AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"string1\"\"string2\"", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddNamespaceToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System.", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddNamespaceToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System<", + new[] { descriptor }); + } + [Fact] + public void DirectiveDescriptor_CanHandleIncompleteNamespaceTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddNamespaceToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System." + Environment.NewLine, + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_CanHandleInvalidNamespaceTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddNamespaceToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System<" + Environment.NewLine, + new[] { descriptor }); + } + + [Fact] + public void ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddTypeToken()); + + // Act & Assert + ParseDocumentTest(Environment.NewLine + " @custom System.Text.Encoding.ASCIIEncoding", + new[] { descriptor }); + } + + [Fact] + public void BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace() + { + // Act & Assert + ParseDocumentTest(Environment.NewLine + " @addTagHelper \"*, Foo\""); + } + + [Fact] + public void BuiltInDirectiveErrorsIfNotAtStartOfLine() + { + // Act & Assert + ParseDocumentTest("{ @addTagHelper \"*, Foo\"" + Environment.NewLine + "}"); + } + + [Fact] + public void ExtensibleDirectiveErrorsIfNotAtStartOfLine() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddTypeToken()); + + // Act & Assert + ParseDocumentTest( + "{ @custom System.Text.Encoding.ASCIIEncoding" + Environment.NewLine + "}", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsTypeTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddTypeToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System.Text.Encoding.ASCIIEncoding", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsMemberTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddMemberToken()); + + // Act & Assert + ParseDocumentTest( + "@custom Some_Member", + new[] { descriptor }); + } + + [Fact] + public void Parser_ParsesNamespaceDirectiveToken_WithSingleSegment() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddNamespaceToken()); + + // Act & Assert + ParseDocumentTest( + "@custom BaseNamespace", + new[] { descriptor }); + } + + [Fact] + public void Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddNamespaceToken()); + + // Act & Assert + ParseDocumentTest( + "@custom BaseNamespace.Foo.Bar", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsStringTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"AString\"", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom AString", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_StringToken_ParserErrorForNonStringValue() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom {foo?}", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom 'AString'", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom AString\"", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsMultipleTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddTypeToken().AddMemberToken().AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System.Text.Encoding.ASCIIEncoding Some_Member \"AString\"", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsRazorBlocks() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.RazorBlock, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"Header\" {

    F{o}o

    }", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsCodeBlocks() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.CodeBlock, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"Name\" { foo(); bar(); }", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_AllowsWhiteSpaceAroundTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddTypeToken().AddMemberToken()); + + // Act & Assert + ParseDocumentTest( + "@custom System.Text.Encoding.ASCIIEncoding Some_Member ", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_ErrorsForInvalidMemberTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddMemberToken()); + + // Act & Assert + ParseDocumentTest( + "@custom -Some_Member", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_NoErrorsSemicolonAfterDirective() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"hello\" ; ", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_AllowsNullableTypes() + { + // Arrange + var variants = new[] + { + "string?", + "string?[]", + "global::System.Int32?", + "KeyValuePair?", + "KeyValuePair?[]", + "global::System.Collections.Generic.KeyValuePair?[]", + }; + + var directiveName = "custom"; + var source = $"@{directiveName}"; + var descriptor = DirectiveDescriptor.CreateDirective( + directiveName, + DirectiveKind.SingleLine, + b => + { + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + }); + + for (var i = 0; i < variants.Length; i++) + { + source += $" {variants[i]}"; + } + + // Act & Assert + ParseDocumentTest(source, new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_AllowsTupleTypes() + { + // Arrange + var variants = new[] + { + "(bool, int)", + "(int aa, string bb)?", + "( int? q , bool w )", + "( int ? q, bool ?w ,(long ? [])) ?", + "(List<(int, string)?> aa, string bb)", + "(string ss, (int u, List<(string, int)> k, (Char c, bool b, List l)), global::System.Int32[] a)", + }; + + var directiveName = "custom"; + var source = $"@{directiveName}"; + var descriptor = DirectiveDescriptor.CreateDirective( + directiveName, + DirectiveKind.SingleLine, + b => + { + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + b.AddTypeToken(); + }); + + for (var i = 0; i < variants.Length; i++) + { + source += $" {variants[i]}"; + } + + // Act & Assert + ParseDocumentTest(source, new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddTypeToken()); + + // Act & Assert + ParseDocumentTest( + $"@custom (bool, int?) ", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_ErrorsExtraContentAfterDirective() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"hello\" \"world\"", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.CodeBlock, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"Hello\" World { foo(); bar(); }", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.CodeBlock, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"Hello\"", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_ErrorsWhenMissingEndBrace() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.CodeBlock, + b => b.AddStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"Hello\" {", + new[] { descriptor }); + } + + [Fact] + public void TagHelperPrefixDirective_NoValueSucceeds() + { + ParseDocumentTest("@tagHelperPrefix \"\""); + } + + [Fact] + public void TagHelperPrefixDirective_Succeeds() + { + ParseDocumentTest("@tagHelperPrefix Foo"); + } + + [Fact] + public void TagHelperPrefixDirective_WithQuotes_Succeeds() + { + ParseDocumentTest("@tagHelperPrefix \"Foo\""); + } + + [Fact] + public void TagHelperPrefixDirective_RequiresValue() + { + ParseDocumentTest("@tagHelperPrefix "); + } + + [Fact] + public void TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue() + { + ParseDocumentTest("@tagHelperPrefix \"Foo"); + } + + [Fact] + public void TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue() + { + ParseDocumentTest("@tagHelperPrefix Foo \""); + } + + [Fact] + public void RemoveTagHelperDirective_NoValue_Invalid() + { + ParseDocumentTest("@removeTagHelper \"\""); + } + + [Fact] + public void RemoveTagHelperDirective_InvalidLookupText_AddsError() + { + ParseDocumentTest("@removeTagHelper Foo"); + } + + [Fact] + public void RemoveTagHelperDirective_SingleQuotes_AddsError() + { + ParseDocumentTest("@removeTagHelper '*, Foo'"); + } + + [Fact] + public void RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError() + { + ParseDocumentTest("@removeTagHelper \"Foo\""); + } + + [Fact] + public void RemoveTagHelperDirective_SupportsSpaces() + { + ParseDocumentTest("@removeTagHelper Foo, Bar "); + } + + [Fact] + public void RemoveTagHelperDirective_RequiresValue() + { + ParseDocumentTest("@removeTagHelper "); + } + + [Fact] + public void RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue() + { + // Arrange + ParseDocumentTest("@removeTagHelper \"Foo"); + } + + [Fact] + public void RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue() + { + ParseDocumentTest("@removeTagHelper Foo\""); + } + + [Fact] + public void AddTagHelperDirective_NoValue_Invalid() + { + ParseDocumentTest("@addTagHelper \"\""); + } + + [Fact] + public void AddTagHelperDirective_InvalidLookupText_AddsError() + { + ParseDocumentTest("@addTagHelper Foo"); + } + + [Fact] + public void AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError() + { + ParseDocumentTest("@addTagHelper \"Foo\""); + } + + [Fact] + public void AddTagHelperDirective_SingleQuotes_AddsError() + { + ParseDocumentTest("@addTagHelper '*, Foo'"); + } + + [Fact] + public void AddTagHelperDirective_SupportsSpaces() + { + ParseDocumentTest("@addTagHelper Foo, Bar "); + } + + [Fact] + public void AddTagHelperDirective_RequiresValue() + { + ParseDocumentTest("@addTagHelper "); + } + + [Fact] + public void AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue() + { + ParseDocumentTest("@addTagHelper \"Foo"); + } + + [Fact] + public void AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue() + { + ParseDocumentTest("@addTagHelper Foo\""); + } + + [Fact] + public void InheritsDirectiveSupportsArrays() + { + ParseDocumentTest( + "@inherits string[[]][]", + new[] { InheritsDirective.Directive, }); + } + + [Fact] + public void InheritsDirectiveSupportsNestedGenerics() + { + ParseDocumentTest( + "@inherits System.Web.Mvc.WebViewPage>", + new[] { InheritsDirective.Directive, }); + } + + [Fact] + public void InheritsDirectiveSupportsTypeKeywords() + { + ParseDocumentTest( + "@inherits string", + new[] { InheritsDirective.Directive, }); + } + + [Fact] + public void Parse_FunctionsDirective() + { + ParseDocumentTest( + "@functions { foo(); bar(); }", + new[] { FunctionsDirective.Directive, }); + } + + [Fact] + public void EmptyFunctionsDirective() + { + ParseDocumentTest( + "@functions { }", + new[] { FunctionsDirective.Directive, }); + } + + [Fact] + public void Parse_SectionDirective() + { + ParseDocumentTest( + "@section Header {

    F{o}o

    }", + new[] { SectionDirective.Directive, }); + } + + [Fact] + public void OptionalDirectiveTokens_AreSkipped() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddOptionalStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom ", + new[] { descriptor }); + } + + [Fact] + public void OptionalDirectiveTokens_WithSimpleTokens_AreParsed() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddOptionalStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"simple-value\"", + new[] { descriptor }); + } + + [Fact] + public void OptionalDirectiveTokens_WithBraces_AreParsed() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddOptionalStringToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"{formaction}?/{id}?\"", + new[] { descriptor }); + } + + [Fact] + public void OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddOptionalStringToken().AddOptionalTypeToken()); + + // Act & Assert + ParseDocumentTest( + "@custom \"{formaction}?/{id}?\" System.String", + new[] { descriptor }); + } + + [Fact] + public void OptionalMemberTokens_WithMissingMember_IsParsed() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "TestDirective", + DirectiveKind.SingleLine, + b => b.AddOptionalMemberToken().AddOptionalStringToken()); + + // Act & Assert + ParseDocumentTest( + "@TestDirective ", + new[] { descriptor }); + } + + [Fact] + public void OptionalMemberTokens_WithMemberSpecified_IsParsed() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "TestDirective", + DirectiveKind.SingleLine, + b => b.AddOptionalMemberToken().AddOptionalStringToken()); + + // Act & Assert + ParseDocumentTest( + "@TestDirective PropertyName", + new[] { descriptor }); + } + + [Fact] + public void Directives_CanUseReservedWord_Class() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "class", + DirectiveKind.SingleLine); + + // Act & Assert + ParseDocumentTest( + "@class", + new[] { descriptor }); + } + + [Fact] + public void Directives_CanUseReservedWord_Namespace() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "namespace", + DirectiveKind.SingleLine); + + // Act & Assert + ParseDocumentTest( + "@namespace", + new[] { descriptor }); + } + + [Fact] + public void Directives_ReservedWordInsideCodeBlock() + { + ParseDocumentTest("@{ class }"); + } + + [Fact] + public void DirectiveDescriptor_UnderstandsAttributeTokens() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddAttributeToken()); + + // Act & Assert + ParseDocumentTest(@" +@custom [Serializable] +@custom [DllImport(""user32.dll"", SetLastError=false, ExactSpelling=false)] +", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_AttributeToken_BalancesBrackets() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddAttributeToken()); + + // Act & Assert + ParseDocumentTest(@" +@custom [SomeCustom(new int[] { 1, 2, 3 } +", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddAttributeToken()); + + // Act & Assert + ParseDocumentTest(@" +@custom [SomeCustom(new int[] + { + 1, + 2, + 3 + }] +", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => b.AddAttributeToken()); + + // Act & Assert + ParseDocumentTest("@custom Serializable]", + new[] { descriptor }); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorParserTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorParserTest.cs new file mode 100644 index 0000000000..7d848c2975 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorParserTest.cs @@ -0,0 +1,52 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class RazorParserTest + { + [Fact] + public void CanParseStuff() + { + var parser = new RazorParser(); + var sourceDocument = TestRazorSourceDocument.CreateResource("TestFiles/Source/BasicMarkup.cshtml", GetType()); + var output = parser.Parse(sourceDocument); + + Assert.NotNull(output); + } + + [Fact] + public void ParseMethodCallsParseDocumentOnMarkupParserAndReturnsResults() + { + // Arrange + var parser = new RazorParser(); + var expected = +@"RazorDocument - [0..12)::12 - [foo @bar baz] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..4)::4 - [foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Whitespace;[ ]; + CSharpCodeBlock - [4..8)::4 + CSharpImplicitExpression - [4..8)::4 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [5..8)::3 + CSharpCodeBlock - [5..8)::3 + CSharpExpressionLiteral - [5..8)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [8..12)::4 - [ baz] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[baz]; +"; + + // Act + var syntaxTree = parser.Parse(TestRazorSourceDocument.Create("foo @bar baz")); + + // Assert + var actual = SyntaxNodeSerializer.Serialize(syntaxTree.Root); + Assert.Equal(expected, actual); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/SourceLocationTrackerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/SourceLocationTrackerTest.cs new file mode 100644 index 0000000000..9671ecedda --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/SourceLocationTrackerTest.cs @@ -0,0 +1,214 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class SourceLocationTrackerTest + { + private static readonly SourceLocation TestStartLocation = new SourceLocation(10, 42, 45); + + [Fact] + public void ConstructorSetsCurrentLocationToZero() + { + Assert.Equal(SourceLocation.Zero, new SourceLocationTracker().CurrentLocation); + } + + [Fact] + public void ConstructorWithSourceLocationSetsCurrentLocationToSpecifiedValue() + { + var loc = new SourceLocation(10, 42, 4); + Assert.Equal(loc, new SourceLocationTracker(loc).CurrentLocation); + } + + [Theory] + [InlineData(null)] + [InlineData("path-to-file")] + public void Advance_PreservesSourceLocationFilePath(string path) + { + // Arrange + var sourceLocation = new SourceLocation(path, 15, 2, 8); + + // Act + var result = SourceLocationTracker.Advance(sourceLocation, "Hello world"); + + // Assert + Assert.Equal(path, result.FilePath); + Assert.Equal(26, result.AbsoluteIndex); + Assert.Equal(2, result.LineIndex); + Assert.Equal(19, result.CharacterIndex); + } + + [Fact] + public void UpdateLocationAdvancesCorrectlyForMultiLineString() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation("foo\nbar\rbaz\r\nbox"); + + // Assert + Assert.Equal(26, tracker.CurrentLocation.AbsoluteIndex); + Assert.Equal(45, tracker.CurrentLocation.LineIndex); + Assert.Equal(3, tracker.CurrentLocation.CharacterIndex); + } + + [Fact] + public void UpdateLocationAdvancesAbsoluteIndexOnNonNewlineCharacter() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('f', 'o'); + + // Assert + Assert.Equal(11, tracker.CurrentLocation.AbsoluteIndex); + } + + [Fact] + public void UpdateLocationAdvancesCharacterIndexOnNonNewlineCharacter() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('f', 'o'); + + // Assert + Assert.Equal(46, tracker.CurrentLocation.CharacterIndex); + } + + [Fact] + public void UpdateLocationDoesNotAdvanceLineIndexOnNonNewlineCharacter() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('f', 'o'); + + // Assert + Assert.Equal(42, tracker.CurrentLocation.LineIndex); + } + + [Fact] + public void UpdateLocationAdvancesLineIndexOnSlashN() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\n', 'o'); + + // Assert + Assert.Equal(43, tracker.CurrentLocation.LineIndex); + } + + [Fact] + public void UpdateLocationAdvancesAbsoluteIndexOnSlashN() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\n', 'o'); + + // Assert + Assert.Equal(11, tracker.CurrentLocation.AbsoluteIndex); + } + + [Fact] + public void UpdateLocationResetsCharacterIndexOnSlashN() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\n', 'o'); + + // Assert + Assert.Equal(0, tracker.CurrentLocation.CharacterIndex); + } + + [Fact] + public void UpdateLocationAdvancesLineIndexOnSlashRFollowedByNonNewlineCharacter() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\r', 'o'); + + // Assert + Assert.Equal(43, tracker.CurrentLocation.LineIndex); + } + + [Fact] + public void UpdateLocationAdvancesAbsoluteIndexOnSlashRFollowedByNonNewlineCharacter() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\r', 'o'); + + // Assert + Assert.Equal(11, tracker.CurrentLocation.AbsoluteIndex); + } + + [Fact] + public void UpdateLocationResetsCharacterIndexOnSlashRFollowedByNonNewlineCharacter() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\r', 'o'); + + // Assert + Assert.Equal(0, tracker.CurrentLocation.CharacterIndex); + } + + [Fact] + public void UpdateLocationDoesNotAdvanceLineIndexOnSlashRFollowedBySlashN() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\r', '\n'); + + // Assert + Assert.Equal(42, tracker.CurrentLocation.LineIndex); + } + + [Fact] + public void UpdateLocationAdvancesAbsoluteIndexOnSlashRFollowedBySlashN() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\r', '\n'); + + // Assert + Assert.Equal(11, tracker.CurrentLocation.AbsoluteIndex); + } + + [Fact] + public void UpdateLocationAdvancesCharacterIndexOnSlashRFollowedBySlashN() + { + // Arrange + var tracker = new SourceLocationTracker(TestStartLocation); + + // Act + tracker.UpdateLocation('\r', '\n'); + + // Assert + Assert.Equal(46, tracker.CurrentLocation.CharacterIndex); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs new file mode 100644 index 0000000000..b574dbdf12 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs @@ -0,0 +1,2341 @@ +// 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.Components; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class TagHelperBlockRewriterTest : TagHelperRewritingTestBase + { + public static TagHelperDescriptor[] SymbolBoundAttributes_Descriptors = new[] + { + TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("bound"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("[item]") + .PropertyName("ListItems") + .TypeName(typeof(List).Namespace + "List")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("[(item)]") + .PropertyName("ArrayItems") + .TypeName(typeof(string[]).Namespace + "System.String[]")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("(click)") + .PropertyName("Event1") + .TypeName(typeof(Action).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("(^click)") + .PropertyName("Event2") + .TypeName(typeof(Action).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("*something") + .PropertyName("StringProperty1") + .TypeName(typeof(string).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("#local") + .PropertyName("StringProperty2") + .TypeName(typeof(string).FullName)) + .Build() + }; + + [Fact] + public void CanHandleSymbolBoundAttributes1() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
      "); + } + + [Fact] + public void CanHandleSymbolBoundAttributes2() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
        "); + } + + [Fact] + public void CanHandleSymbolBoundAttributes3() + { + EvaluateData(SymbolBoundAttributes_Descriptors, ""); + } + + [Fact] + public void CanHandleSymbolBoundAttributes4() + { + EvaluateData(SymbolBoundAttributes_Descriptors, ""); + } + + [Fact] + public void CanHandleSymbolBoundAttributes5() + { + EvaluateData(SymbolBoundAttributes_Descriptors, ""); + } + + [Fact] + public void CanHandleSymbolBoundAttributes6() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
        "); + } + + [Fact] + public void CanHandleSymbolBoundAttributes7() + { + EvaluateData(SymbolBoundAttributes_Descriptors, "
        "); + } + + public static TagHelperDescriptor[] WithoutEndTag_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }; + + [Fact] + public void CanHandleWithoutEndTagTagStructure1() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure2() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure3() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure4() + { + EvaluateData(WithoutEndTag_Descriptors, ""); + } + + [Fact] + public void CanHandleWithoutEndTagTagStructure5() + { + EvaluateData(WithoutEndTag_Descriptors, "
        "); + } + + public static TagHelperDescriptor[] GetTagStructureCompatibilityDescriptors(TagStructure structure1, TagStructure structure2) + { + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(structure1)) + .Build(), + TagHelperDescriptorBuilder.Create("InputTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(structure2)) + .Build() + }; + + return descriptors; + } + + [Fact] + public void AllowsCompatibleTagStructures1() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures2() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures3() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.WithoutEndTag); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures4() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.WithoutEndTag, TagStructure.WithoutEndTag); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures5() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.NormalOrSelfClosing); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures6() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.WithoutEndTag); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures7() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.NormalOrSelfClosing, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures8() + { + // Arrange + var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.WithoutEndTag, TagStructure.Unspecified); + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing() + { + // Arrange + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + { + rule + .RequireTagName("*") + .RequireAttributeDescriptor(b => + { + b.Name = "@onclick"; + b.Metadata.Add(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString); + }); + }) + .AddMetadata(ComponentMetadata.SpecialKindKey, ComponentMetadata.EventHandler.TagHelperKind) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void AllowsCompatibleTagStructures_DirectiveAttribute_Void() + { + // Arrange + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + { + rule + .RequireTagName("*") + .RequireAttributeDescriptor(b => + { + b.Name = "@onclick"; + b.Metadata.Add(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString); + }); + + }) + .AddMetadata(ComponentMetadata.SpecialKindKey, ComponentMetadata.EventHandler.TagHelperKind) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, ""); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes1() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes4() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes8() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes9() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes10() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes11() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes12() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes13() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes14() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes15() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes16() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes18() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes19() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelpersWithAttributes20() + { + RunParseTreeRewriterTest("

        }\">

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper1() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper5() + { + RunParseTreeRewriterTest(" <

        ", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper7() + { + RunParseTreeRewriterTest("<<> <<>>", "strong", "p"); + } + + [Fact] + public void CreatesErrorForMalformedTagHelper8() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + public static TagHelperDescriptor[] CodeTagHelperAttributes_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PersonTagHelper", "personAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("person")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("age") + .PropertyName("Age") + .TypeName(typeof(int).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("birthday") + .PropertyName("BirthDay") + .TypeName(typeof(DateTime).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("name") + .PropertyName("Name") + .TypeName(typeof(string).FullName)) + .Build() + }; + + [Fact] + public void UnderstandsMultipartNonStringTagHelperAttributes() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, " 123)()\" />"); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes1() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes2() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes3() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes4() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes5() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes6() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes7() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes8() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes9() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes10() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes11() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void CreatesMarkupCodeSpansForNonStringTagHelperAttributes12() + { + EvaluateData(CodeTagHelperAttributes_Descriptors, ""); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2() + { + RunParseTreeRewriterTest("

        Hello World

        ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3() + { + RunParseTreeRewriterTest("

        Hello World

        ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "strong", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2() + { + // Arrange + var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; + var currentFormattedString = "

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        Hello World

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4() + { + // Arrange + var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; + var currentFormattedString = "

        Hello World

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        Hello

        World

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6() + { + // Arrange + var doWhileString = "@do { var foo = bar; Foo foo++; } while (foo);"; + var currentFormattedString = "

        Hello

        World

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        Hello World inside of strong tag

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        {0}

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2() + { + // Arrange + var doWhileString = "@do { var foo = bar;

        Foo

        foo++; } while (foo);"; + var currentFormattedString = "

        {0}

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        Hello World {0}

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4() + { + // Arrange + var doWhileString = "@do { var foo = bar;

        Foo

        foo++; } while (foo);"; + var currentFormattedString = "

        Hello World {0}

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        {0}

        {0}

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6() + { + // Arrange + var doWhileString = "@do { var foo = bar;

        Foo

        foo++; } while (foo);"; + var currentFormattedString = "

        {0}

        {0}

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var currentFormattedString = "

        Hello {0}inside of {0} strong tag

        "; + var document = string.Format(currentFormattedString, dateTimeNowString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8() + { + // Arrange + var doWhileString = "@do { var foo = bar;

        Foo

        foo++; } while (foo);"; + var currentFormattedString = "

        Hello {0}inside of {0} strong tag

        "; + var document = string.Format(currentFormattedString, doWhileString); + + // Act & Assert + RunParseTreeRewriterTest(document, "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml1() + { + RunParseTreeRewriterTest("<<

        >>

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml2() + { + RunParseTreeRewriterTest("<

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml3() + { + RunParseTreeRewriterTest("< p />", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml4() + { + RunParseTreeRewriterTest("", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml5() + { + RunParseTreeRewriterTest("< class=\"foo\"

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml6() + { + RunParseTreeRewriterTest("/>

        >", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml7() + { + RunParseTreeRewriterTest("/>

        >", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml8() + { + RunParseTreeRewriterTest("@DateTime.Now/>

        >", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml9() + { + RunParseTreeRewriterTest("

        @DateTime.Now / >

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_AllowsInvalidHtml10() + { + RunParseTreeRewriterTest("

        < @DateTime.Now >

        ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers1() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers2() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers3() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers4() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void UnderstandsEmptyAttributeTagHelpers5() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + public static TagHelperDescriptor[] EmptyTagHelperBoundAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(bool).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("name") + .PropertyName("Name") + .TypeName(typeof(string).FullName)) + .Build() + }; + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes1() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes2() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes3() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes4() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes5() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes6() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes7() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes8() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes9() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes10() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes11() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes12() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes13() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void CreatesErrorForEmptyTagHelperBoundAttributes14() + { + EvaluateData(EmptyTagHelperBoundAttribute_Descriptors, ""); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers1() + { + RunParseTreeRewriterTest("", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers2() + { + RunParseTreeRewriterTest("", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers3() + { + RunParseTreeRewriterTest("

        World

        ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers4() + { + RunParseTreeRewriterTest(" ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers5() + { + RunParseTreeRewriterTest(" World

        ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers7() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p", "div", "script"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + + [Fact] + public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "p"); + } + + + [Fact] + public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3() + { + RunParseTreeRewriterTest("Hello

        World", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5() + { + RunParseTreeRewriterTest("

        Hello World inside of strong tag

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4() + { + RunParseTreeRewriterTest("

        Hello World inside of strong tag

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1() + { + RunParseTreeRewriterTest("

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "p"); + } + + [Fact] + public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4() + { + RunParseTreeRewriterTest("

        Hello World inside of strong tag

        ", "p"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document2() + { + // Arrange + var document = ""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document4() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document6() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Document7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block1() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block2() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block3() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block4() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block5() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block6() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void GeneratesExpectedOutputForUnboundDataDashAttributes_Block7() + { + // Arrange + var dateTimeNowString = "@DateTime.Now"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + RunParseTreeRewriterTest(document, "input"); + } + + public static TagHelperDescriptor[] MinimizedAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("unbound-required"))) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("bound-required-string"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-required-string") + .PropertyName("BoundRequiredString") + .TypeName(typeof(string).FullName)) + .Build(), + TagHelperDescriptorBuilder.Create("InputTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("bound-required-int"))) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-required-int") + .PropertyName("BoundRequiredInt") + .TypeName(typeof(int).FullName)) + .Build(), + TagHelperDescriptorBuilder.Create("InputTagHelper3", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("int-dictionary") + .PropertyName("DictionaryOfIntProperty") + .TypeName(typeof(IDictionary).Namespace + ".IDictionary") + .AsDictionaryAttribute("int-prefix-", typeof(int).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("string-dictionary") + .PropertyName("DictionaryOfStringProperty") + .TypeName(typeof(IDictionary).Namespace + ".IDictionary") + .AsDictionaryAttribute("string-prefix-", typeof(string).FullName)) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-string") + .PropertyName("BoundRequiredString") + .TypeName(typeof(string).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound-int") + .PropertyName("BoundRequiredString") + .TypeName(typeof(int).FullName)) + .Build(), + }; + + [Fact] + public void UnderstandsMinimizedAttributes_Document1() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document2() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document3() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document4() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document5() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document6() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document7() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document8() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document9() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document10() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document11() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document12() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document13() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document14() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document15() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document16() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document17() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document18() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document19() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document20() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document21() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document22() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document23() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document24() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document25() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document26() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document27() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document28() + { + // Arrange + var document = ""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document29() + { + // Arrange + var document = "

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document30() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document31() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document32() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Document33() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

        "; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block1() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block2() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block3() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block4() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block5() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block6() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block7() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block8() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block9() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block10() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block11() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block12() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block13() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block14() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block15() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block16() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block17() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block18() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block19() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block20() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block21() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block22() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block23() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block24() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block25() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block26() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block27() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block28() + { + // Arrange + var document = ""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block29() + { + // Arrange + var document = "

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block30() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block31() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block32() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $""; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_Block33() + { + // Arrange + var expressionString = "@DateTime.Now + 1"; + var document = $"

        "; + + // Wrap in a CSharp block + document = $"@{{{document}}}"; + + // Act & Assert + EvaluateData(MinimizedAttribute_Descriptors, document); + } + + [Fact] + public void UnderstandsMinimizedAttributes_PartialTags1() + { + EvaluateData(MinimizedAttribute_Descriptors, " + rule + .RequireTagName("input")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("boundbool") + .PropertyName("BoundBoolProp") + .TypeName(typeof(bool).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("boundbooldict") + .PropertyName("BoundBoolDictProp") + .TypeName("System.Collections.Generic.IDictionary") + .AsDictionary("boundbooldict-", typeof(bool).FullName)) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, document); + } + + [Fact] + public void FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes() + { + // Arrange + var document = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("boundbool") + .PropertyName("BoundBoolProp") + .TypeName(typeof(bool).FullName)) + .BoundAttributeDescriptor(attribute => + attribute + .Name("boundbooldict") + .PropertyName("BoundBoolDictProp") + .TypeName("System.Collections.Generic.IDictionary") + .AsDictionary("boundbooldict-", typeof(bool).FullName)) + .Build(), + }; + + var featureFlags = new TestRazorParserFeatureFlags(); + + // Act & Assert + EvaluateData(descriptors, document, featureFlags: featureFlags); + } + + [Fact] + public void Rewrites_ComponentDirectiveAttributes() + { + // Arrange + var document = @""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, "Bind", ComponentsApi.AssemblyName) + .AddMetadata(ComponentMetadata.SpecialKindKey, ComponentMetadata.Bind.TagHelperKind) + .AddMetadata(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString) + .AddMetadata(TagHelperMetadata.Runtime.Name, ComponentMetadata.Bind.RuntimeName) + .TypeName("Microsoft.AspNetCore.Components.Bind") + .AddMetadata(ComponentMetadata.Bind.FallbackKey, bool.TrueString) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(r => + { + r.Name = "@bind-"; + r.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch; + r.Metadata.Add(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString); + })) + .BoundAttributeDescriptor(attribute => + attribute + .Name("@bind-...") + .PropertyName("Bind") + .AsDictionaryAttribute("@bind-", typeof(object).FullName) + .TypeName("System.Collections.Generic.Dictionary") + .AddMetadata(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString) + .BindAttributeParameter(p => + { + p.Name = "event"; + p.TypeName = typeof(string).FullName; + p.SetPropertyName("Event"); + })) + .Build(), + }; + + var featureFlags = new TestRazorParserFeatureFlags(allowCSharpInMarkupAttributeArea: false); + + // Act & Assert + EvaluateData(descriptors, document, featureFlags: featureFlags); + } + + [Fact] + public void Rewrites_MinimizedComponentDirectiveAttributes() + { + // Arrange + var document = @""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, "Bind", ComponentsApi.AssemblyName) + .AddMetadata(ComponentMetadata.SpecialKindKey, ComponentMetadata.Bind.TagHelperKind) + .AddMetadata(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString) + .AddMetadata(TagHelperMetadata.Runtime.Name, ComponentMetadata.Bind.RuntimeName) + .TypeName("Microsoft.AspNetCore.Components.Bind") + .AddMetadata(ComponentMetadata.Bind.FallbackKey, bool.TrueString) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(r => + { + r.Name = "@bind-"; + r.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch; + r.Metadata.Add(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString); + })) + .BoundAttributeDescriptor(attribute => + attribute + .Name("@bind-...") + .PropertyName("Bind") + .AsDictionaryAttribute("@bind-", typeof(object).FullName) + .TypeName("System.Collections.Generic.Dictionary") + .AddMetadata(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString) + .BindAttributeParameter(p => + { + p.Name = "param"; + p.TypeName = typeof(string).FullName; + p.SetPropertyName("Param"); + })) + .Build(), + }; + + var featureFlags = new TestRazorParserFeatureFlags(allowCSharpInMarkupAttributeArea: false); + + // Act & Assert + EvaluateData(descriptors, document, featureFlags: featureFlags); + } + + private class TestRazorParserFeatureFlags : RazorParserFeatureFlags + { + public TestRazorParserFeatureFlags( + bool allowMinimizedBooleanTagHelperAttributes = false, + bool allowHtmlCommentsInTagHelper = false, + bool allowComponentFileKind = false, + bool allowRazorInCodeBlockDirectives = false, + bool allowUsingVariableDeclarations = false, + bool allowConditionalDataDashAttributesInComponents = false, + bool allowCSharpInMarkupAttributeArea = true, + bool allowNullableForgivenessOperator = false) + { + AllowMinimizedBooleanTagHelperAttributes = allowMinimizedBooleanTagHelperAttributes; + AllowHtmlCommentsInTagHelpers = allowHtmlCommentsInTagHelper; + AllowComponentFileKind = allowComponentFileKind; + AllowRazorInAllCodeBlocks = allowRazorInCodeBlockDirectives; + AllowUsingVariableDeclarations = allowUsingVariableDeclarations; + AllowConditionalDataDashAttributes = allowConditionalDataDashAttributesInComponents; + AllowCSharpInMarkupAttributeArea = allowCSharpInMarkupAttributeArea; + AllowNullableForgivenessOperator = allowNullableForgivenessOperator; + } + + public override bool AllowMinimizedBooleanTagHelperAttributes { get; } + + public override bool AllowHtmlCommentsInTagHelpers { get; } + + public override bool AllowComponentFileKind { get; } + + public override bool AllowRazorInAllCodeBlocks { get; } + + public override bool AllowUsingVariableDeclarations { get; } + + public override bool AllowConditionalDataDashAttributes { get; } + + public override bool AllowCSharpInMarkupAttributeArea { get; } + + public override bool AllowNullableForgivenessOperator { get; } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs new file mode 100644 index 0000000000..044f59124d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -0,0 +1,1936 @@ +// 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.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class TagHelperParseTreeRewriterTest : TagHelperRewritingTestBase + { + public static TheoryData GetAttributeNameValuePairsData + { + get + { + Func> kvp = + (key, value) => new KeyValuePair(key, value); + var empty = Enumerable.Empty>(); + var csharp = TagHelperParseTreeRewriter.Rewriter.InvalidAttributeValueMarker; + + // documentContent, expectedPairs + return new TheoryData>> + { + { "", empty }, + { "", empty }, + { "", new[] { kvp("href", csharp) } }, + { "", new[] { kvp("href", $"prefix{csharp} suffix") } }, + { "", new[] { kvp("href", "~/home") } }, + { "", new[] { kvp("href", "~/home") } }, + { + "", + new[] { kvp("href", $"{csharp}::0"), kvp("class", "btn btn-success"), kvp("random", "") } + }, + { "", new[] { kvp("href", "") } }, + { "> expectedPairs) + { + // Arrange + var errorSink = new ErrorSink(); + var parseResult = ParseDocument(documentContent); + var document = parseResult.Root; + var parseTreeRewriter = new TagHelperParseTreeRewriter.Rewriter( + parseResult.Source, + null, + Enumerable.Empty(), + parseResult.Options.FeatureFlags, + errorSink); + + // Assert - Guard + var rootBlock = Assert.IsType(document); + var rootMarkup = Assert.IsType(rootBlock.Document); + var childBlock = Assert.Single(rootMarkup.Children); + var element = Assert.IsType(childBlock); + Assert.Empty(errorSink.Errors); + + // Act + var pairs = parseTreeRewriter.GetAttributeNameValuePairs(element.StartTag); + + // Assert + Assert.Equal(expectedPairs, pairs); + } + + public static TagHelperDescriptor[] PartialRequiredParentTags_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")) + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(), + TagHelperDescriptorBuilder.Create("CatchALlTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + }; + + [Fact] + public void UnderstandsPartialRequiredParentTags1() + { + var document = "

        "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags2() + { + var document = "

        "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags3() + { + var document = "

        "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags4() + { + var document = "<

        <

        "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags5() + { + var document = "<

        <

        "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + [Fact] + public void UnderstandsPartialRequiredParentTags6() + { + var document = "<

        <

        "; + EvaluateData(PartialRequiredParentTags_Descriptors, document); + } + + public static TagHelperDescriptor[] NestedVoidSelfClosingRequiredParent_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("p")) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("input")) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + }; + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent1() + { + var document = ""; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent2() + { + var document = "

        "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent3() + { + var document = "


        "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent4() + { + var document = "


        "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent5() + { + var document = ""; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent6() + { + var document = "

        "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent7() + { + var document = "


        "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedVoidSelfClosingRequiredParent8() + { + var document = "


        "; + EvaluateData(NestedVoidSelfClosingRequiredParent_Descriptors, document); + } + + public static TagHelperDescriptor[] NestedRequiredParent_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("p")) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("div")) + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + }; + + [Fact] + public void UnderstandsNestedRequiredParent1() + { + var document = ""; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent2() + { + var document = "

        "; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent3() + { + var document = "
        "; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent4() + { + var document = ""; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsNestedRequiredParent5() + { + var document = "

        "; + EvaluateData(NestedRequiredParent_Descriptors, document); + } + + [Fact] + public void UnderstandsTagHelperPrefixAndAllowedChildren() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("strong") + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")) + .Build(), + }; + + // Act & Assert + EvaluateData( + descriptors, + documentContent, + tagHelperPrefix: "th:"); + } + + [Fact] + public void UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("strong") + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong").RequireParentTag("p")) + .Build(), + }; + + // Act & Assert + EvaluateData( + descriptors, + documentContent, + tagHelperPrefix: "th:"); + } + + [Fact] + public void InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent() + { + // Rewrite_InvalidStructure_UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("strong") + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong").RequireParentTag("p")) + .Build(), + }; + + // Act & Assert + EvaluateData( + descriptors, + documentContent, + tagHelperPrefix: "th:"); + } + + [Fact] + public void NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("strong") + .Build(), + }; + + // Act & Assert + EvaluateData( + descriptors, + documentContent, + tagHelperPrefix: "th:"); + } + + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4() + { + var document = ""; + RunParseTreeRewriterTest(document, "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags1() + { + var document = ""; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags2() + { + var document = ""; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags3() + { + var document = "

        "; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void UnderstandsTagHelpersInHtmlTypedScriptTags4() + { + var document = "

        "; + RunParseTreeRewriterTest(document, "p", "input"); + } + + [Fact] + public void CanHandleInvalidChildrenWithWhitespace() + { + // Arrange + var documentContent = $"

        {Environment.NewLine} {Environment.NewLine} Hello" + + $"{Environment.NewLine} {Environment.NewLine}

        "; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("br") + .Build() + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void RecoversWhenRequiredAttributeMismatchAndRestrictedChildren() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireAttributeDescriptor(attribute => attribute.Name("required"))) + .AllowChildTag("br") + .Build() + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void CanHandleMultipleTagHelpersWithAllowedChildren_OneNull() + { + // Arrange + var documentContent = "

        Hello World

        "; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("strong") + .AllowChildTag("br") + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")) + .Build(), + TagHelperDescriptorBuilder.Create("BRTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("br") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void CanHandleMultipleTagHelpersWithAllowedChildren() + { + // Arrange + var documentContent = "

        Hello World

        "; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("strong") + .Build(), + TagHelperDescriptorBuilder.Create("PTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("br") + .Build(), + TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")) + .Build(), + TagHelperDescriptorBuilder.Create("BRTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("br") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren1() + { + // Arrange + var documentContent = "


        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren2() + { + // Arrange + var documentContent = $"

        {Environment.NewLine}
        {Environment.NewLine}

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren3() + { + // Arrange + var documentContent = "


        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren4() + { + // Arrange + var documentContent = "

        Hello

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren5() + { + // Arrange + var documentContent = "


        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "br", "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren6() + { + // Arrange + var documentContent = "


        Hello

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren7() + { + // Arrange + var documentContent = "

        Title:
        Something

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren8() + { + // Arrange + var documentContent = "

        Title:
        Something

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong", "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren9() + { + // Arrange + var documentContent = "

        Title:
        Something

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong", "br" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren10() + { + // Arrange + var documentContent = "

        Title:
        A Very Cool

        Something

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren11() + { + // Arrange + var documentContent = "

        Title:
        A Very Cool

        Something

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren12() + { + // Arrange + var documentContent = "

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren13() + { + // Arrange + var documentContent = "

        <

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsAllowedChildren14() + { + // Arrange + var documentContent = "


        :Hello:

        "; + var descriptors = GetAllowedChildrenTagHelperDescriptors(new[] { "custom", "strong" }); + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + private TagHelperDescriptor[] GetAllowedChildrenTagHelperDescriptors(string[] allowedChildren) + { + var pTagHelperBuilder = TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); + var strongTagHelperBuilder = TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("strong")); + + foreach (var childTag in allowedChildren) + { + pTagHelperBuilder.AllowChildTag(childTag); + strongTagHelperBuilder.AllowChildTag(childTag); + } + var descriptors = new TagHelperDescriptor[] + { + pTagHelperBuilder.Build(), + strongTagHelperBuilder.Build(), + TagHelperDescriptorBuilder.Create("BRTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("br") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build(), + }; + + return descriptors; + } + + [Fact] + public void AllowsSimpleHtmlCommentsAsChildren() + { + // Arrange + var allowedChildren = new List { "b" }; + var literal = "asdf"; + var commentOutput = "Hello World"; + var document = $"

        {literal}

        "; + + var pTagHelperBuilder = TagHelperDescriptorBuilder + .Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); + foreach (var childTag in allowedChildren) + { + pTagHelperBuilder.AllowChildTag(childTag); + } + + var descriptors = new TagHelperDescriptor[] + { + pTagHelperBuilder.Build() + }; + + // Act & Assert + EvaluateData(descriptors, document); + } + + [Fact] + public void DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff() + { + // Arrange + var allowedChildren = new List { "b" }; + var comment1 = "Hello"; + var document = $"

        "; + + var pTagHelperBuilder = TagHelperDescriptorBuilder + .Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); + foreach (var childTag in allowedChildren) + { + pTagHelperBuilder.AllowChildTag(childTag); + } + + var descriptors = new TagHelperDescriptor[] + { + pTagHelperBuilder.Build() + }; + + // Act & Assert + EvaluateData( + descriptors, + document, + featureFlags: RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_0, FileKinds.Legacy)); + } + + [Fact] + public void FailsForContentWithCommentsAsChildren() + { + // Arrange + var allowedChildren = new List { "b" }; + var comment1 = "Hello"; + var literal = "asdf"; + var comment2 = "World"; + var document = $"

        {literal}

        "; + + var pTagHelperBuilder = TagHelperDescriptorBuilder + .Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); + foreach (var childTag in allowedChildren) + { + pTagHelperBuilder.AllowChildTag(childTag); + } + + var descriptors = new TagHelperDescriptor[] + { + pTagHelperBuilder.Build() + }; + + // Act & Assert + EvaluateData(descriptors, document); + } + + [Fact] + public void AllowsRazorCommentsAsChildren() + { + // Arrange + var allowedChildren = new List { "b" }; + var literal = "asdf"; + var commentOutput = $"@*{literal}*@"; + var document = $"

        {literal}{commentOutput}

        "; + + var pTagHelperBuilder = TagHelperDescriptorBuilder + .Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); + foreach (var childTag in allowedChildren) + { + pTagHelperBuilder.AllowChildTag(childTag); + } + + var descriptors = new TagHelperDescriptor[] + { + pTagHelperBuilder.Build() + }; + + // Act & Assert + EvaluateData(descriptors, document); + } + + [Fact] + public void AllowsRazorMarkupInHtmlComment() + { + // Arrange + var allowedChildren = new List { "b" }; + var literal = "asdf"; + var part1 = "Hello "; + var part2 = "World"; + var commentStart = ""; + var document = $"

        {literal}{commentStart}{part1}@{part2}{commentEnd}

        "; + + var pTagHelperBuilder = TagHelperDescriptorBuilder + .Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")); + foreach (var childTag in allowedChildren) + { + pTagHelperBuilder.AllowChildTag(childTag); + } + + var descriptors = new TagHelperDescriptor[] + { + pTagHelperBuilder.Build() + }; + + // Act & Assert + EvaluateData(descriptors, document); + } + + [Fact] + public void UnderstandsNullTagNameWithAllowedChildrenForCatchAll() + { + // Arrange + var documentContent = "

        "; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("custom") + .Build(), + TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("PTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .AllowChildTag("custom") + .Build(), + TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) + .Build(), + }; + + // Act & Assert + EvaluateData(descriptors, documentContent, "th:"); + } + + [Fact] + public void CanHandleStartTagOnlyTagTagMode() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void CreatesErrorForWithoutEndTagTagStructureForEndTags() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + [Fact] + public void CreatesErrorForInconsistentTagStructures() + { + // Arrange + var documentContent = ""; + var descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("InputTagHelper1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build(), + TagHelperDescriptorBuilder.Create("InputTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireTagStructure(TagStructure.NormalOrSelfClosing)) + .Build() + }; + + // Act & Assert + EvaluateData(descriptors, documentContent); + } + + public static TagHelperDescriptor[] RequiredAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + TagHelperDescriptorBuilder.Create("divTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style"))) + .Build(), + TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) + .Build() + }; + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7() + { + EvaluateData(RequiredAttribute_Descriptors, "

        words and spaces

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8() + { + EvaluateData(RequiredAttribute_Descriptors, "

        words and spaces

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9() + { + EvaluateData(RequiredAttribute_Descriptors, "

        wordsandspaces

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10() + { + EvaluateData(RequiredAttribute_Descriptors, ""); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11() + { + EvaluateData(RequiredAttribute_Descriptors, ""); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12() + { + EvaluateData(RequiredAttribute_Descriptors, "words and spaces"); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13() + { + EvaluateData(RequiredAttribute_Descriptors, "words and spaces"); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18() + { + EvaluateData(RequiredAttribute_Descriptors, "

        words and spaces

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21() + { + EvaluateData(RequiredAttribute_Descriptors, "
        words and spaces
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22() + { + EvaluateData(RequiredAttribute_Descriptors, "
        words and spaces
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23() + { + EvaluateData(RequiredAttribute_Descriptors, "
        wordsandspaces
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24() + { + EvaluateData(RequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25() + { + EvaluateData(RequiredAttribute_Descriptors, "

        words and spaces

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26() + { + EvaluateData(RequiredAttribute_Descriptors, "
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27() + { + EvaluateData(RequiredAttribute_Descriptors, "
        words and spaces
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28() + { + EvaluateData(RequiredAttribute_Descriptors, "
        words and spaces
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29() + { + EvaluateData(RequiredAttribute_Descriptors, "
        words and spaces
        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30() + { + EvaluateData(RequiredAttribute_Descriptors, "
        wordsandspaces
        "); + } + + public static TagHelperDescriptor[] NestedRequiredAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) + .Build(), + }; + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2() + { + EvaluateData(NestedRequiredAttribute_Descriptors, ""); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8() + { + EvaluateData(NestedRequiredAttribute_Descriptors, ""); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9() + { + EvaluateData(NestedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10() + { + EvaluateData(NestedRequiredAttribute_Descriptors, ""); + } + + public static TagHelperDescriptor[] MalformedRequiredAttribute_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + }; + + [Fact] + public void RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1() + { + EvaluateData(MalformedRequiredAttribute_Descriptors, ""); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8() + { + EvaluateData(MalformedRequiredAttribute_Descriptors, "

        "); + } + + [Fact] + public void RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9() + { + EvaluateData(MalformedRequiredAttribute_Descriptors, "

        rule.RequireTagName("myth")) + .Build(), + TagHelperDescriptorBuilder.Create("mythTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("myth2")) + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(bool).FullName)) + .Build() + }; + + public static TagHelperDescriptor[] PrefixedTagHelperCatchAll_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("mythTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("*")) + .Build(), + }; + + [Fact] + public void AllowsPrefixedTagHelpers1() + { + EvaluateData(PrefixedTagHelperCatchAll_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers2() + { + EvaluateData(PrefixedTagHelperCatchAll_Descriptors, "words and spaces", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers3() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers4() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers5() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers6() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers7() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers8() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers9() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers10() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "words and spaces", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsPrefixedTagHelpers11() + { + EvaluateData(PrefixedTagHelperColon_Descriptors, "", tagHelperPrefix: "th:"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3() + { + RunParseTreeRewriterTest("@{words with spaces}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4() + { + RunParseTreeRewriterTest("@{words and spaces}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9() + { + RunParseTreeRewriterTest("@{}", "p", "text"); + } + + [Fact] + public void AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData2() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData3() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData4() + { + RunParseTreeRewriterTest("@{words and spaces}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData5() + { + RunParseTreeRewriterTest("@{

        }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData6() + { + RunParseTreeRewriterTest("@{

        }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData7() + { + RunParseTreeRewriterTest("@{

        }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData8() + { + RunParseTreeRewriterTest("@{

        }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData9() + { + RunParseTreeRewriterTest("@{

        }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData10() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData11() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithBlockData12() + { + RunParseTreeRewriterTest("@{

        }", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData1() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData2() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData3() + { + RunParseTreeRewriterTest("@{words with spaces}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData4() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutCSharp_WithAttributeData5() + { + RunParseTreeRewriterTest("@{}", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData1() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData2() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData3() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData4() + { + RunParseTreeRewriterTest("words and spaces", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData5() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData6() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData7() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData8() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData9() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData10() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData11() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithBlockData12() + { + RunParseTreeRewriterTest("

        ", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData1() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData2() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData3() + { + RunParseTreeRewriterTest("words and spaces", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData4() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void AllowsTagHelperElementOptOutHTML_WithAttributeData5() + { + RunParseTreeRewriterTest("", "strong", "p"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers1() + { + RunParseTreeRewriterTest("Hello World", "p", "text"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers2() + { + RunParseTreeRewriterTest("@{Hello World}", "p", "text"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers3() + { + RunParseTreeRewriterTest("@{

        Hello World

        }", "p", "text"); + } + + [Fact] + public void DoesNotRewriteTextTagTransitionTagHelpers4() + { + RunParseTreeRewriterTest("@{

        Hello World

        }", "p", "text"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers1() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers2() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers3() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers4() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers5() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers6() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers7() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void DoesNotRewriteSpecialTagTagHelpers8() + { + RunParseTreeRewriterTest("", "!--", "?xml", "![CDATA[", "!DOCTYPE"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks1() + { + RunParseTreeRewriterTest("

        ", "p", "div"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks2() + { + RunParseTreeRewriterTest("

        Hello World

        ", "p", "div"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks3() + { + RunParseTreeRewriterTest("

        Hel

        lo

        World

        ", "p", "div"); + } + + [Fact] + public void RewritesNestedTagHelperTagBlocks4() + { + RunParseTreeRewriterTest("

        Hello

        World

        ", "p", "div"); + } + + [Fact] + public void HandlesMalformedNestedNonTagHelperTags_Correctly() + { + RunParseTreeRewriterTest("
        @{
        }"); + } + + [Fact] + public void HandlesNonTagHelperStartAndEndVoidTags_Correctly() + { + RunParseTreeRewriterTest("Foo"); + } + + public static TagHelperDescriptor[] CaseSensitive_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .SetCaseSensitive() + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(bool).FullName)) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) + .Build(), + }; + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly1() + { + EvaluateData(CaseSensitive_Descriptors, "

        "); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly2() + { + EvaluateData(CaseSensitive_Descriptors, "

        "); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly3() + { + EvaluateData(CaseSensitive_Descriptors, "

        "); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly4() + { + EvaluateData(CaseSensitive_Descriptors, "

        "); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly5() + { + EvaluateData(CaseSensitive_Descriptors, "

        "); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperRewritingTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperRewritingTestBase.cs new file mode 100644 index 0000000000..febc0663a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperRewritingTestBase.cs @@ -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.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class TagHelperRewritingTestBase : ParserTestBase + { + internal void RunParseTreeRewriterTest(string documentContent, params string[] tagNames) + { + var descriptors = BuildDescriptors(tagNames); + + EvaluateData(descriptors, documentContent); + } + + internal IEnumerable BuildDescriptors(params string[] tagNames) + { + var descriptors = new List(); + + foreach (var tagName in tagNames) + { + var descriptor = TagHelperDescriptorBuilder.Create(tagName + "taghelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName(tagName)) + .Build(); + descriptors.Add(descriptor); + } + + return descriptors; + } + + internal void EvaluateData( + IEnumerable descriptors, + string documentContent, + string tagHelperPrefix = null, + RazorParserFeatureFlags featureFlags = null) + { + var syntaxTree = ParseDocument(documentContent, featureFlags: featureFlags); + + var rewrittenTree = TagHelperParseTreeRewriter.Rewrite(syntaxTree, tagHelperPrefix, descriptors); + + BaselineTest(rewrittenTree); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TextReaderExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TextReaderExtensionsTest.cs new file mode 100644 index 0000000000..e95878c148 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TextReaderExtensionsTest.cs @@ -0,0 +1,113 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class TextReaderExtensionsTest + { + [Fact] + public void ReadUntilWithCharReadsAllTextUpToSpecifiedCharacterButNotPast() + { + RunReaderTest("foo bar baz @biz", "foo bar baz ", '@', r => r.ReadUntil('@')); + } + + [Fact] + public void ReadUntilWithCharWithInclusiveFlagReadsAllTextUpToSpecifiedCharacterButNotPastIfInclusiveFalse() + { + RunReaderTest("foo bar baz @biz", "foo bar baz ", '@', r => r.ReadUntil('@', inclusive: false)); + } + + [Fact] + public void ReadUntilWithCharWithInclusiveFlagReadsAllTextUpToAndIncludingSpecifiedCharacterIfInclusiveTrue() + { + RunReaderTest("foo bar baz @biz", "foo bar baz @", 'b', r => r.ReadUntil('@', inclusive: true)); + } + + [Fact] + public void ReadUntilWithCharReadsToEndIfSpecifiedCharacterNotFound() + { + RunReaderTest("foo bar baz", "foo bar baz", -1, r => r.ReadUntil('@')); + } + + [Fact] + public void ReadUntilWithMultipleTerminatorsReadsUntilAnyTerminatorIsFound() + { + RunReaderTest("", " r.ReadUntil('/', '>')); + } + + [Fact] + public void ReadUntilWithMultipleTerminatorsHonorsInclusiveFlagWhenFalse() + { + // NOTE: Using named parameters would be difficult here, hence the inline comment + RunReaderTest("", " r.ReadUntil(/* inclusive */ false, '/', '>')); + } + + [Fact] + public void ReadUntilWithMultipleTerminatorsHonorsInclusiveFlagWhenTrue() + { + // NOTE: Using named parameters would be difficult here, hence the inline comment + RunReaderTest("", "', r => r.ReadUntil(/* inclusive */ true, '/', '>')); + } + + [Fact] + public void ReadUntilWithPredicateStopsWhenPredicateIsTrue() + { + RunReaderTest("foo bar baz 0 zoop zork zoink", "foo bar baz ", '0', r => r.ReadUntil(c => Char.IsDigit(c))); + } + + [Fact] + public void ReadUntilWithPredicateHonorsInclusiveFlagWhenFalse() + { + RunReaderTest("foo bar baz 0 zoop zork zoink", "foo bar baz ", '0', r => r.ReadUntil(c => Char.IsDigit(c), inclusive: false)); + } + + [Fact] + public void ReadUntilWithPredicateHonorsInclusiveFlagWhenTrue() + { + RunReaderTest("foo bar baz 0 zoop zork zoink", "foo bar baz 0", ' ', r => r.ReadUntil(c => Char.IsDigit(c), inclusive: true)); + } + + [Fact] + public void ReadWhileWithPredicateStopsWhenPredicateIsFalse() + { + RunReaderTest("012345a67890", "012345", 'a', r => r.ReadWhile(c => Char.IsDigit(c))); + } + + [Fact] + public void ReadWhileWithPredicateHonorsInclusiveFlagWhenFalse() + { + RunReaderTest("012345a67890", "012345", 'a', r => r.ReadWhile(c => Char.IsDigit(c), inclusive: false)); + } + + [Fact] + public void ReadWhileWithPredicateHonorsInclusiveFlagWhenTrue() + { + RunReaderTest("012345a67890", "012345a", '6', r => r.ReadWhile(c => Char.IsDigit(c), inclusive: true)); + } + + private static void RunReaderTest(string testString, string expectedOutput, int expectedPeek, Func action) + { + // Arrange + var reader = new StringReader(testString); + + // Act + var read = action(reader); + + // Assert + Assert.Equal(expectedOutput, read); + + if (expectedPeek == -1) + { + Assert.True(reader.Peek() == -1, "Expected that the reader would be positioned at the end of the input stream"); + } + else + { + Assert.Equal((char)expectedPeek, (char)reader.Peek()); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TokenizerLookaheadTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TokenizerLookaheadTest.cs new file mode 100644 index 0000000000..5561f2e3c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TokenizerLookaheadTest.cs @@ -0,0 +1,217 @@ +// 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 System.Text; +using Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class TokenizerLookaheadTest : HtmlTokenizerTestBase + { + [Fact] + public void Lookahead_MaintainsExistingBufferWhenRejected() + { + // Arrange + var tokenizer = new ExposedTokenizer("01234"); + tokenizer.Buffer.Append("pre-existing values"); + + // Act + var result = tokenizer.Lookahead("0x", takeIfMatch: true, caseSensitive: true); + + // Assert + Assert.False(result); + Assert.Equal("pre-existing values", tokenizer.Buffer.ToString(), StringComparer.Ordinal); + } + + [Fact] + public void Lookahead_AddsToExistingBufferWhenSuccessfulAndTakeIfMatchIsTrue() + { + // Arrange + var tokenizer = new ExposedTokenizer("0x1234"); + tokenizer.Buffer.Append("pre-existing values"); + + // Act + var result = tokenizer.Lookahead("0x", takeIfMatch: true, caseSensitive: true); + + // Assert + Assert.True(result); + Assert.Equal("pre-existing values0x", tokenizer.Buffer.ToString(), StringComparer.Ordinal); + } + + [Fact] + public void Lookahead_MaintainsExistingBufferWhenSuccessfulAndTakeIfMatchIsFalse() + { + // Arrange + var tokenizer = new ExposedTokenizer("0x1234"); + tokenizer.Buffer.Append("pre-existing values"); + + // Act + var result = tokenizer.Lookahead("0x", takeIfMatch: false, caseSensitive: true); + + // Assert + Assert.True(result); + Assert.Equal("pre-existing values", tokenizer.Buffer.ToString(), StringComparer.Ordinal); + } + + [Fact] + public void LookaheadUntil_PassesThePreviousTokensInTheSameOrder() + { + // Arrange + var tokenizer = CreateContentTokenizer("asdf--fvd--<"); + + // Act + var i = 3; + IEnumerable previousTokens = null; + var tokenFound = tokenizer.LookaheadUntil((s, p) => + { + previousTokens = p; + return --i == 0; + }); + + // Assert + Assert.Equal(4, previousTokens.Count()); + + // For the very first element, there will be no previous items, so null is expected + var orderIndex = 0; + Assert.Null(previousTokens.ElementAt(orderIndex++)); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.Text, "asdf"), previousTokens.ElementAt(orderIndex++)); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.DoubleHyphen, "--"), previousTokens.ElementAt(orderIndex++)); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.Text, "fvd"), previousTokens.ElementAt(orderIndex++)); + } + + [Fact] + public void LookaheadUntil_ReturnsFalseAfterIteratingOverAllTokensIfConditionIsNotMet() + { + // Arrange + var tokenizer = CreateContentTokenizer("asdf--fvd"); + + // Act + var tokens = new Stack(); + var tokenFound = tokenizer.LookaheadUntil((s, p) => + { + tokens.Push(s); + return false; + }); + + // Assert + Assert.False(tokenFound); + Assert.Equal(3, tokens.Count); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.Text, "fvd"), tokens.Pop()); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.DoubleHyphen, "--"), tokens.Pop()); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.Text, "asdf"), tokens.Pop()); + } + + [Fact] + public void LookaheadUntil_ReturnsTrueAndBreaksIteration() + { + // Arrange + var tokenizer = CreateContentTokenizer("asdf--fvd"); + + // Act + var tokens = new Stack(); + var tokenFound = tokenizer.LookaheadUntil((s, p) => + { + tokens.Push(s); + return s.Kind == SyntaxKind.DoubleHyphen; + }); + + // Assert + Assert.True(tokenFound); + Assert.Equal(2, tokens.Count); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.DoubleHyphen, "--"), tokens.Pop()); + AssertTokenEqual(SyntaxFactory.Token(SyntaxKind.Text, "asdf"), tokens.Pop()); + } + + private static TestTokenizerBackedParser CreateContentTokenizer(string content) + { + var source = TestRazorSourceDocument.Create(content); + var options = RazorParserOptions.CreateDefault(); + var context = new ParserContext(source, options); + + var tokenizer = new TestTokenizerBackedParser(HtmlLanguageCharacteristics.Instance, context); + return tokenizer; + } + + private static void AssertTokenEqual(SyntaxToken expected, SyntaxToken actual) + { + Assert.True(expected.IsEquivalentTo(actual), "Tokens not equal."); + } + + private class ExposedTokenizer : Tokenizer + { + public ExposedTokenizer(string input) + : base(new SeekableTextReader(input, filePath: null)) + { + } + + public new StringBuilder Buffer + { + get + { + return base.Buffer; + } + } + + public override SyntaxKind RazorCommentStarKind + { + get + { + throw new NotImplementedException(); + } + } + + public override SyntaxKind RazorCommentTransitionKind + { + get + { + throw new NotImplementedException(); + } + } + + public override SyntaxKind RazorCommentKind + { + get + { + throw new NotImplementedException(); + } + } + + protected override int StartState + { + get + { + throw new NotImplementedException(); + } + } + + protected override SyntaxToken CreateToken( + string content, + SyntaxKind type, + RazorDiagnostic[] errors) + { + throw new NotImplementedException(); + } + + protected override StateResult Dispatch() + { + throw new NotImplementedException(); + } + } + + private class TestTokenizerBackedParser : TokenizerBackedParser + { + internal TestTokenizerBackedParser(LanguageCharacteristics language, ParserContext context) : base(language, context) + { + } + + internal new bool LookaheadUntil(Func, bool> condition) + { + return base.LookaheadUntil(condition); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TokenizerTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TokenizerTestBase.cs new file mode 100644 index 0000000000..21ccddba3b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TokenizerTestBase.cs @@ -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.Diagnostics; +using System.Text; +using Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public abstract class TokenizerTestBase + { + internal abstract object IgnoreRemaining { get; } + internal abstract object CreateTokenizer(ITextDocument source); + + internal void TestTokenizer(string input, params SyntaxToken[] expectedSymbols) + { + // Arrange + var success = true; + var output = new StringBuilder(); + using (var source = new SeekableTextReader(input, filePath: null)) + { + var tokenizer = (Tokenizer)CreateTokenizer(source); + var counter = 0; + SyntaxToken current = null; + while ((current = tokenizer.NextToken()) != null) + { + if (counter >= expectedSymbols.Length) + { + output.AppendLine(string.Format("F: Expected: << Nothing >>; Actual: {0}", current)); + success = false; + } + else if (ReferenceEquals(expectedSymbols[counter], IgnoreRemaining)) + { + output.AppendLine(string.Format("P: Ignored |{0}|", current)); + } + else + { + if (!expectedSymbols[counter].IsEquivalentTo(current)) + { + output.AppendLine(string.Format("F: Expected: {0}; Actual: {1}", expectedSymbols[counter], current)); + success = false; + } + else + { + output.AppendLine(string.Format("P: Expected: {0}", expectedSymbols[counter])); + } + counter++; + } + } + if (counter < expectedSymbols.Length && !ReferenceEquals(expectedSymbols[counter], IgnoreRemaining)) + { + success = false; + for (; counter < expectedSymbols.Length; counter++) + { + output.AppendLine(string.Format("F: Expected: {0}; Actual: << None >>", expectedSymbols[counter])); + } + } + } + Assert.True(success, Environment.NewLine + output.ToString()); + WriteTraceLine(output.Replace("{", "{{").Replace("}", "}}").ToString()); + } + + [Conditional("PARSER_TRACE")] + private static void WriteTraceLine(string format, params object[] args) + { + Trace.WriteLine(string.Format(format, args)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/WhiteSpaceRewriterTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/WhiteSpaceRewriterTest.cs new file mode 100644 index 0000000000..4bc69b6d7c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/WhiteSpaceRewriterTest.cs @@ -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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Legacy +{ + public class WhiteSpaceRewriterTest : ParserTestBase + { + [Fact] + public void Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block() + { + // Arrange + var content = @" +
        + @result +
        +
        + @(result) +
        "; + var parsed = ParseDocument( + RazorLanguageVersion.Latest, + content, + Array.Empty()); + + var rewriter = new WhitespaceRewriter(); + + // Act + var rewritten = rewriter.Visit(parsed.Root); + + // Assert + var rewrittenTree = RazorSyntaxTree.Create(rewritten, parsed.Source, parsed.Diagnostics, parsed.Options); + BaselineTest(rewrittenTree); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor.Language.Test.csproj b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor.Language.Test.csproj new file mode 100644 index 0000000000..120eee7bb4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor.Language.Test.csproj @@ -0,0 +1,28 @@ + + + + $(StandardTestTfms) + $(DefaultItemExcludes);TestFiles\**\* + $(DefineConstants);GENERATE_BASELINES + + + false + + + + + + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3337ebeac2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorCodeDocumentExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorCodeDocumentExtensionsTest.cs new file mode 100644 index 0000000000..2840823a17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorCodeDocumentExtensionsTest.cs @@ -0,0 +1,631 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Extensions; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorCodeDocumentExtensionsTest + { + [Fact] + public void GetRazorSyntaxTree_ReturnsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorSyntaxTree.Parse(codeDocument.Source); + codeDocument.Items[typeof(RazorSyntaxTree)] = expected; + + // Act + var actual = codeDocument.GetSyntaxTree(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetRazorSyntaxTree_SetsSyntaxTree() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorSyntaxTree.Parse(codeDocument.Source); + + // Act + codeDocument.SetSyntaxTree(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorSyntaxTree)]); + } + + [Fact] + public void GetAndSetImportSyntaxTrees_ReturnsSyntaxTrees() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = new[] { RazorSyntaxTree.Parse(codeDocument.Source), }; + codeDocument.SetImportSyntaxTrees(expected); + + // Act + var actual = codeDocument.GetImportSyntaxTrees(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void GetAndSetTagHelpers_ReturnsTagHelpers() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = new[] { TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build() }; + codeDocument.SetTagHelpers(expected); + + // Act + var actual = codeDocument.GetTagHelpers(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void GetIRDocument_ReturnsIRDocument() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = new DocumentIntermediateNode(); + codeDocument.Items[typeof(DocumentIntermediateNode)] = expected; + + // Act + var actual = codeDocument.GetDocumentIntermediateNode(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetIRDocument_SetsIRDocument() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = new DocumentIntermediateNode(); + + // Act + codeDocument.SetDocumentIntermediateNode((DocumentIntermediateNode)expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(DocumentIntermediateNode)]); + } + + [Fact] + public void GetCSharpDocument_ReturnsCSharpDocument() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCSharpDocument.Create("", RazorCodeGenerationOptions.CreateDefault(), Array.Empty()); + codeDocument.Items[typeof(RazorCSharpDocument)] = expected; + + // Act + var actual = codeDocument.GetCSharpDocument(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetCSharpDocument_SetsCSharpDocument() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCSharpDocument.Create("", RazorCodeGenerationOptions.CreateDefault(), Array.Empty()); + + // Act + codeDocument.SetCSharpDocument(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorCSharpDocument)]); + } + + [Fact] + public void GetTagHelperContext_ReturnsTagHelperContext() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = TagHelperDocumentContext.Create(null, new TagHelperDescriptor[0]); + codeDocument.Items[typeof(TagHelperDocumentContext)] = expected; + + // Act + var actual = codeDocument.GetTagHelperContext(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetTagHelperContext_SetsTagHelperContext() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = TagHelperDocumentContext.Create(null, new TagHelperDescriptor[0]); + + // Act + codeDocument.SetTagHelperContext(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(TagHelperDocumentContext)]); + } + + [Fact] + public void GetParserOptions_ReturnsSuccessfully() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + codeDocument.Items[typeof(RazorParserOptions)] = expected; + + // Act + var actual = codeDocument.GetParserOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetParserOptions_SetsSuccessfully() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorParserOptions.CreateDefault(); + + // Act + codeDocument.SetParserOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorParserOptions)]); + } + + [Fact] + public void GetCodeGenerationOptions_ReturnsSuccessfully() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + codeDocument.Items[typeof(RazorCodeGenerationOptions)] = expected; + + // Act + var actual = codeDocument.GetCodeGenerationOptions(); + + // Assert + Assert.Same(expected, actual); + } + + [Fact] + public void SetCodeGenerationOptions_SetsSuccessfully() + { + // Arrange + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + + var expected = RazorCodeGenerationOptions.CreateDefault(); + + // Act + codeDocument.SetCodeGenerationOptions(expected); + + // Assert + Assert.Same(expected, codeDocument.Items[typeof(RazorCodeGenerationOptions)]); + } + + [Fact] + public void TryComputeNamespace_RootNamespaceNotSet_ReturnsNull() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Test.cshtml", relativePath: "Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Null(@namespace); + } + + [Fact] + public void TryComputeNamespace_RelativePathNull_ReturnsNull() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Test.cshtml", relativePath: null); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Null(@namespace); + } + + [Fact] + public void TryComputeNamespace_FilePathNull_ReturnsNull() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: null, relativePath: "Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Null(@namespace); + } + + [Fact] + public void TryComputeNamespace_RelativePathLongerThanFilePath_ReturnsNull() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Test.cshtml", relativePath: "Some\\invalid\\relative\\path\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Null(@namespace); + } + + [Fact] + public void TryComputeNamespace_ComputesNamespace() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Components\\Test.cshtml", relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetCodeGenerationOptions(RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello"; + })); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("Hello.Components", @namespace); + } + + [Fact] + public void TryComputeNamespace_UsesIROptions_ComputesNamespace() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Components\\Test.cshtml", relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("Hello.Components", @namespace); + } + + [Fact] + public void TryComputeNamespace_NoRootNamespaceFallback_ReturnsNull() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Components\\Test.cshtml", relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: false, out var @namespace); + + // Assert + Assert.Null(@namespace); + } + + [Fact] + public void TryComputeNamespace_PrefersOptionsFromCodeDocument_ComputesNamespace() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Components\\Test.cshtml", relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetCodeGenerationOptions(RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "World"; + })); + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("World.Components", @namespace); + } + + [Fact] + public void TryComputeNamespace_SanitizesNamespaceName() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create(filePath: "C:\\Hello\\Components with space\\Test$name.cshtml", relativePath: "\\Components with space\\Test$name.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hel?o.World"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("Hel_o.World.Components_with_space", @namespace); + } + + [Fact] + public void TryComputeNamespace_RespectsNamespaceDirective() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create( + content: "@namespace My.Custom.NS", + filePath: "C:\\Hello\\Components\\Test.cshtml", + relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetFileKind(FileKinds.Component); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + }))); + + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello.World"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("My.Custom.NS", @namespace); + } + + [Fact] + public void TryComputeNamespace_RespectsImportsNamespaceDirective() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create( + filePath: "C:\\Hello\\Components\\Test.cshtml", + relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetFileKind(FileKinds.Component); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + }))); + + var importSourceDocument = TestRazorSourceDocument.Create( + content: "@namespace My.Custom.NS", + filePath: "C:\\Hello\\_Imports.razor", + relativePath: "\\_Imports.razor"); + codeDocument.SetImportSyntaxTrees(new[] + { + RazorSyntaxTree.Parse(importSourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + })) + }); + + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello.World"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("My.Custom.NS.Components", @namespace); + } + + [Fact] + public void TryComputeNamespace_RespectsImportsNamespaceDirective_SameFolder() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create( + filePath: "C:\\Hello\\Components\\Test.cshtml", + relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetFileKind(FileKinds.Component); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + }))); + + var importSourceDocument = TestRazorSourceDocument.Create( + content: "@namespace My.Custom.NS", + filePath: "C:\\Hello\\Components\\_Imports.razor", + relativePath: "\\Components\\_Imports.razor"); + codeDocument.SetImportSyntaxTrees(new[] + { + RazorSyntaxTree.Parse(importSourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + })) + }); + + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello.World"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("My.Custom.NS", @namespace); + } + + [Fact] + public void TryComputeNamespace_OverrideImportsNamespaceDirective() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create( + content: "@namespace My.Custom.OverrideNS", + filePath: "C:\\Hello\\Components\\Test.cshtml", + relativePath: "\\Components\\Test.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetFileKind(FileKinds.Component); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + }))); + + var importSourceDocument = TestRazorSourceDocument.Create( + content: "@namespace My.Custom.NS", + filePath: "C:\\Hello\\_Imports.razor", + relativePath: "\\_Imports.razor"); + codeDocument.SetImportSyntaxTrees(new[] + { + RazorSyntaxTree.Parse(importSourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + })) + }); + + var documentNode = new DocumentIntermediateNode() + { + Options = RazorCodeGenerationOptions.Create(c => + { + c.RootNamespace = "Hello.World"; + }) + }; + codeDocument.SetDocumentIntermediateNode(documentNode); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("My.Custom.OverrideNS", @namespace); + } + + [Theory] + [InlineData("/", "foo.cshtml", "Base")] + [InlineData("/", "foo/bar.cshtml", "Base.foo")] + [InlineData("/", "foo/bar/baz.cshtml", "Base.foo.bar")] + [InlineData("/foo/", "bar/baz.cshtml", "Base.bar")] + [InlineData("/Foo/", "bar/baz.cshtml", "Base.bar")] + [InlineData("c:\\", "foo.cshtml", "Base")] + [InlineData("c:\\", "foo\\bar.cshtml", "Base.foo")] + [InlineData("c:\\", "foo\\bar\\baz.cshtml", "Base.foo.bar")] + [InlineData("c:\\foo\\", "bar\\baz.cshtml", "Base.bar")] + [InlineData("c:\\Foo\\", "bar\\baz.cshtml", "Base.bar")] + public void TryComputeNamespace_ComputesNamespaceWithSuffix(string basePath, string relativePath, string expectedNamespace) + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create( + filePath: Path.Combine(basePath, relativePath), + relativePath: relativePath); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + }))); + + var importRelativePath = "_ViewImports.cshtml"; + var importSourceDocument = TestRazorSourceDocument.Create( + content: "@namespace Base", + filePath: Path.Combine(basePath, importRelativePath), + relativePath: importRelativePath); + codeDocument.SetImportSyntaxTrees(new[] + { + RazorSyntaxTree.Parse(importSourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + })) + }); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal(expectedNamespace, @namespace); + } + + [Fact] + public void TryComputeNamespace_ForNonRelatedFiles_UsesNamespaceVerbatim() + { + // Arrange + var sourceDocument = TestRazorSourceDocument.Create( + filePath: "c:\\foo\\bar\\bleh.cshtml", + relativePath: "bar\\bleh.cshtml"); + var codeDocument = TestRazorCodeDocument.Create(sourceDocument, Array.Empty()); + codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + }))); + + var importSourceDocument = TestRazorSourceDocument.Create( + content: "@namespace Base", + filePath: "c:\\foo\\baz\\bleh.cshtml", + relativePath: "baz\\bleh.cshtml"); + codeDocument.SetImportSyntaxTrees(new[] + { + RazorSyntaxTree.Parse(importSourceDocument, RazorParserOptions.Create(options => + { + options.Directives.Add(NamespaceDirective.Directive); + })) + }); + + // Act + codeDocument.TryComputeNamespace(fallbackToRootNamespace: true, out var @namespace); + + // Assert + Assert.Equal("Base", @namespace); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorCodeDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorCodeDocumentTest.cs new file mode 100644 index 0000000000..c0cce4b7c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorCodeDocumentTest.cs @@ -0,0 +1,61 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorCodeDocumentTest + { + [Fact] + public void Create() + { + // Arrange + var source = TestRazorSourceDocument.Create(); + + // Act + var code = RazorCodeDocument.Create(source); + + // Assert + Assert.Same(source, code.Source); + Assert.NotNull(code.Items); + } + + [Fact] + public void Create_WithImports() + { + // Arrange + var source = TestRazorSourceDocument.Create(); + + var imports = new RazorSourceDocument[] + { + TestRazorSourceDocument.Create(), + }; + + // Act + var code = RazorCodeDocument.Create(source, imports); + + // Assert + Assert.Same(source, code.Source); + Assert.NotNull(code.Items); + + Assert.NotSame(imports, code.Imports); + Assert.Collection(imports, d => Assert.Same(imports[0], d)); + } + + [Fact] + public void Create_WithImports_AllowsNull() + { + // Arrange + var source = TestRazorSourceDocument.Create(); + + // Act + var code = RazorCodeDocument.Create(source, imports: null); + + // Assert + Assert.Same(source, code.Source); + Assert.NotNull(code.Items); + Assert.Empty(code.Imports); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs new file mode 100644 index 0000000000..9b3af87f6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticDescriptorTest.cs @@ -0,0 +1,78 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorDiagnosticDescriptorTest + { + [Fact] + public void RazorDiagnosticDescriptor_Ctor() + { + // Arrange & Act + var descriptor = new RazorDiagnosticDescriptor("RZ0001", () => "Hello, World!", RazorDiagnosticSeverity.Error); + + // Assert + Assert.Equal("RZ0001", descriptor.Id); + Assert.Equal(RazorDiagnosticSeverity.Error, descriptor.Severity); + Assert.Equal("Hello, World!", descriptor.GetMessageFormat()); + } + + [Fact] + public void RazorDiagnosticDescriptor_Equals() + { + // Arrange + var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "a!", RazorDiagnosticSeverity.Error); + var descriptor2 = new RazorDiagnosticDescriptor("RZ0001", () => "b!", RazorDiagnosticSeverity.Error); + + // Act + var result = descriptor1.Equals(descriptor2); + + // Assert + Assert.True(result); + } + + [Fact] + public void RazorDiagnosticDescriptor_NotEquals() + { + // Arrange + var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "a!", RazorDiagnosticSeverity.Error); + var descriptor2 = new RazorDiagnosticDescriptor("RZ0002", () => "b!", RazorDiagnosticSeverity.Error); + + // Act + var result = descriptor1.Equals(descriptor2); + + // Assert + Assert.False(result); + } + + [Fact] + public void RazorDiagnosticDescriptor_HashCodesEqual() + { + // Arrange + var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "a!", RazorDiagnosticSeverity.Error); + var descriptor2 = new RazorDiagnosticDescriptor("RZ0001", () => "b!", RazorDiagnosticSeverity.Error); + + // Act + var result = descriptor1.GetHashCode() == descriptor2.GetHashCode(); + + // Assert + Assert.True(result); + } + + [Fact] + public void RazorDiagnosticDescriptor_HashCodesNotEqual() + { + // Arrange + var descriptor1 = new RazorDiagnosticDescriptor("RZ0001", () => "a!", RazorDiagnosticSeverity.Error); + var descriptor2 = new RazorDiagnosticDescriptor("RZ0002", () => "b!", RazorDiagnosticSeverity.Error); + + // Act + var result = descriptor1.GetHashCode() == descriptor2.GetHashCode(); + + // Assert + Assert.False(result); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticTest.cs new file mode 100644 index 0000000000..0ad45e8ed5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorDiagnosticTest.cs @@ -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 Microsoft.AspNetCore.Razor.Language.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorDiagnosticTest + { + [Fact] + public void Create_WithDescriptor_CreatesDefaultRazorDiagnostic() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0001", () => "a", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + // Act + var diagnostic = RazorDiagnostic.Create(descriptor, span); + + // Assert + var defaultDiagnostic = Assert.IsType(diagnostic); + Assert.Equal("RZ0001", defaultDiagnostic.Id); + Assert.Equal(RazorDiagnosticSeverity.Error, defaultDiagnostic.Severity); + Assert.Equal(span, diagnostic.Span); + } + + [Fact] + public void Create_WithDescriptor_AndArgs_CreatesDefaultRazorDiagnostic() + { + // Arrange + var descriptor = new RazorDiagnosticDescriptor("RZ0001", () => "a", RazorDiagnosticSeverity.Error); + var span = new SourceSpan("test.cs", 15, 1, 8, 5); + + // Act + var diagnostic = RazorDiagnostic.Create(descriptor, span, "Hello", "World"); + + // Assert + var defaultDiagnostic = Assert.IsType(diagnostic); + Assert.Equal("RZ0001", defaultDiagnostic.Id); + Assert.Equal(RazorDiagnosticSeverity.Error, defaultDiagnostic.Severity); + Assert.Equal(span, diagnostic.Span); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorEngineBuilderExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorEngineBuilderExtensionsTest.cs new file mode 100644 index 0000000000..3df637cadc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorEngineBuilderExtensionsTest.cs @@ -0,0 +1,98 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ +#pragma warning disable CS0618 // Type or member is obsolete + public class RazorEngineBuilderExtensionsTest + { + [Fact] + public void AddDirective_ExistingFeature_UsesFeature() + { + // Arrange + var expected = new DefaultRazorDirectiveFeature(); + var engine = RazorEngine.CreateEmpty(b => + { + b.Features.Add(expected); + + // Act + b.AddDirective(DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine)); + }); + + // Assert + var actual = Assert.Single(engine.Features.OfType()); + Assert.Same(expected, actual); + + var directive = Assert.Single(actual.Directives); + Assert.Equal("test", directive.Directive); + } + + [Fact] + public void AddDirective_NoFeature_CreatesFeature() + { + // Arrange + var engine = RazorEngine.CreateEmpty(b => + { + // Act + b.AddDirective(DirectiveDescriptor.CreateDirective("test", DirectiveKind.SingleLine)); + }); + + // Assert + var actual = Assert.Single(engine.Features.OfType()); + Assert.IsType(actual); + + var directive = Assert.Single(actual.Directives); + Assert.Equal("test", directive.Directive); + } + + [Fact] + public void AddTargetExtensions_ExistingFeature_UsesFeature() + { + // Arrange + var extension = new MyTargetExtension(); + + var expected = new DefaultRazorTargetExtensionFeature(); + var engine = RazorEngine.CreateEmpty(b => + { + b.Features.Add(expected); + + // Act + b.AddTargetExtension(extension); + }); + + // Assert + var actual = Assert.Single(engine.Features.OfType()); + Assert.Same(expected, actual); + + Assert.Same(extension, Assert.Single(actual.TargetExtensions)); + } + + [Fact] + public void AddTargetExtensions_NoFeature_CreatesFeature() + { + // Arrange + var extension = new MyTargetExtension(); + + var engine = RazorEngine.CreateEmpty(b => + { + // Act + b.AddTargetExtension(extension); + }); + + // Assert + var actual = Assert.Single(engine.Features.OfType()); + Assert.IsType(actual); + + Assert.Same(extension, Assert.Single(actual.TargetExtensions)); + } + + private class MyTargetExtension : ICodeTargetExtension + { + } + } +#pragma warning restore CS0618 // Type or member is obsolete +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorEngineTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorEngineTest.cs new file mode 100644 index 0000000000..225f73f342 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorEngineTest.cs @@ -0,0 +1,233 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Extensions; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ +#pragma warning disable CS0618 // Type or member is obsolete + public class RazorEngineTest + { + [Fact] + public void Create_NoArg_CreatesDefaultRuntimeEngine() + { + // Arrange + // Act + var engine = RazorEngine.Create(); + + // Assert + Assert.IsType(engine); + AssertDefaultRuntimeFeatures(engine.Features); + AssertDefaultRuntimePhases(engine.Phases); + AssertDefaultRuntimeTargetExtensions(engine); + } + + [Fact] + public void CreateDesignTime_NoArg_CreatesDefaultDesignTimeEngine() + { + // Arrange + // Act + var engine = RazorEngine.CreateDesignTime(); + + // Assert + Assert.IsType(engine); + AssertDefaultDesignTimeFeatures(engine.Features); + AssertDefaultDesignTimePhases(engine.Phases); + AssertDefaultDesignTimeTargetExtensions(engine); + } + + [Fact] + public void Create_Null_CreatesDefaultRuntimeEngine() + { + // Arrange + // Act + var engine = RazorEngine.Create(configure: null); + + // Assert + Assert.IsType(engine); + AssertDefaultRuntimeFeatures(engine.Features); + AssertDefaultRuntimePhases(engine.Phases); + AssertDefaultRuntimeTargetExtensions(engine); + } + + [Fact] + public void CreateDesignTime_Null_CreatesDefaultDesignTimeEngine() + { + // Arrange + // Act + var engine = RazorEngine.CreateDesignTime(configure: null); + + // Assert + Assert.IsType(engine); + AssertDefaultDesignTimeFeatures(engine.Features); + AssertDefaultDesignTimePhases(engine.Phases); + AssertDefaultDesignTimeTargetExtensions(engine); + } + + [Fact] + public void Create_Lambda_AddsFeaturesAndPhases() + { + // Arrange + IRazorEngineFeature[] features = null; + IRazorEnginePhase[] phases = null; + + // Act + var engine = RazorEngine.Create(builder => + { + builder.Features.Clear(); + builder.Phases.Clear(); + + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + + builder.Phases.Add(Mock.Of()); + builder.Phases.Add(Mock.Of()); + + features = builder.Features.ToArray(); + phases = builder.Phases.ToArray(); + }); + + // Assert + Assert.Collection( + engine.Features, + f => Assert.Same(features[0], f), + f => Assert.Same(features[1], f)); + + Assert.Collection( + engine.Phases, + p => Assert.Same(phases[0], p), + p => Assert.Same(phases[1], p)); + } + + [Fact] + public void CreateDesignTime_Lambda_AddsFeaturesAndPhases() + { + // Arrange + IRazorEngineFeature[] features = null; + IRazorEnginePhase[] phases = null; + + // Act + var engine = RazorEngine.CreateDesignTime(builder => + { + builder.Features.Clear(); + builder.Phases.Clear(); + + builder.Features.Add(Mock.Of()); + builder.Features.Add(Mock.Of()); + + builder.Phases.Add(Mock.Of()); + builder.Phases.Add(Mock.Of()); + + features = builder.Features.ToArray(); + phases = builder.Phases.ToArray(); + }); + + // Assert + Assert.Collection( + engine.Features, + f => Assert.Same(features[0], f), + f => Assert.Same(features[1], f)); + + Assert.Collection( + engine.Phases, + p => Assert.Same(phases[0], p), + p => Assert.Same(phases[1], p)); + } + + private static void AssertDefaultRuntimeTargetExtensions(RazorEngine engine) + { + var feature = engine.Features.OfType().FirstOrDefault(); + Assert.NotNull(feature); + + Assert.Collection( + feature.TargetExtensions, + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension)); + } + + private static void AssertDefaultRuntimeFeatures(IEnumerable features) + { + Assert.Collection( + features, + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature)); + } + + private static void AssertDefaultRuntimePhases(IReadOnlyList phases) + { + Assert.Collection( + phases, + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase)); + } + + private static void AssertDefaultDesignTimeTargetExtensions(RazorEngine engine) + { + var feature = engine.Features.OfType().FirstOrDefault(); + Assert.NotNull(feature); + + Assert.Collection( + feature.TargetExtensions, + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension)); + } + + private static void AssertDefaultDesignTimeFeatures(IEnumerable features) + { + Assert.Collection( + features, + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature)); + } + + private static void AssertDefaultDesignTimePhases(IReadOnlyList phases) + { + Assert.Collection( + phases, + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase)); + } + } +#pragma warning restore CS0618 // Type or member is obsolete +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs new file mode 100644 index 0000000000..5b09826ebf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs @@ -0,0 +1,141 @@ +// 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.Linq; +using System.Reflection; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorLanguageVersionTest + { + [Fact] + public void TryParseInvalid() + { + // Arrange + var value = "not-version"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var _); + + // Assert + Assert.False(result); + } + + [Fact] + public void TryParse10() + { + // Arrange + var value = "1.0"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_1_0, version); + } + + [Fact] + public void TryParse11() + { + // Arrange + var value = "1.1"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_1_1, version); + } + + [Fact] + public void TryParse20() + { + // Arrange + var value = "2.0"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_2_0, version); + } + + [Fact] + public void TryParse21() + { + // Arrange + var value = "2.1"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_2_1, version); + } + + [Fact] + public void TryParse30() + { + // Arrange + var value = "3.0"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_3_0, version); + } + + [Fact] + public void TryParseLatest() + { + // Arrange + var value = "Latest"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_3_0, version); + } + + [Fact] + public void TryParseExperimental() + { + // Arrange + var value = "experimental"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Experimental, version); + } + + [Fact] + public void LatestPointsToNewestVersion() + { + // Arrange + var v = RazorLanguageVersion.Parse("latest"); + var versions = typeof(RazorLanguageVersion).GetFields(BindingFlags.Public | BindingFlags.Static) + .Where(f => f.Name.StartsWith("Version_")) + .Select(f => f.GetValue(obj: null)) + .Cast(); + + // Act & Assert + Assert.NotEmpty(versions); + foreach (var version in versions) + { + Assert.True(version.CompareTo(v) <= 0, $"RazorLanguageVersion {version} has a higher version than RazorLanguageVersion.Latest"); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorParserFeatureFlagsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorParserFeatureFlagsTest.cs new file mode 100644 index 0000000000..d645d45ced --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorParserFeatureFlagsTest.cs @@ -0,0 +1,49 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorParserFeatureFlagsTest + { + [Fact] + public void Create_LatestVersion_AllowsLatestFeatures() + { + // Arrange & Act + var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Latest, FileKinds.Legacy); + + // Assert + Assert.True(context.AllowComponentFileKind); + Assert.True(context.AllowRazorInAllCodeBlocks); + Assert.True(context.AllowUsingVariableDeclarations); + Assert.True(context.AllowNullableForgivenessOperator); + } + + [Fact] + public void Create_21Version_Allows21Features() + { + // Arrange & Act + var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_1, FileKinds.Legacy); + + // Assert + Assert.True(context.AllowMinimizedBooleanTagHelperAttributes); + Assert.True(context.AllowHtmlCommentsInTagHelpers); + } + + [Fact] + public void Create_OldestVersion_DoesNotAllowLatestFeatures() + { + // Arrange & Act + var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_1_0, FileKinds.Legacy); + + // Assert + Assert.False(context.AllowMinimizedBooleanTagHelperAttributes); + Assert.False(context.AllowHtmlCommentsInTagHelpers); + Assert.False(context.AllowComponentFileKind); + Assert.False(context.AllowRazorInAllCodeBlocks); + Assert.False(context.AllowUsingVariableDeclarations); + Assert.False(context.AllowNullableForgivenessOperator); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineBuilderExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineBuilderExtensionsTest.cs new file mode 100644 index 0000000000..f0a57128c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineBuilderExtensionsTest.cs @@ -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 Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineBuilderExtensionsTest + { + [Fact] + public void SetImportFeature_SetsTheImportFeature() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var testFeature1 = Mock.Of(); + var testFeature2 = Mock.Of(); + builder.Features.Add(testFeature1); + builder.Features.Add(testFeature2); + var newFeature = Mock.Of(); + + // Act + builder.SetImportFeature(newFeature); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(newFeature, feature); + } + + [Fact] + public void AddTargetExtension_CreatesAndAddsToTargetExtensionFeatureIfItDoesNotExist() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var expectedExtension = Mock.Of(); + + // Act + builder.AddTargetExtension(expectedExtension); + + // Assert + var feature = Assert.Single(builder.Features); + var codeTargetExtensionFeature = Assert.IsAssignableFrom(feature); + var extensions = Assert.Single(codeTargetExtensionFeature.TargetExtensions); + Assert.Same(expectedExtension, extensions); + } + + [Fact] + public void AddTargetExtension_UsesExistingFeatureIfExistsAndAddsTo() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var codeTargetExtensionFeature = new DefaultRazorTargetExtensionFeature(); + builder.Features.Add(codeTargetExtensionFeature); + var expectedExtension = Mock.Of(); + + // Act + builder.AddTargetExtension(expectedExtension); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(codeTargetExtensionFeature, feature); + var extensions = Assert.Single(codeTargetExtensionFeature.TargetExtensions); + Assert.Same(expectedExtension, extensions); + } + + [Fact] + public void AddDirective_CreatesAndAddsToDirectiveFeatureIfItDoesNotExist() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var expectedDirective = Mock.Of(); + + // Act + builder.AddDirective(expectedDirective); + + // Assert + var feature = Assert.Single(builder.Features); + var directiveFeature = Assert.IsAssignableFrom(feature); + var directive = Assert.Single(directiveFeature.Directives); + Assert.Same(expectedDirective, directive); + } + + [Fact] + public void AddDirective_UsesExistingFeatureIfExistsAndAddsTo() + { + // Arrange + var builder = new DefaultRazorProjectEngineBuilder(RazorConfiguration.Default, Mock.Of()); + var directiveFeature = new DefaultRazorDirectiveFeature(); + builder.Features.Add(directiveFeature); + var expecteDirective = Mock.Of(); + + // Act + builder.AddDirective(expecteDirective); + + // Assert + var feature = Assert.Single(builder.Features); + Assert.Same(directiveFeature, feature); + var directive = Assert.Single(directiveFeature.Directives); + Assert.Same(expecteDirective, directive); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineFeatureBaseTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineFeatureBaseTest.cs new file mode 100644 index 0000000000..8344e787c7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineFeatureBaseTest.cs @@ -0,0 +1,34 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineFeatureBaseTest + { + [Fact] + public void ProjectEngineSetter_CallsOnInitialized() + { + // Arrange + var testFeature = new TestFeature(); + + // Act + testFeature.ProjectEngine = Mock.Of(); + + // Assert + Assert.Equal(1, testFeature.InitializationCount); + } + + private class TestFeature : RazorProjectEngineFeatureBase + { + public int InitializationCount { get; private set; } + + protected override void OnInitialized() + { + InitializationCount++; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs new file mode 100644 index 0000000000..c9fa4504cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs @@ -0,0 +1,115 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Components; +using Microsoft.AspNetCore.Razor.Language.Extensions; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectEngineTest + { + [Fact] + public void CreateDesignTime_Lambda_AddsFeaturesAndPhases() + { + // Arrange + + // Act + var engine = RazorProjectEngine.Create(RazorConfiguration.Default, Mock.Of()); + + // Assert + AssertDefaultPhases(engine); + AssertDefaultFeatures(engine); + AssertDefaultDirectives(engine); + AssertDefaultTargetExtensions(engine); + } + + private static void AssertDefaultPhases(RazorProjectEngine engine) + { + Assert.Collection( + engine.Phases, + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase), + phase => Assert.IsType(phase)); + } + + private static void AssertDefaultFeatures(RazorProjectEngine engine) + { + var features = engine.EngineFeatures.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + features, + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature), + feature => Assert.IsType(feature)); + } + + private static void AssertDefaultDirectives(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + Assert.Collection( + feature.Directives, + directive => Assert.Same(FunctionsDirective.Directive, directive), + directive => Assert.Same(ImplementsDirective.Directive, directive), + directive => Assert.Same(InheritsDirective.Directive, directive), + directive => Assert.Same(NamespaceDirective.Directive, directive), + directive => Assert.Same(AttributeDirective.Directive, directive)); + } + + private static void AssertDefaultTargetExtensions(RazorProjectEngine engine) + { + var feature = engine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + + var extensions = feature.TargetExtensions.OrderBy(f => f.GetType().Name).ToArray(); + Assert.Collection( + extensions, + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension), + extension => Assert.IsType(extension)); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectItemTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectItemTest.cs new file mode 100644 index 0000000000..e1e95b2cc0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectItemTest.cs @@ -0,0 +1,104 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectItemTest + { + [Fact] + public void CombinedPath_ReturnsPathIfBasePathIsEmpty() + { + // Arrange + var emptyBasePath = "/"; + var path = "/foo/bar.cshtml"; + var projectItem = new TestRazorProjectItem(path, basePath: emptyBasePath); + + // Act + var combinedPath = projectItem.CombinedPath; + + // Assert + Assert.Equal(path, combinedPath); + } + + [Theory] + [InlineData("/root", "/root/foo/bar.cshtml")] + [InlineData("root/subdir", "root/subdir/foo/bar.cshtml")] + public void CombinedPath_ConcatsPaths(string basePath, string expected) + { + // Arrange + var path = "/foo/bar.cshtml"; + var projectItem = new TestRazorProjectItem(path, basePath: basePath); + + // Act + var combinedPath = projectItem.CombinedPath; + + // Assert + Assert.Equal(expected, combinedPath); + } + + [Theory] + [InlineData("/Home/Index")] + [InlineData("EditUser")] + public void Extension_ReturnsNullIfFileDoesNotHaveExtension(string path) + { + // Arrange + var projectItem = new TestRazorProjectItem(path, basePath: "/views"); + + // Act + var extension = projectItem.Extension; + + // Assert + Assert.Null(extension); + } + + [Theory] + [InlineData("/Home/Index.cshtml", ".cshtml")] + [InlineData("/Home/Index.en-gb.cshtml", ".cshtml")] + [InlineData("EditUser.razor", ".razor")] + public void Extension_ReturnsFileExtension(string path, string expected) + { + // Arrange + var projectItem = new TestRazorProjectItem(path, basePath: "/views"); + + // Act + var extension = projectItem.Extension; + + // Assert + Assert.Equal(expected, extension); + } + + [Theory] + [InlineData("Home/Index.cshtml", "Index.cshtml")] + [InlineData("/Accounts/Customers/Manage-en-us.razor", "Manage-en-us.razor")] + public void FileName_ReturnsFileNameWithExtension(string path, string expected) + { + // Arrange + var projectItem = new TestRazorProjectItem(path, basePath: "/"); + + // Act + var fileName = projectItem.FileName; + + // Assert + Assert.Equal(expected, fileName); + } + + [Theory] + [InlineData("Home/Index", "Home/Index")] + [InlineData("Home/Index.cshtml", "Home/Index")] + [InlineData("/Accounts/Customers/Manage.en-us.razor", "/Accounts/Customers/Manage.en-us")] + [InlineData("/Accounts/Customers/Manage-en-us.razor", "/Accounts/Customers/Manage-en-us")] + public void PathWithoutExtension_ExcludesExtension(string path, string expected) + { + // Arrange + var projectItem = new TestRazorProjectItem(path, basePath: "/"); + + // Act + var fileName = projectItem.FilePathWithoutExtension; + + // Assert + Assert.Equal(expected, fileName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectTest.cs new file mode 100644 index 0000000000..7831db3521 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectTest.cs @@ -0,0 +1,333 @@ +// 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.Testing; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorProjectTest + { + [Fact] + public void NormalizeAndEnsureValidPath_DoesNotModifyPath() + { + // Arrange + var project = new TestRazorProject(); + + // Act + var path = project.NormalizeAndEnsureValidPath("/Views/Home/Index.cshtml"); + + // Assert + Assert.Equal("/Views/Home/Index.cshtml", path); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void NormalizeAndEnsureValidPath_ThrowsIfPathIsNullOrEmpty(string path) + { + // Arrange + var project = new TestRazorProject(); + + // Act and Assert + ExceptionAssert.ThrowsArgumentNullOrEmptyString(() => project.NormalizeAndEnsureValidPath(path), "path"); + } + + [Theory] + [InlineData("foo")] + [InlineData("~/foo")] + [InlineData("\\foo")] + public void NormalizeAndEnsureValidPath_ThrowsIfPathDoesNotStartWithForwardSlash(string path) + { + // Arrange + var project = new TestRazorProject(); + + // Act and Assert + ExceptionAssert.ThrowsArgument( + () => project.NormalizeAndEnsureValidPath(path), + "path", + "Path must begin with a forward slash '/'."); + } + + [Fact] + public void FindHierarchicalItems_ReturnsEmptySequenceIfPathIsAtRoot() + { + // Arrange + var project = new TestRazorProject(); + + // Act + var result = project.FindHierarchicalItems("/", "File.cshtml"); + + // Assert + Assert.Empty(result); + } + + [Theory] + [InlineData("_ViewStart.cshtml")] + [InlineData("_ViewImports.cshtml")] + public void FindHierarchicalItems_ReturnsItemsForPath(string fileName) + { + // Arrange + var path = "/Views/Home/Index.cshtml"; + var items = new List + { + CreateProjectItem($"/{fileName}"), + CreateProjectItem($"/Views/{fileName}"), + CreateProjectItem($"/Views/Home/{fileName}") + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(path, $"{fileName}"); + + // Assert + Assert.Collection( + result, + item => Assert.Equal($"/Views/Home/{fileName}", item.FilePath), + item => Assert.Equal($"/Views/{fileName}", item.FilePath), + item => Assert.Equal($"/{fileName}", item.FilePath)); + } + + [Fact] + public void FindHierarchicalItems_ReturnsItemsForPathAtRoot() + { + // Arrange + var path = "/Index.cshtml"; + var items = new List + { + CreateProjectItem("/File.cshtml") + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(path, "File.cshtml"); + + // Assert + Assert.Collection( + result, + item => Assert.Equal("/File.cshtml", item.FilePath)); + } + + [Fact] + public void FindHierarchicalItems_DoesNotIncludePassedInItem() + { + // Arrange + var path = "/Areas/MyArea/Views/Home/File.cshtml"; + var items = new List + { + CreateProjectItem("/Areas/MyArea/Views/Home/File.cshtml"), + CreateProjectItem("/Areas/MyArea/Views/File.cshtml"), + CreateProjectItem("/Areas/MyArea/File.cshtml"), + CreateProjectItem("/Areas/File.cshtml"), + CreateProjectItem("/File.cshtml"), + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(path, "File.cshtml"); + + // Assert + Assert.Collection( + result, + item => Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath), + item => Assert.Equal("/Areas/MyArea/File.cshtml", item.FilePath), + item => Assert.Equal("/Areas/File.cshtml", item.FilePath), + item => Assert.Equal("/File.cshtml", item.FilePath)); + } + + [Fact] + public void FindHierarchicalItems_ReturnsEmptySequenceIfPassedInItemWithFileNameIsAtRoot() + { + // Arrange + var path = "/File.cshtml"; + var items = new List + { + CreateProjectItem("/File.cshtml") + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(path, "File.cshtml"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void FindHierarchicalItems_IncludesNonExistentFiles() + { + // Arrange + var path = "/Areas/MyArea/Views/Home/Test.cshtml"; + var items = new List + { + CreateProjectItem("/Areas/MyArea/File.cshtml"), + CreateProjectItem("/File.cshtml") + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(path, "File.cshtml"); + + // Assert + Assert.Collection( + result, + item => + { + Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }, + item => + { + Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }, + item => + { + Assert.Equal("/Areas/MyArea/File.cshtml", item.FilePath); + Assert.True(item.Exists); + }, + item => + { + Assert.Equal("/Areas/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }, + item => + { + Assert.Equal("/File.cshtml", item.FilePath); + Assert.True(item.Exists); + }); + } + + [Theory] + [InlineData("/Areas")] + [InlineData("/Areas/")] + public void FindHierarchicalItems_WithBasePath(string basePath) + { + // Arrange + var path = "/Areas/MyArea/Views/Home/Test.cshtml"; + var items = new List + { + CreateProjectItem("/Areas/MyArea/File.cshtml"), + CreateProjectItem("/File.cshtml") + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(basePath, path, "File.cshtml"); + + // Assert + Assert.Collection( + result, + item => + { + Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }, + item => + { + Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }, + item => + { + Assert.Equal("/Areas/MyArea/File.cshtml", item.FilePath); + Assert.True(item.Exists); + }, + item => + { + Assert.Equal("/Areas/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }); + } + + [Theory] + [InlineData("/Areas/MyArea/Views")] + [InlineData("/Areas/MyArea/Views/")] + public void FindHierarchicalItems_WithNestedBasePath(string basePath) + { + // Arrange + var path = "/Areas/MyArea/Views/Home/Test.cshtml"; + var items = new List + { + CreateProjectItem("/Areas/MyArea/File.cshtml"), + CreateProjectItem("/File.cshtml") + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(basePath, path, "File.cshtml"); + + // Assert + Assert.Collection( + result, + item => + { + Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }, + item => + { + Assert.Equal("/Areas/MyArea/Views/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }); + } + + [Theory] + [InlineData("/Areas/MyArea/Views/Home")] + [InlineData("/Areas/MyArea/Views/Home/")] + public void FindHierarchicalItems_WithFileAtBasePath(string basePath) + { + // Arrange + var path = "/Areas/MyArea/Views/Home/Test.cshtml"; + var items = new List + { + CreateProjectItem("/Areas/MyArea/File.cshtml"), + CreateProjectItem("/File.cshtml"), + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(basePath, path, "File.cshtml"); + + // Assert + Assert.Collection( + result, + item => + { + Assert.Equal("/Areas/MyArea/Views/Home/File.cshtml", item.FilePath); + Assert.False(item.Exists); + }); + } + + [Fact] + public void FindHierarchicalItems_ReturnsEmptySequenceIfPathIsNotASubPathOfBasePath() + { + // Arrange + var basePath = "/Pages"; + var path = "/Areas/MyArea/Views/Home/Test.cshtml"; + var items = new List + { + CreateProjectItem("/Areas/MyArea/File.cshtml"), + CreateProjectItem("/File.cshtml"), + }; + var project = new TestRazorProject(items); + + // Act + var result = project.FindHierarchicalItems(basePath, path, "File.cshtml"); + + // Assert + Assert.Empty(result); + } + + private RazorProjectItem CreateProjectItem(string path) + { + var projectItem = new Mock(); + projectItem.SetupGet(f => f.FilePath).Returns(path); + projectItem.SetupGet(f => f.Exists).Returns(true); + return projectItem.Object; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorSourceDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorSourceDocumentTest.cs new file mode 100644 index 0000000000..9c05f2851c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorSourceDocumentTest.cs @@ -0,0 +1,219 @@ +// 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.Text; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class RazorSourceDocumentTest + { + [Fact] + public void ReadFrom() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(); + + // Act + var document = RazorSourceDocument.ReadFrom(content, "file.cshtml"); + + // Assert + Assert.IsType(document); + Assert.Equal("file.cshtml", document.FilePath); + Assert.Same(Encoding.UTF8, document.Encoding); + } + + [Fact] + public void ReadFrom_WithEncoding() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); + + // Act + var document = RazorSourceDocument.ReadFrom(content, "file.cshtml", Encoding.UTF32); + + // Assert + Assert.Equal("file.cshtml", document.FilePath); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + + [Fact] + public void ReadFrom_WithProperties() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); + var properties = new RazorSourceDocumentProperties("c:\\myapp\\filePath.cshtml", "filePath.cshtml"); + + // Act + var document = RazorSourceDocument.ReadFrom(content, Encoding.UTF32, properties); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + + [Fact] + public void ReadFrom_EmptyStream_WithEncoding() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(content: string.Empty, encoding: Encoding.UTF32); + + // Act + var document = RazorSourceDocument.ReadFrom(content, "file.cshtml", Encoding.UTF32); + + // Assert + Assert.Equal("file.cshtml", document.FilePath); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + + [Fact] + public void ReadFrom_ProjectItem() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", "filePath.cshtml", "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_NoRelativePath() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToRelativePath() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", relativePhysicalPath: "filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToFileName() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void Create_WithoutEncoding() + { + // Arrange + var content = "Hello world"; + var fileName = "some-file-name"; + + // Act + var document = RazorSourceDocument.Create(content, fileName); + + // Assert + Assert.Equal(fileName, document.FilePath); + Assert.Equal(content, ReadContent(document)); + Assert.Same(Encoding.UTF8, document.Encoding); + } + + [Fact] + public void Create_WithEncoding() + { + // Arrange + var content = "Hello world"; + var fileName = "some-file-name"; + var encoding = Encoding.UTF32; + + // Act + var document = RazorSourceDocument.Create(content, fileName, encoding); + + // Assert + Assert.Equal(fileName, document.FilePath); + Assert.Equal(content, ReadContent(document)); + Assert.Same(encoding, document.Encoding); + } + + [Fact] + public void Create_WithProperties() + { + // Arrange + var content = "Hello world"; + var properties = new RazorSourceDocumentProperties("c:\\myapp\\filePath.cshtml", "filePath.cshtml"); + + // Act + var document = RazorSourceDocument.Create(content, Encoding.UTF32, properties); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(content, ReadContent(document)); + Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding); + } + + [Fact] + public void ReadFrom_WithProjectItem_FallbackToFilePath_WhenRelativePhysicalPathIsNull() + { + // Arrange + var filePath = "filePath.cshtml"; + var projectItem = new TestRazorProjectItem(filePath, relativePhysicalPath: null); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal(filePath, document.FilePath); + Assert.Equal(filePath, document.RelativePath); + } + + [Fact] + public void ReadFrom_WithProjectItem_UsesRelativePhysicalPath() + { + // Arrange + var filePath = "filePath.cshtml"; + var relativePhysicalPath = "relative-path.cshtml"; + var projectItem = new TestRazorProjectItem(filePath, relativePhysicalPath: relativePhysicalPath); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal(relativePhysicalPath, document.FilePath); + Assert.Equal(relativePhysicalPath, document.RelativePath); + } + + private static string ReadContent(RazorSourceDocument razorSourceDocument) + { + var buffer = new char[razorSourceDocument.Length]; + razorSourceDocument.CopyTo(0, buffer, 0, buffer.Length); + + return new string(buffer); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorSyntaxTreeTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorSyntaxTreeTest.cs new file mode 100644 index 0000000000..ed0bf3fb26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorSyntaxTreeTest.cs @@ -0,0 +1,63 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language.Syntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Test +{ + public class RazorSyntaxTreeTest + { + [Fact] + public void Parse_CanParseEmptyDocument() + { + // Arrange + var source = TestRazorSourceDocument.Create(string.Empty); + + // Act + var syntaxTree = RazorSyntaxTree.Parse(source); + + // Assert + Assert.NotNull(syntaxTree); + Assert.Empty(syntaxTree.Diagnostics); + } + + [Fact] + public void Parse_NodesReturnCorrectFilePath() + { + // Arrange + var filePath = "test.cshtml"; + var source = TestRazorSourceDocument.Create("@if (true) { @if(false) {
        @something.
        } }", filePath: filePath); + + // Act + var syntaxTree = RazorSyntaxTree.Parse(source); + + // Assert + Assert.Empty(syntaxTree.Diagnostics); + Assert.NotNull(syntaxTree); + + var children = syntaxTree.Root.DescendantNodes(); + Assert.All(children, node => Assert.Equal(filePath, node.GetSourceLocation(source).FilePath)); + } + + [Fact] + public void Parse_UseDirectiveTokenizer_ParsesUntilFirstDirective() + { + // Arrange + var source = TestRazorSourceDocument.Create("\r\n \r\n @*SomeComment*@ \r\n @tagHelperPrefix \"SomePrefix\"\r\n\r\n@if (true) {\r\n @if(false) {
        @something.
        } \r\n}"); + var options = RazorParserOptions.Create(builder => builder.ParseLeadingDirectives = true); + + // Act + var syntaxTree = RazorSyntaxTree.Parse(source, options); + + // Assert + var root = syntaxTree.Root; + Assert.NotNull(syntaxTree); + Assert.Equal(61, root.EndPosition); + Assert.Single(root.DescendantNodes().Where(n => n is RazorDirectiveBodySyntax body && body.Keyword.GetContent() == "tagHelperPrefix")); + Assert.Empty(root.DescendantNodes().Where(n => n is MarkupElementSyntax)); + Assert.Empty(syntaxTree.Diagnostics); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceChangeTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceChangeTest.cs new file mode 100644 index 0000000000..2d829be381 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceChangeTest.cs @@ -0,0 +1,198 @@ +// 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.Legacy; +using Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class SourceChangeTest + { + [Fact] + public void SourceChange_ConstructorSetsDefaults_WhenNotProvided() + { + // Arrange & Act + var change = new SourceChange(15, 7, "Hello"); + + // Assert + Assert.Equal(15, change.Span.AbsoluteIndex); + Assert.Equal(-1, change.Span.CharacterIndex); + Assert.Null(change.Span.FilePath); + Assert.Equal(7, change.Span.Length); + Assert.Equal(-1, change.Span.LineIndex); + Assert.Equal("Hello", change.NewText); + } + + [Fact] + public void IsDelete_IsTrue_WhenOldLengthIsPositive_AndNewLengthIsZero() + { + // Arrange & Act + var change = new SourceChange(3, 5, string.Empty); + + // Assert + Assert.True(change.IsDelete); + } + + [Fact] + public void IsInsert_IsTrue_WhenOldLengthIsZero_AndNewLengthIsPositive() + { + // Arrange & Act + var change = new SourceChange(3, 0, "Hello"); + + // Assert + Assert.True(change.IsInsert); + } + + [Fact] + public void IsReplace_IsTrue_WhenOldLengthIsPositive_AndNewLengthIsPositive() + { + // Arrange & Act + var change = new SourceChange(3, 5, "Hello"); + + // Assert + Assert.True(change.IsReplace); + } + + [Fact] + public void GetEditedContent_ForDelete_ReturnsNewContent() + { + // Arrange + var text = "Hello, World"; + + var change = new SourceChange(2, 2, string.Empty); + + // Act + var result = change.GetEditedContent(text, 1); + + // Act + Assert.Equal("Hlo, World", result); + } + + [Fact] + public void GetEditedContent_ForInsert_ReturnsNewContent() + { + // Arrange + var text = "Hello, World"; + + var change = new SourceChange(2, 0, "heyo"); + + // Act + var result = change.GetEditedContent(text, 1); + + // Act + Assert.Equal("Hheyoello, World", result); + } + + [Fact] + public void GetEditedContent_ForReplace_ReturnsNewContent() + { + // Arrange + var text = "Hello, World"; + + var change = new SourceChange(2, 2, "heyo"); + + // Act + var result = change.GetEditedContent(text, 1); + + // Act + Assert.Equal("Hheyolo, World", result); + } + + [Fact] + public void GetEditedContent_SyntaxNode_ReturnsNewContent() + { + // Arrange + var builder = SyntaxListBuilder.Create(); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); + + var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(); + + var change = new SourceChange(2, 2, "heyo"); + + // Act + var result = change.GetEditedContent(node); + + // Act + Assert.Equal("Heheyoo, World", result); + } + + [Fact] + public void GetOffSet_SpanIsOwner_ReturnsOffset() + { + // Arrange + var builder = SyntaxListBuilder.Create(); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); + + var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13); + + var change = new SourceChange(15, 2, "heyo"); + + // Act + var result = change.GetOffset(node); + + // Act + Assert.Equal(2, result); + } + + [Fact] + public void GetOffSet_SpanIsNotOwnerOfChange_ThrowsException() + { + // Arrange + var builder = SyntaxListBuilder.Create(); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); + + var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13); + + var change = new SourceChange(12, 2, "heyo"); + + var expected = $"The node '{node}' is not the owner of change '{change}'."; + + // Act & Assert + var exception = Assert.Throws(() => { change.GetOffset(node); }); + Assert.Equal(expected, exception.Message); + } + + [Fact] + public void GetOrigninalText_SpanIsOwner_ReturnsContent() + { + // Arrange + var builder = SyntaxListBuilder.Create(); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); + + var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13); + + var change = new SourceChange(15, 2, "heyo"); + + // Act + var result = change.GetOriginalText(node); + + // Act + Assert.Equal("ll", result); + } + + [Fact] + public void GetOrigninalText_SpanIsOwner_ReturnsContent_ZeroLengthSpan() + { + // Arrange + var builder = SyntaxListBuilder.Create(); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); + builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); + + var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13); + + var change = new SourceChange(15, 0, "heyo"); + + // Act + var result = change.GetOriginalText(node); + + // Act + Assert.Equal(string.Empty, result); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceLocationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceLocationTest.cs new file mode 100644 index 0000000000..c2401c56b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceLocationTest.cs @@ -0,0 +1,110 @@ +// 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.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class SourceLocationTest + { + [Fact] + public void ConstructorWithLineAndCharacterIndexSetsAssociatedProperties() + { + // Act + var loc = new SourceLocation(0, 42, 24); + + // Assert + Assert.Null(loc.FilePath); + Assert.Equal(0, loc.AbsoluteIndex); + Assert.Equal(42, loc.LineIndex); + Assert.Equal(24, loc.CharacterIndex); + } + + [Fact] + public void Constructor_SetsFilePathAndIndexes() + { + // Arrange + var filePath = "some-file-path"; + var absoluteIndex = 133; + var lineIndex = 23; + var characterIndex = 12; + + // Act + var sourceLocation = new SourceLocation(filePath, absoluteIndex, lineIndex, characterIndex); + + // Assert + Assert.Equal(filePath, sourceLocation.FilePath); + Assert.Equal(absoluteIndex, sourceLocation.AbsoluteIndex); + Assert.Equal(lineIndex, sourceLocation.LineIndex); + Assert.Equal(characterIndex, sourceLocation.CharacterIndex); + } + + [Theory] + [InlineData(null)] + [InlineData("some-file")] + public void GetHashCode_ReturnsSameValue_WhenEqual(string path) + { + // Arrange + var sourceLocationA = new SourceLocation(path, 10, 3, 4); + var sourceLocationB = new SourceLocation(path, 10, 3, 4); + var sourceLocationC = new SourceLocation(path, 10, 45, 8754); + + // Act + var hashCodeA = sourceLocationA.GetHashCode(); + var hashCodeB = sourceLocationB.GetHashCode(); + var hashCodeC = sourceLocationC.GetHashCode(); + + // Assert + Assert.Equal(hashCodeA, hashCodeB); + Assert.Equal(hashCodeA, hashCodeC); + } + + [Fact] + public void Equals_ReturnsFalse_FilePathsNullAndAbsoluteIndicesMatch() + { + // Arrange + var sourceLocationA = new SourceLocation(10, 3, 4); + var sourceLocationB = new SourceLocation(10, 45, 8754); + + // Act + var result = sourceLocationA.Equals(sourceLocationB); + + // Assert + Assert.False(result); + } + + [Fact] + public void Equals_ReturnsFalse_IfFilePathIsDifferent() + { + // Arrange + var sourceLocationA = new SourceLocation(10, 3, 4); + var sourceLocationB = new SourceLocation("different-file", 10, 3, 4); + + // Act + var result = sourceLocationA.Equals(sourceLocationB); + + // Assert + Assert.False(result); + } + + [Theory] + [InlineData(null)] + [InlineData("some-file")] + public void Equals_ReturnsTrue_IfFilePathAndIndexesAreSame(string path) + { + // Arrange + var sourceLocationA = new SourceLocation(path, 10, 3, 4); + var sourceLocationB = new SourceLocation(path, 10, 3, 4); + var sourceLocationC = new SourceLocation("different-path", 10, 3, 4); + + // Act + var result1 = sourceLocationA.Equals(sourceLocationB); + var result2 = sourceLocationA.Equals(sourceLocationC); + + // Assert + Assert.True(result1); + Assert.False(result2); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceSpanTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceSpanTest.cs new file mode 100644 index 0000000000..d59253c08a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/SourceSpanTest.cs @@ -0,0 +1,117 @@ +// 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 Xunit; +using Microsoft.AspNetCore.Razor.Language.Legacy; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class SourceSpanTest + { + [Fact] + public void GeneratedCodeMappingsAreEqualIfDataIsEqual() + { + // Arrange + var left = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 8)); + + var right = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 8)); + + // Assert + Assert.True(left.Equals(right)); + Assert.True(right.Equals(left)); + Assert.True(Equals(left, right)); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfCodeLengthIsNotEqual() + { + // Arrange + var left = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 8)); + + var right = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 5), + new SourceSpan(new SourceLocation(5, 6, 7), 9)); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfStartGeneratedColumnIsNotEqual() + { + // Arrange + var left = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 8)); + + var right = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 8), 8)); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfStartColumnIsNotEqual() + { + // Arrange + var left = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 8), 8)); + + var right = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 8)); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfStartLineIsNotEqual() + { + // Arrange + var left = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 5, 7), 8)); + + var right = new SourceMapping( + new SourceSpan(new SourceLocation(1, 1, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 8)); + + // Assert + AssertNotEqual(left, right); + } + + [Fact] + public void GeneratedCodeMappingsAreNotEqualIfAbsoluteIndexIsNotEqual() + { + // Arrange + var left = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(4, 6, 7), 8)); + + var right = new SourceMapping( + new SourceSpan(new SourceLocation(1, 2, 3), 4), + new SourceSpan(new SourceLocation(5, 6, 7), 9)); + + // Assert + AssertNotEqual(left, right); + } + + private void AssertNotEqual(SourceMapping left, SourceMapping right) + { + Assert.False(left == right); + Assert.False(left.Equals(right)); + Assert.False(right.Equals(left)); + Assert.False(Equals(left, right)); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/StreamSourceDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/StreamSourceDocumentTest.cs new file mode 100644 index 0000000000..f377450320 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/StreamSourceDocumentTest.cs @@ -0,0 +1,200 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class StreamSourceDocumentTest + { + [Fact] + public void FilePath() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "file.cshtml", relativePath: null)); + + // Assert + Assert.Equal("file.cshtml", document.FilePath); + } + + [Fact] + public void FilePath_Null() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.FilePath); + } + + [Fact] + public void RelativePath() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: "file.cshtml")); + + // Assert + Assert.Equal("file.cshtml", document.RelativePath); + } + + [Fact] + public void RelativePath_Null() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + + // Act + var document = new StreamSourceDocument(stream, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.RelativePath); + } + + [Fact] + public void GetChecksum_ReturnsCopiedChecksum() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); + + // Act + var firstChecksum = document.GetChecksum(); + var secondChecksum = document.GetChecksum(); + + // Assert + Assert.Equal(firstChecksum, secondChecksum); + Assert.NotSame(firstChecksum, secondChecksum); + } + + [Fact] + public void GetChecksum_ComputesCorrectChecksum_UTF8() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF8); + var document = new StreamSourceDocument(stream, Encoding.UTF8, RazorSourceDocumentProperties.Default); + var expectedChecksum = new byte[] { 70, 180, 84, 105, 70, 79, 152, 31, 71, 157, 46, 159, 50, 83, 1, 243, 222, 48, 90, 18 }; + + // Act + var checksum = document.GetChecksum(); + + // Assert + Assert.Equal(expectedChecksum, checksum); + } + + [Fact] + public void GetChecksum_ComputesCorrectChecksum_UTF32AutoDetect() + { + // Arrange + var content = "Hello World!"; + var stream = CreateBOMStream(content, Encoding.UTF32); + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); + var expectedChecksum = new byte[] { 159, 154, 109, 89, 250, 163, 165, 108, 2, 112, 34, 4, 247, 161, 82, 168, 77, 213, 107, 71 }; + + // Act + var checksum = document.GetChecksum(); + + // Assert + Assert.Equal(expectedChecksum, checksum); + } + + [Fact] + public void ConstructedWithoutEncoding_DetectsEncoding() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); + + // Act + var document = new StreamSourceDocument(content, null, RazorSourceDocumentProperties.Default); + + // Assert + Assert.IsType(document); + Assert.Equal(Encoding.UTF32, document.Encoding); + } + + [Fact] + public void ConstructedWithoutEncoding_EmptyStream_DetectsEncoding() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(content: string.Empty, encoding: Encoding.UTF32); + + // Act + var document = new StreamSourceDocument(content, null, RazorSourceDocumentProperties.Default); + + // Assert + Assert.IsType(document); + Assert.Equal(Encoding.UTF32, document.Encoding); + } + + [Fact] + public void FailsOnMismatchedEncoding() + { + // Arrange + var content = TestRazorSourceDocument.CreateStreamContent(encoding: Encoding.UTF32); + var expectedMessage = Resources.FormatMismatchedContentEncoding(Encoding.UTF8.EncodingName, Encoding.UTF32.EncodingName); + + // Act & Assert + var exception = Assert.Throws( + () => new StreamSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default)); + Assert.Equal(expectedMessage, exception.Message); + } + + [Theory] + [InlineData(100000)] + [InlineData(RazorSourceDocument.LargeObjectHeapLimitInChars)] + [InlineData(RazorSourceDocument.LargeObjectHeapLimitInChars + 2)] + [InlineData(RazorSourceDocument.LargeObjectHeapLimitInChars * 2 - 1)] + [InlineData(RazorSourceDocument.LargeObjectHeapLimitInChars * 2)] + public void DetectsSizeOfStreamForLargeContent(int contentLength) + { + // Arrange + var content = new string('a', contentLength); + var stream = TestRazorSourceDocument.CreateStreamContent(content); + + // Act + var document = new StreamSourceDocument(stream, null, RazorSourceDocumentProperties.Default); + + // Assert + var streamDocument = Assert.IsType(document); + Assert.IsType(streamDocument._innerSourceDocument); + Assert.Same(Encoding.UTF8, document.Encoding); + Assert.Equal(content, ReadContent(document)); + } + + private static MemoryStream CreateBOMStream(string content, Encoding encoding) + { + var preamble = encoding.GetPreamble(); + var contentBytes = encoding.GetBytes(content); + var buffer = new byte[preamble.Length + contentBytes.Length]; + preamble.CopyTo(buffer, 0); + contentBytes.CopyTo(buffer, preamble.Length); + var stream = new MemoryStream(buffer); + return stream; + } + + private static string ReadContent(RazorSourceDocument razorSourceDocument) + { + var buffer = new char[razorSourceDocument.Length]; + razorSourceDocument.CopyTo(0, buffer, 0, buffer.Length); + + return new string(buffer); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/StringSourceDocumentTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/StringSourceDocumentTest.cs new file mode 100644 index 0000000000..8306d2bf80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/StringSourceDocumentTest.cs @@ -0,0 +1,516 @@ +// 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.Text; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class StringSourceDocumentTest + { + [Fact] + public void GetChecksum_ReturnsCopiedChecksum() + { + // Arrange + var content = "Hello World!"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var firstChecksum = document.GetChecksum(); + var secondChecksum = document.GetChecksum(); + + // Assert + Assert.Equal(firstChecksum, secondChecksum); + Assert.NotSame(firstChecksum, secondChecksum); + } + + [Fact] + public void GetChecksum_ComputesCorrectChecksum_UTF8() + { + // Arrange + var content = "Hello World!"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + var expectedChecksum = new byte[] { 46, 247, 189, 230, 8, 206, 84, 4, 233, 125, 95, 4, 47, 149, 248, 159, 28, 35, 40, 113 }; + + // Act + var checksum = document.GetChecksum(); + + // Assert + Assert.Equal(expectedChecksum, checksum); + } + + [Fact] + public void GetChecksum_ComputesCorrectChecksum_UTF32() + { + // Arrange + var content = "Hello World!"; + var document = new StringSourceDocument(content, Encoding.UTF32, RazorSourceDocumentProperties.Default); + var expectedChecksum = new byte[] { 8, 149, 159, 15, 242, 255, 115, 227, 219, 78, 61, 53, 127, 239, 77, 239, 215, 140, 248, 44 }; + + // Act + var checksum = document.GetChecksum(); + + // Assert + Assert.Equal(expectedChecksum, checksum); + } + + [Fact] + public void Indexer_ProvidesCharacterAccessToContent() + { + // Arrange + var expectedContent = "Hello, World!"; + var indexerBuffer = new char[expectedContent.Length]; + var document = new StringSourceDocument(expectedContent, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + for (var i = 0; i < document.Length; i++) + { + indexerBuffer[i] = document[i]; + } + + // Assert + var output = new string(indexerBuffer); + Assert.Equal(expectedContent, output); + } + + [Fact] + public void Length() + { + // Arrange + var expectedContent = "Hello, World!"; + var document = new StringSourceDocument(expectedContent, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act & Assert + Assert.Equal(expectedContent.Length, document.Length); + } + + [Fact] + public void FilePath() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "file.cshtml", relativePath: null)); + + // Assert + Assert.Equal("file.cshtml", document.FilePath); + } + + [Fact] + public void FilePath_Null() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.FilePath); + } + + [Fact] + public void RelativePath() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: "file.cshtml")); + + // Assert + Assert.Equal("file.cshtml", document.RelativePath); + } + + [Fact] + public void RelativePath_Null() + { + // Arrange + var content = "Hello, World!"; + + // Act + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: null, relativePath: null)); + + // Assert + Assert.Null(document.RelativePath); + } + + [Fact] + public void CopyTo_PartialCopyFromStart() + { + // Arrange + var content = "Hello, World!"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + var expectedContent = "Hello"; + var charBuffer = new char[expectedContent.Length]; + + // Act + document.CopyTo(0, charBuffer, 0, expectedContent.Length); + + // Assert + var copiedContent = new string(charBuffer); + Assert.Equal(expectedContent, copiedContent); + } + + [Fact] + public void CopyTo_PartialCopyDestinationOffset() + { + // Arrange + var content = "Hello, World!"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + var expectedContent = "$Hello"; + var charBuffer = new char[expectedContent.Length]; + charBuffer[0] = '$'; + + // Act + document.CopyTo(0, charBuffer, 1, "Hello".Length); + + // Assert + var copiedContent = new string(charBuffer); + Assert.Equal(expectedContent, copiedContent); + } + + [Fact] + public void CopyTo_PartialCopySourceOffset() + { + // Arrange + var content = "Hello, World!"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + var expectedContent = "World"; + var charBuffer = new char[expectedContent.Length]; + + // Act + document.CopyTo(7, charBuffer, 0, expectedContent.Length); + + // Assert + var copiedContent = new string(charBuffer); + Assert.Equal(expectedContent, copiedContent); + } + + [Fact] + public void CopyTo_CanCopyMultipleTimes() + { + // Arrange + var content = "Hi"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act & Assert + // + // (we should be able to do this twice to prove that the underlying data isn't disposed) + for (var i = 0; i < 2; i++) + { + var charBuffer = new char[2]; + document.CopyTo(0, charBuffer, 0, 2); + var copiedContent = new string(charBuffer); + Assert.Equal("Hi", copiedContent); + } + } + + [Fact] + public void Lines_Count_EmptyDocument() + { + // Arrange + var content = string.Empty; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.Count; + + // Assert + Assert.Equal(1, actual); + } + + [Fact] + public void Lines_GetLineLength_EmptyDocument() + { + // Arrange + var content = string.Empty; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLineLength(0); + + // Assert + Assert.Equal(0, actual); + } + + [Fact] + public void Lines_GetLineLength_TrailingNewlineDoesNotStartNewLine() + { + // Arrange + var content = "hello\n"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLineLength(0); + + // Assert + Assert.Equal(6, actual); + } + + [Fact] + public void Lines_GetLineLength_TrailingNewlineDoesNotStartNewLine_CRLF() + { + // Arrange + var content = "hello\r\n"; + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLineLength(0); + + // Assert + Assert.Equal(7, actual); + } + + [Fact] + public void Lines_Simple_Document() + { + // Arrange + var content = new StringBuilder() + .Append("The quick brown").Append('\n') + .Append("fox").Append("\r\n") + .Append("jumps over the lazy dog.") + .ToString(); + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 16, 5, 24 }, actual); + } + + [Fact] + public void Lines_CRLF_OnlyCountsAsASingleNewLine() + { + // Arrange + var content = "Hello\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 7, 6 }, actual); + } + + [Fact] + public void Lines_CR_IsNewLine() + { + // Arrange + var content = "Hello\rWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 6, 6 }, actual); + } + + // CR handling is stateful in the parser, making sure we properly reset the state. + [Fact] + public void Lines_CR_IsNewLine_MultipleCRs() + { + // Arrange + var content = "Hello\rBig\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 6, 5, 6 }, actual); + } + + [Fact] + public void Lines_LF_IsNewLine() + { + // Arrange + var content = "Hello\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 6, 6 }, actual); + } + + [Fact] + public void Lines_Unicode0085_IsNewLine() + { + // Arrange + var content = "Hello\u0085World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 6, 6 }, actual); + } + + [Fact] + public void Lines_Unicode2028_IsNewLine() + { + // Arrange + var content = "Hello\u2028World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 6, 6 }, actual); + } + + [Fact] + public void Lines_Unicode2029_IsNewLine() + { + // Arrange + var content = "Hello\u2029World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = GetAllSourceMappings(document); + + // Assert + Assert.Equal(new int[] { 6, 6 }, actual); + } + + [Fact] + public void Lines_GetLocation_IncludesAbsoluteIndexAndDocument() + { + // Arrange + var content = "Hello, World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "Hi.cshtml", relativePath: null)); + + // Act + var actual = document.Lines.GetLocation(1); + + // Assert + Assert.Equal("Hi.cshtml", actual.FilePath); + Assert.Equal(1, actual.AbsoluteIndex); + } + + [Fact] + public void Lines_GetLocation_PrefersRelativePath() + { + // Arrange + var content = "Hello, World!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, new RazorSourceDocumentProperties(filePath: "Hi.cshtml", relativePath: "Bye.cshtml")); + + // Act + var actual = document.Lines.GetLocation(1); + + // Assert + Assert.Equal("Bye.cshtml", actual.FilePath); + Assert.Equal(1, actual.AbsoluteIndex); + } + + // Beginnings of lines are special because the BinarySearch in the implementation + // will succeed. It's a different code path. + [Fact] + public void Lines_GetLocation_FirstCharacter() + { + // Arrange + var content = "Hello\nBig\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLocation(0); + + // Assert + Assert.Equal(0, actual.LineIndex); + Assert.Equal(0, actual.CharacterIndex); + } + + [Fact] + public void Lines_GetLocation_EndOfFirstLine() + { + // Arrange + var content = "Hello\nBig\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLocation(5); + + // Assert + Assert.Equal(0, actual.LineIndex); + Assert.Equal(5, actual.CharacterIndex); + } + + [Fact] + public void Lines_GetLocation_InteriorLine() + { + // Arrange + var content = "Hello\nBig\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLocation(7); + + // Assert + Assert.Equal(1, actual.LineIndex); + Assert.Equal(1, actual.CharacterIndex); + } + + [Fact] + public void Lines_GetLocation_StartOfLastLine() + { + // Arrange + var content = "Hello\nBig\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLocation(11); + + // Assert + Assert.Equal(2, actual.LineIndex); + Assert.Equal(0, actual.CharacterIndex); + } + + [Fact] + public void Lines_GetLocation_EndOfLastLine() + { + // Arrange + var content = "Hello\nBig\r\nWorld!"; + + var document = new StringSourceDocument(content, Encoding.UTF8, RazorSourceDocumentProperties.Default); + + // Act + var actual = document.Lines.GetLocation(16); + + // Assert + Assert.Equal(2, actual.LineIndex); + Assert.Equal(5, actual.CharacterIndex); + } + + private static int[] GetAllSourceMappings(RazorSourceDocument source) + { + var lines = new int[source.Lines.Count]; + for (var i = 0; i < lines.Length; i++) + { + lines[i] = source.Lines.GetLineLength(i); + } + + return lines; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs new file mode 100644 index 0000000000..ab3439b2e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs @@ -0,0 +1,656 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class TagHelperBinderTest + { + [Fact] + public void GetBinding_ReturnsBindingWithInformation() + { + // Arrange + var divTagHelper = TagHelperDescriptorBuilder.Create("DivTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(); + var expectedDescriptors = new[] { divTagHelper }; + var expectedAttributes = new[] + { + new KeyValuePair("class", "something") + }; + var tagHelperBinder = new TagHelperBinder("th:", expectedDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "th:div", + attributes: expectedAttributes, + parentTagName: "body", + parentIsTagHelper: false); + + // Assert + Assert.Equal(expectedDescriptors, bindingResult.Descriptors, TagHelperDescriptorComparer.Default); + Assert.Equal("th:div", bindingResult.TagName); + Assert.Equal("body", bindingResult.ParentTagName); + Assert.Equal(expectedAttributes, bindingResult.Attributes); + Assert.Equal("th:", bindingResult.TagHelperPrefix); + Assert.Equal(divTagHelper.TagMatchingRules, bindingResult.Mappings[divTagHelper], TagMatchingRuleDescriptorComparer.Default); + } + + public static TheoryData RequiredParentData + { + get + { + var strongPDivParent = TagHelperDescriptorBuilder.Create("StrongTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("p")) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("strong") + .RequireParentTag("div")) + .Build(); + var catchAllPParent = TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireParentTag("p")) + .Build(); + + return new TheoryData< + string, // tagName + string, // parentTagName + IEnumerable, // availableDescriptors + IEnumerable> // expectedDescriptors + { + { + "strong", + "p", + new[] { strongPDivParent }, + new[] { strongPDivParent } + }, + { + "strong", + "div", + new[] { strongPDivParent, catchAllPParent }, + new[] { strongPDivParent } + }, + { + "strong", + "p", + new[] { strongPDivParent, catchAllPParent }, + new[] { strongPDivParent, catchAllPParent } + }, + { + "custom", + "p", + new[] { strongPDivParent, catchAllPParent }, + new[] { catchAllPParent } + }, + }; + } + } + + [Theory] + [MemberData(nameof(RequiredParentData))] + public void GetBinding_ReturnsBindingResultWithDescriptorsParentTags( + string tagName, + string parentTagName, + object availableDescriptors, + object expectedDescriptors) + { + // Arrange + var tagHelperBinder = new TagHelperBinder(null, (IEnumerable)availableDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName, + attributes: Array.Empty>(), + parentTagName: parentTagName, + parentIsTagHelper: false); + + // Assert + Assert.Equal((IEnumerable)expectedDescriptors, bindingResult.Descriptors, TagHelperDescriptorComparer.Default); + } + + public static TheoryData RequiredAttributeData + { + get + { + var divDescriptor = TagHelperDescriptorBuilder.Create("DivTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("style"))) + .Build(); + var inputDescriptor = TagHelperDescriptorBuilder.Create("InputTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style"))) + .Build(); + var inputWildcardPrefixDescriptor = TagHelperDescriptorBuilder.Create("InputWildCardAttribute", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => + attribute + .Name("nodashprefix") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch))) + .Build(); + var catchAllDescriptor = TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName(TagHelperMatchingConventions.ElementCatchAllName) + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(); + var catchAllDescriptor2 = TagHelperDescriptorBuilder.Create("CatchAllTagHelper2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName(TagHelperMatchingConventions.ElementCatchAllName) + .RequireAttributeDescriptor(attribute => attribute.Name("custom")) + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(); + var catchAllWildcardPrefixDescriptor = TagHelperDescriptorBuilder.Create("CatchAllWildCardAttribute", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName(TagHelperMatchingConventions.ElementCatchAllName) + .RequireAttributeDescriptor(attribute => + attribute + .Name("prefix-") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch))) + .Build(); + var defaultAvailableDescriptors = + new[] { divDescriptor, inputDescriptor, catchAllDescriptor, catchAllDescriptor2 }; + var defaultWildcardDescriptors = + new[] { inputWildcardPrefixDescriptor, catchAllWildcardPrefixDescriptor }; + Func> kvp = + (name) => new KeyValuePair(name, "test value"); + + return new TheoryData< + string, // tagName + IReadOnlyList>, // providedAttributes + IEnumerable, // availableDescriptors + IEnumerable> // expectedDescriptors + { + { + "div", + new[] { kvp("custom") }, + defaultAvailableDescriptors, + null + }, + { "div", new[] { kvp("style") }, defaultAvailableDescriptors, new[] { divDescriptor } }, + { "div", new[] { kvp("class") }, defaultAvailableDescriptors, new[] { catchAllDescriptor } }, + { + "div", + new[] { kvp("class"), kvp("style") }, + defaultAvailableDescriptors, + new[] { divDescriptor, catchAllDescriptor } + }, + { + "div", + new[] { kvp("class"), kvp("style"), kvp("custom") }, + defaultAvailableDescriptors, + new[] { divDescriptor, catchAllDescriptor, catchAllDescriptor2 } + }, + { + "input", + new[] { kvp("class"), kvp("style") }, + defaultAvailableDescriptors, + new[] { inputDescriptor, catchAllDescriptor } + }, + { + "input", + new[] { kvp("nodashprefixA") }, + defaultWildcardDescriptors, + new[] { inputWildcardPrefixDescriptor } + }, + { + "input", + new[] { kvp("nodashprefix-ABC-DEF"), kvp("random") }, + defaultWildcardDescriptors, + new[] { inputWildcardPrefixDescriptor } + }, + { + "input", + new[] { kvp("prefixABCnodashprefix") }, + defaultWildcardDescriptors, + null + }, + { + "input", + new[] { kvp("prefix-") }, + defaultWildcardDescriptors, + null + }, + { + "input", + new[] { kvp("nodashprefix") }, + defaultWildcardDescriptors, + null + }, + { + "input", + new[] { kvp("prefix-A") }, + defaultWildcardDescriptors, + new[] { catchAllWildcardPrefixDescriptor } + }, + { + "input", + new[] { kvp("prefix-ABC-DEF"), kvp("random") }, + defaultWildcardDescriptors, + new[] { catchAllWildcardPrefixDescriptor } + }, + { + "input", + new[] { kvp("prefix-abc"), kvp("nodashprefix-def") }, + defaultWildcardDescriptors, + new[] { inputWildcardPrefixDescriptor, catchAllWildcardPrefixDescriptor } + }, + { + "input", + new[] { kvp("class"), kvp("prefix-abc"), kvp("onclick"), kvp("nodashprefix-def"), kvp("style") }, + defaultWildcardDescriptors, + new[] { inputWildcardPrefixDescriptor, catchAllWildcardPrefixDescriptor } + }, + }; + } + } + + [Theory] + [MemberData(nameof(RequiredAttributeData))] + public void GetBinding_ReturnsBindingResultDescriptorsWithRequiredAttributes( + string tagName, + IReadOnlyList> providedAttributes, + object availableDescriptors, + object expectedDescriptors) + { + // Arrange + var tagHelperBinder = new TagHelperBinder(null, (IReadOnlyList)availableDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding(tagName, providedAttributes, parentTagName: "p", parentIsTagHelper: false); + + // Assert + Assert.Equal((IEnumerable)expectedDescriptors, bindingResult?.Descriptors, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void GetBinding_ReturnsNullBindingResultPrefixAsTagName() + { + // Arrange + var catchAllDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName(TagHelperMatchingConventions.ElementCatchAllName)) + .Build(); + var descriptors = new[] { catchAllDescriptor }; + var tagHelperBinder = new TagHelperBinder("th", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "th", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + Assert.Null(bindingResult); + } + + [Fact] + public void GetBinding_ReturnsBindingResultCatchAllDescriptorsForPrefixedTags() + { + // Arrange + var catchAllDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName(TagHelperMatchingConventions.ElementCatchAllName)) + .Build(); + var descriptors = new[] { catchAllDescriptor }; + var tagHelperBinder = new TagHelperBinder("th:", descriptors); + + // Act + var bindingResultDiv = tagHelperBinder.GetBinding( + tagName: "th:div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + var bindingResultSpan = tagHelperBinder.GetBinding( + tagName: "th:span", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + var descriptor = Assert.Single(bindingResultDiv.Descriptors); + Assert.Same(catchAllDescriptor, descriptor); + descriptor = Assert.Single(bindingResultSpan.Descriptors); + Assert.Same(catchAllDescriptor, descriptor); + } + + [Fact] + public void GetBinding_ReturnsBindingResultDescriptorsForPrefixedTags() + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(); + var descriptors = new[] { divDescriptor }; + var tagHelperBinder = new TagHelperBinder("th:", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "th:div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + var descriptor = Assert.Single(bindingResult.Descriptors); + Assert.Same(divDescriptor, descriptor); + } + + [Theory] + [InlineData("*")] + [InlineData("div")] + public void GetBinding_ReturnsNullForUnprefixedTags(string tagName) + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName(tagName)) + .Build(); + var descriptors = new[] { divDescriptor }; + var tagHelperBinder = new TagHelperBinder("th:", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + Assert.Null(bindingResult); + } + + [Fact] + public void GetDescriptors_ReturnsNothingForUnregisteredTags() + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(); + var spanDescriptor = TagHelperDescriptorBuilder.Create("foo2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("span")) + .Build(); + var descriptors = new TagHelperDescriptor[] { divDescriptor, spanDescriptor }; + var tagHelperBinder = new TagHelperBinder(null, descriptors); + + // Act + var tagHelperBinding = tagHelperBinder.GetBinding( + tagName: "foo", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + Assert.Null(tagHelperBinding); + } + + [Fact] + public void GetDescriptors_ReturnsCatchAllsWithEveryTagName() + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(); + var spanDescriptor = TagHelperDescriptorBuilder.Create("foo2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("span")) + .Build(); + var catchAllDescriptor = TagHelperDescriptorBuilder.Create("foo3", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName(TagHelperMatchingConventions.ElementCatchAllName)) + .Build(); + var descriptors = new TagHelperDescriptor[] { divDescriptor, spanDescriptor, catchAllDescriptor }; + var tagHelperBinder = new TagHelperBinder(null, descriptors); + + // Act + var divBinding = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + var spanBinding = tagHelperBinder.GetBinding( + tagName: "span", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + // For divs + Assert.Equal(2, divBinding.Descriptors.Count()); + Assert.Contains(divDescriptor, divBinding.Descriptors); + Assert.Contains(catchAllDescriptor, divBinding.Descriptors); + + // For spans + Assert.Equal(2, spanBinding.Descriptors.Count()); + Assert.Contains(spanDescriptor, spanBinding.Descriptors); + Assert.Contains(catchAllDescriptor, spanBinding.Descriptors); + } + + [Fact] + public void GetDescriptors_DuplicateDescriptorsAreNotPartOfTagHelperDescriptorPool() + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(); + var descriptors = new TagHelperDescriptor[] { divDescriptor, divDescriptor }; + var tagHelperBinder = new TagHelperBinder(null, descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + var descriptor = Assert.Single(bindingResult.Descriptors); + Assert.Same(divDescriptor, descriptor); + } + + [Fact] + public void GetBinding_DescriptorWithMultipleRules_CorrectlySelectsMatchingRules() + { + // Arrange + var multiRuleDescriptor = TagHelperDescriptorBuilder.Create("foo", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule + .RequireTagName(TagHelperMatchingConventions.ElementCatchAllName) + .RequireParentTag("body")) + .TagMatchingRuleDescriptor(rule => rule + .RequireTagName("div")) + .TagMatchingRuleDescriptor(rule => rule + .RequireTagName("span")) + .Build(); + var descriptors = new TagHelperDescriptor[] { multiRuleDescriptor }; + var tagHelperBinder = new TagHelperBinder(null, descriptors); + + // Act + var binding = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + var boundDescriptor = Assert.Single(binding.Descriptors); + Assert.Same(multiRuleDescriptor, boundDescriptor); + var boundRules = binding.Mappings[boundDescriptor]; + var boundRule = Assert.Single(boundRules); + Assert.Equal("div", boundRule.TagName); + } + + [Fact] + public void GetBinding_PrefixedParent_ReturnsBinding() + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div").RequireParentTag("p")) + .Build(); + var pDescriptor = TagHelperDescriptorBuilder.Create("foo2", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p")) + .Build(); + var descriptors = new[] { divDescriptor, pDescriptor }; + var tagHelperBinder = new TagHelperBinder("th:", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "th:div", + attributes: Array.Empty>(), + parentTagName: "th:p", + parentIsTagHelper: true); + + // Assert + var boundDescriptor = Assert.Single(bindingResult.Descriptors); + Assert.Same(divDescriptor, boundDescriptor); + var boundRules = bindingResult.Mappings[boundDescriptor]; + var boundRule = Assert.Single(boundRules); + Assert.Equal("div", boundRule.TagName); + Assert.Equal("p", boundRule.ParentTag); + } + + [Fact] + public void GetBinding_IsAttributeMatch_SingleAttributeMatch() + { + // Arrange + var divDescriptor = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .AddMetadata(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString) + .Build(); + + var descriptors = new[] { divDescriptor, }; + var tagHelperBinder = new TagHelperBinder("", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + Assert.True(bindingResult.IsAttributeMatch); + } + + [Fact] + public void GetBinding_IsAttributeMatch_MultipleAttributeMatches() + { + // Arrange + var divDescriptor1 = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .AddMetadata(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString) + .Build(); + + var divDescriptor2 = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .AddMetadata(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString) + .Build(); + + var descriptors = new[] { divDescriptor1, divDescriptor2, }; + var tagHelperBinder = new TagHelperBinder("", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + Assert.True(bindingResult.IsAttributeMatch); + } + + [Fact] + public void GetBinding_IsAttributeMatch_MixedAttributeMatches() + { + // Arrange + var divDescriptor1 = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .AddMetadata(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString) + .Build(); + + var divDescriptor2 = TagHelperDescriptorBuilder.Create("foo1", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .Build(); + + var descriptors = new[] { divDescriptor1, divDescriptor2, }; + var tagHelperBinder = new TagHelperBinder("", descriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: Array.Empty>(), + parentTagName: "p", + parentIsTagHelper: false); + + // Assert + Assert.False(bindingResult.IsAttributeMatch); + } + + [Fact] + public void GetBinding_CaseSensitiveRule_CaseMismatch_ReturnsNull() + { + // Arrange + var divTagHelper = TagHelperDescriptorBuilder.Create("DivTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .SetCaseSensitive() + .Build(); + var expectedDescriptors = new[] { divTagHelper }; + var expectedAttributes = new[] + { + new KeyValuePair("class", "something") + }; + var tagHelperBinder = new TagHelperBinder("th:", expectedDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "th:Div", + attributes: expectedAttributes, + parentTagName: "body", + parentIsTagHelper: false); + + // Assert + Assert.Null(bindingResult); + } + + [Fact] + public void GetBinding_CaseSensitiveRequiredAttribute_CaseMismatch_ReturnsNull() + { + // Arrange + var divTagHelper = TagHelperDescriptorBuilder.Create("DivTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .SetCaseSensitive() + .Build(); + var expectedDescriptors = new[] { divTagHelper }; + var expectedAttributes = new[] + { + new KeyValuePair("CLASS", "something") + }; + var tagHelperBinder = new TagHelperBinder(null, expectedDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: expectedAttributes, + parentTagName: "body", + parentIsTagHelper: false); + + // Assert + Assert.Null(bindingResult); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperDescriptorBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperDescriptorBuilderTest.cs new file mode 100644 index 0000000000..37eef5fbfa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperDescriptorBuilderTest.cs @@ -0,0 +1,38 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class TagHelperDescriptorBuilderTest + { + [Fact] + public void DisplayName_SetsDescriptorsDisplayName() + { + // Arrange + var expectedDisplayName = "ExpectedDisplayName"; + var builder = TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly"); + + // Act + var descriptor = builder.DisplayName(expectedDisplayName).Build(); + + // Assert + Assert.Equal(expectedDisplayName, descriptor.DisplayName); + } + + [Fact] + public void DisplayName_DefaultsToTypeName() + { + // Arrange + var expectedDisplayName = "TestTagHelper"; + var builder = TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly"); + + // Act + var descriptor = builder.Build(); + + // Assert + Assert.Equal(expectedDisplayName, descriptor.DisplayName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperDescriptorExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperDescriptorExtensionsTest.cs new file mode 100644 index 0000000000..0940661058 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperDescriptorExtensionsTest.cs @@ -0,0 +1,64 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class TagHelperDescriptorExtensionsTest + { + [Fact] + public void GetTypeName_ReturnsTypeName() + { + // Arrange + var expectedTypeName = "TestTagHelper"; + var descriptor = TagHelperDescriptorBuilder.Create(expectedTypeName, "TestAssembly").TypeName(expectedTypeName).Build(); + + // Act + var typeName = descriptor.GetTypeName(); + + // Assert + Assert.Equal(expectedTypeName, typeName); + } + + [Fact] + public void GetTypeName_ReturnsNullIfNoTypeName() + { + // Arrange + var descriptor = TagHelperDescriptorBuilder.Create("Test", "TestAssembly").Build(); + + // Act + var typeName = descriptor.GetTypeName(); + + // Assert + Assert.Null(typeName); + } + + [Fact] + public void IsDefaultKind_ReturnsTrue_IfKindIsDefault() + { + // Arrange + var descriptor = TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build(); + + // Act + var isDefault = descriptor.IsDefaultKind(); + + // Assert + Assert.True(isDefault); + } + + [Fact] + public void IsDefaultKind_ReturnsFalse_IfKindIsNotDefault() + { + // Arrange + var descriptor = TagHelperDescriptorBuilder.Create("other-kind", "TestTagHelper", "TestAssembly").Build(); + + // Act + var isDefault = descriptor.IsDefaultKind(); + + // Assert + Assert.False(isDefault); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs new file mode 100644 index 0000000000..afda769414 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs @@ -0,0 +1,158 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class TagHelperMatchingConventionsTest + { + public static TheoryData RequiredAttributeDescriptorData + { + get + { + // requiredAttributeDescriptor, attributeName, attributeValue, expectedResult + return new TheoryData, string, string, bool> + { + { + builder => builder.Name("key"), + "KeY", + "value", + true + }, + { + builder => builder.Name("key"), + "keys", + "value", + false + }, + { + builder => builder + .Name("route-") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + "ROUTE-area", + "manage", + true + }, + { + builder => builder + .Name("route-") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + "routearea", + "manage", + false + }, + { + builder => builder + .Name("route-") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + "route-", + "manage", + false + }, + { + builder => builder + .Name("key") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch), + "KeY", + "value", + true + }, + { + builder => builder + .Name("key") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch), + "keys", + "value", + false + }, + { + builder => builder + .Name("key") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("value") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch), + "key", + "value", + true + }, + { + builder => builder + .Name("key") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("value") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch), + "key", + "Value", + false + }, + { + builder => builder + .Name("class") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("btn") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch), + "class", + "btn btn-success", + true + }, + { + builder => builder + .Name("class") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("btn") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch), + "class", + "BTN btn-success", + false + }, + { + builder => builder + .Name("href") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("#navigate") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch), + "href", + "/home/index#navigate", + true + }, + { + builder => builder + .Name("href") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch) + .Value("#navigate") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch), + "href", + "/home/index#NAVigate", + false + }, + }; + } + } + + [Theory] + [MemberData(nameof(RequiredAttributeDescriptorData))] + public void Matches_ReturnsExpectedResult( + Action configure, + string attributeName, + string attributeValue, + bool expectedResult) + { + // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder); + + configure(builder); + + var requiredAttibute = builder.Build(); + + // Act + var result = TagHelperMatchingConventions.SatisfiesRequiredAttribute(attributeName, attributeValue, requiredAttibute); + + // Assert + Assert.Equal(expectedResult, result); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml new file mode 100644 index 0000000000..7c5b3ca2e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Home.cshtml @@ -0,0 +1 @@ +home-content \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/About/About.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/Index.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/Home/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/Views/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/DefaultRazorProjectFileSystem/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.cshtml new file mode 100644 index 0000000000..f347706f3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.cshtml @@ -0,0 +1 @@ +@test \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt new file mode 100644 index 0000000000..6142bc2eb1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/CustomDirective.ir.txt @@ -0,0 +1,6 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - + ClassDeclaration - - public - Template - - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt new file mode 100644 index 0000000000..6142bc2eb1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/Empty.ir.txt @@ -0,0 +1,6 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - + ClassDeclaration - - public - Template - - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.cshtml new file mode 100644 index 0000000000..46953c4542 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.cshtml @@ -0,0 +1 @@ +Hello, World! \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt new file mode 100644 index 0000000000..83409ed68c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/BasicIntegrationTest/HelloWorld.ir.txt @@ -0,0 +1,8 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Razor + RazorSourceChecksumAttribute - + ClassDeclaration - - public - Template - - + MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [13] HelloWorld.cshtml) + IntermediateToken - (0:0,0 [13] HelloWorld.cshtml) - Html - Hello, World! diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective.cshtml new file mode 100644 index 0000000000..10b53aaeaf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective.cshtml @@ -0,0 +1 @@ +@addTagHelper "*, TestAssembly" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..9f3704669f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AddTagHelperDirective_DesignTime + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.codegen.html new file mode 100644 index 0000000000..0da46f2152 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.codegen.html @@ -0,0 +1 @@ + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..a3c0f0d9e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt @@ -0,0 +1,14 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AddTagHelperDirective_DesignTime - - + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] AddTagHelperDirective.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [2] AddTagHelperDirective.cshtml) + IntermediateToken - (31:0,31 [2] AddTagHelperDirective.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..782c5c9d62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective.cshtml) +|"*, TestAssembly"| +Generated Location: (543:12,37 [17] ) +|"*, TestAssembly"| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml new file mode 100644 index 0000000000..638e221534 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml @@ -0,0 +1,6 @@ +@attribute [System.Runtime.InteropServices.DllImport("user32.dll")] +@attribute [assembly: AssemblyTitleAttribute("Some assembly")] +@attribute [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)] +@attribute [Conditional("DEBUG"), Conditional("TEST1")] + +Hello World \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..a9a63af516 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [System.Runtime.InteropServices.DllImport("user32.dll")] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [assembly: AssemblyTitleAttribute("Some assembly")] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [Conditional("DEBUG"), Conditional("TEST1")] + +#line default +#line hidden +#nullable disable + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirective_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.codegen.html new file mode 100644 index 0000000000..fd82d19806 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.codegen.html @@ -0,0 +1,6 @@ + + + + + +Hello World \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..143b299051 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + CSharpCode - (11:0,11 [56] AttributeDirective.cshtml) + IntermediateToken - (11:0,11 [56] AttributeDirective.cshtml) - CSharp - [System.Runtime.InteropServices.DllImport("user32.dll")] + CSharpCode - (80:1,11 [51] AttributeDirective.cshtml) + IntermediateToken - (80:1,11 [51] AttributeDirective.cshtml) - CSharp - [assembly: AssemblyTitleAttribute("Some assembly")] + CSharpCode - (144:2,11 [66] AttributeDirective.cshtml) + IntermediateToken - (144:2,11 [66] AttributeDirective.cshtml) - CSharp - [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)] + CSharpCode - (223:3,11 [44] AttributeDirective.cshtml) + IntermediateToken - (223:3,11 [44] AttributeDirective.cshtml) - CSharp - [Conditional("DEBUG"), Conditional("TEST1")] + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirective_DesignTime - - + DesignTimeDirective - + DirectiveToken - (11:0,11 [56] AttributeDirective.cshtml) - [System.Runtime.InteropServices.DllImport("user32.dll")] + DirectiveToken - (80:1,11 [51] AttributeDirective.cshtml) - [assembly: AssemblyTitleAttribute("Some assembly")] + DirectiveToken - (144:2,11 [66] AttributeDirective.cshtml) - [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)] + DirectiveToken - (223:3,11 [44] AttributeDirective.cshtml) - [Conditional("DEBUG"), Conditional("TEST1")] + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (269:4,0 [13] AttributeDirective.cshtml) + IntermediateToken - (269:4,0 [13] AttributeDirective.cshtml) - Html - \nHello World diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..c76e0fc08c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (11:0,11 [56] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml) +|[System.Runtime.InteropServices.DllImport("user32.dll")]| +Generated Location: (271:7,11 [56] ) +|[System.Runtime.InteropServices.DllImport("user32.dll")]| + +Source Location: (80:1,11 [51] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml) +|[assembly: AssemblyTitleAttribute("Some assembly")]| +Generated Location: (503:14,11 [51] ) +|[assembly: AssemblyTitleAttribute("Some assembly")]| + +Source Location: (144:2,11 [66] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml) +|[DllImport("user32.dll", SetLastError=false, ExactSpelling=false)]| +Generated Location: (730:21,11 [66] ) +|[DllImport("user32.dll", SetLastError=false, ExactSpelling=false)]| + +Source Location: (223:3,11 [44] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml) +|[Conditional("DEBUG"), Conditional("TEST1")]| +Generated Location: (972:28,11 [44] ) +|[Conditional("DEBUG"), Conditional("TEST1")]| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_Runtime.codegen.cs new file mode 100644 index 0000000000..ec883320dd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_Runtime.codegen.cs @@ -0,0 +1,47 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "796e795e99f31ccb6c596e30f8540f5de179132a" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirective_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [System.Runtime.InteropServices.DllImport("user32.dll")] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [assembly: AssemblyTitleAttribute("Some assembly")] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)] + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml" + [Conditional("DEBUG"), Conditional("TEST1")] + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"796e795e99f31ccb6c596e30f8540f5de179132a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirective_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\nHello World"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_Runtime.ir.txt new file mode 100644 index 0000000000..98f79e9671 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_Runtime.ir.txt @@ -0,0 +1,16 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + CSharpCode - (11:0,11 [56] AttributeDirective.cshtml) + IntermediateToken - (11:0,11 [56] AttributeDirective.cshtml) - CSharp - [System.Runtime.InteropServices.DllImport("user32.dll")] + CSharpCode - (80:1,11 [51] AttributeDirective.cshtml) + IntermediateToken - (80:1,11 [51] AttributeDirective.cshtml) - CSharp - [assembly: AssemblyTitleAttribute("Some assembly")] + CSharpCode - (144:2,11 [66] AttributeDirective.cshtml) + IntermediateToken - (144:2,11 [66] AttributeDirective.cshtml) - CSharp - [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)] + CSharpCode - (223:3,11 [44] AttributeDirective.cshtml) + IntermediateToken - (223:3,11 [44] AttributeDirective.cshtml) - CSharp - [Conditional("DEBUG"), Conditional("TEST1")] + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeDirective_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (269:4,0 [13] AttributeDirective.cshtml) + IntermediateToken - (269:4,0 [13] AttributeDirective.cshtml) - Html - \nHello World diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml new file mode 100644 index 0000000000..8610fe90aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml @@ -0,0 +1,8 @@ +@addTagHelper *, TestAssembly + +

        +

        HelloWorld

        + + + +

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..8548f916c2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,70 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "checkbox"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "checkbox"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..db2f83bb78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt @@ -0,0 +1,85 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] AttributeTargetingTagHelpers.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [4] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (29:0,29 [4] AttributeTargetingTagHelpers.cshtml) - Html - \n\n + TagHelper - (33:2,0 [228] AttributeTargetingTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (48:2,15 [9] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (48:2,15 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + IntermediateToken - (54:3,4 [2] AttributeTargetingTagHelpers.cshtml) - Html -

        + TagHelper - (57:3,7 [36] AttributeTargetingTagHelpers.cshtml) - strong - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (79:3,29 [5] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (79:3,29 [5] AttributeTargetingTagHelpers.cshtml) - Html - Hello + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - catchAll - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (75:3,25 [2] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (75:3,25 [2] AttributeTargetingTagHelpers.cshtml) - Html - hi + DefaultTagHelperExecute - + HtmlContent - (93:3,43 [62] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (93:3,43 [7] AttributeTargetingTagHelpers.cshtml) - Html - + IntermediateToken - (101:3,51 [5] AttributeTargetingTagHelpers.cshtml) - Html - World + IntermediateToken - (106:3,56 [9] AttributeTargetingTagHelpers.cshtml) - Html - + IntermediateToken - (115:3,65 [4] AttributeTargetingTagHelpers.cshtml) - Html -

        + IntermediateToken - (119:3,69 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + IntermediateToken - (125:4,4 [6] AttributeTargetingTagHelpers.cshtml) - Html - + IntermediateToken - (149:4,28 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + TagHelper - (155:5,4 [40] AttributeTargetingTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (187:5,36 [4] AttributeTargetingTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (187:5,36 [4] AttributeTargetingTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (195:5,44 [6] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (195:5,44 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + TagHelper - (201:6,4 [54] AttributeTargetingTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (233:6,36 [4] AttributeTargetingTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (233:6,36 [4] AttributeTargetingTagHelpers.cshtml) - CSharp - true + DefaultTagHelperHtmlAttribute - - catchAll - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (249:6,52 [2] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (249:6,52 [2] AttributeTargetingTagHelpers.cshtml) - Html - hi + DefaultTagHelperExecute - + HtmlContent - (255:6,58 [2] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (255:6,58 [2] AttributeTargetingTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (43:2,10 [3] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (43:2,10 [3] AttributeTargetingTagHelpers.cshtml) - Html - btn + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..daeee4d6ba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml) +|*, TestAssembly| +Generated Location: (1310:21,38 [15] ) +|*, TestAssembly| + +Source Location: (187:5,36 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml) +|true| +Generated Location: (2403:44,42 [4] ) +|true| + +Source Location: (233:6,36 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml) +|true| +Generated Location: (3170:57,42 [4] ) +|true| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..0d6a110467 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.codegen.cs @@ -0,0 +1,132 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2ceb35a784a30ab44eb8b621c9e61d2361841c63" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2ceb35a784a30ab44eb8b621c9e61d2361841c63", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("catchAll", new global::Microsoft.AspNetCore.Html.HtmlString("hi"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("btn"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n

        "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("strong", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Hello"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("World

        \r\n \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..dd411e5da2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_Runtime.ir.txt @@ -0,0 +1,68 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - catchAll - hi - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - btn - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:1,0 [2] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (31:1,0 [2] AttributeTargetingTagHelpers.cshtml) - Html - \n + TagHelper - (33:2,0 [228] AttributeTargetingTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (48:2,15 [9] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (48:2,15 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + IntermediateToken - (54:3,4 [2] AttributeTargetingTagHelpers.cshtml) - Html -

        + TagHelper - (57:3,7 [36] AttributeTargetingTagHelpers.cshtml) - strong - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (79:3,29 [5] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (79:3,29 [5] AttributeTargetingTagHelpers.cshtml) - Html - Hello + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (93:3,43 [62] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (93:3,43 [7] AttributeTargetingTagHelpers.cshtml) - Html - + IntermediateToken - (101:3,51 [5] AttributeTargetingTagHelpers.cshtml) - Html - World + IntermediateToken - (106:3,56 [9] AttributeTargetingTagHelpers.cshtml) - Html - + IntermediateToken - (115:3,65 [4] AttributeTargetingTagHelpers.cshtml) - Html -

        + IntermediateToken - (119:3,69 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + IntermediateToken - (125:4,4 [6] AttributeTargetingTagHelpers.cshtml) - Html - + IntermediateToken - (149:4,28 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + TagHelper - (155:5,4 [40] AttributeTargetingTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) - __tagHelperAttribute_1 - type - Type + PreallocatedTagHelperProperty - (168:5,17 [8] AttributeTargetingTagHelpers.cshtml) - __tagHelperAttribute_1 - type - Type + DefaultTagHelperProperty - (187:5,36 [4] AttributeTargetingTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (187:5,36 [4] AttributeTargetingTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (195:5,44 [6] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (195:5,44 [6] AttributeTargetingTagHelpers.cshtml) - Html - \n + TagHelper - (201:6,4 [54] AttributeTargetingTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperProperty - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) - __tagHelperAttribute_1 - type - Type + PreallocatedTagHelperProperty - (214:6,17 [8] AttributeTargetingTagHelpers.cshtml) - __tagHelperAttribute_1 - type - Type + DefaultTagHelperProperty - (233:6,36 [4] AttributeTargetingTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (233:6,36 [4] AttributeTargetingTagHelpers.cshtml) - CSharp - true + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (255:6,58 [2] AttributeTargetingTagHelpers.cshtml) + IntermediateToken - (255:6,58 [2] AttributeTargetingTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml new file mode 100644 index 0000000000..69b68e07c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml @@ -0,0 +1,26 @@ +@functions { + public async Task Foo() + { + return "Bar"; + } +} + +
        +

        Basic Asynchronous Expression Test

        +

        Basic Asynchronous Expression: @await Foo()

        +

        Basic Asynchronous Template: @(await Foo())

        +

        Basic Asynchronous Statement: @{ await Foo(); }

        +

        Basic Asynchronous Statement Nested: @{ @await Foo() }

        +

        Basic Incomplete Asynchronous Statement: @await

        +
        + +
        +

        Advanced Asynchronous Expression Test

        +

        Advanced Asynchronous Expression: @await Foo(1, 2)

        +

        Advanced Asynchronous Expression Extended: @await Foo.Bar(1, 2)

        +

        Advanced Asynchronous Template: @(await Foo("bob", true))

        +

        Advanced Asynchronous Statement: @{ await Foo(something, hello: "world"); }

        +

        Advanced Asynchronous Statement Extended: @{ await Foo.Bar(1, 2) }

        +

        Advanced Asynchronous Statement Nested: @{ @await Foo(boolValue: false) }

        +

        Advanced Incomplete Asynchronous Statement: @await ("wrrronggg")

        +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs new file mode 100644 index 0000000000..850e7d6fae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.cs @@ -0,0 +1,145 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + await Foo(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo(1, 2); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo.Bar(1, 2); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo("bob", true); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + await Foo(something, hello: "world"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + await Foo.Bar(1, 2) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await Foo(boolValue: false); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + __o = await ("wrrronggg"); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + public async Task Foo() + { + return "Bar"; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.html new file mode 100644 index 0000000000..22593ca1ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.codegen.html @@ -0,0 +1,26 @@ + + + + + + + +
        +

        Basic Asynchronous Expression Test

        +

        Basic Asynchronous Expression:

        +

        Basic Asynchronous Template:

        +

        Basic Asynchronous Statement:

        +

        Basic Asynchronous Statement Nested:

        +

        Basic Incomplete Asynchronous Statement:

        +
        + +
        +

        Advanced Asynchronous Expression Test

        +

        Advanced Asynchronous Expression:

        +

        Advanced Asynchronous Expression Extended:

        +

        Advanced Asynchronous Template:

        +

        Advanced Asynchronous Statement:

        +

        Advanced Asynchronous Statement Extended:

        +

        Advanced Asynchronous Statement Nested:

        +

        Advanced Incomplete Asynchronous Statement:

        +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt new file mode 100644 index 0000000000..0794ebc4bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt @@ -0,0 +1,148 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (89:5,1 [102] Await.cshtml) + IntermediateToken - (89:5,1 [4] Await.cshtml) - Html - \n\n + IntermediateToken - (93:7,0 [8] Await.cshtml) - Html -
        + IntermediateToken - (102:7,9 [6] Await.cshtml) - Html - \n + IntermediateToken - (108:8,4 [3] Await.cshtml) - Html -

        + IntermediateToken - (112:8,8 [34] Await.cshtml) - Html - Basic Asynchronous Expression Test + IntermediateToken - (146:8,42 [5] Await.cshtml) - Html -

        + IntermediateToken - (151:8,47 [6] Await.cshtml) - Html - \n + IntermediateToken - (157:9,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (160:9,7 [31] Await.cshtml) - Html - Basic Asynchronous Expression: + CSharpExpression - (192:9,39 [11] Await.cshtml) + IntermediateToken - (192:9,39 [11] Await.cshtml) - CSharp - await Foo() + HtmlContent - (203:9,50 [42] Await.cshtml) + IntermediateToken - (203:9,50 [4] Await.cshtml) - Html -

        + IntermediateToken - (207:9,54 [6] Await.cshtml) - Html - \n + IntermediateToken - (213:10,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (216:10,7 [29] Await.cshtml) - Html - Basic Asynchronous Template: + CSharpExpression - (247:10,38 [11] Await.cshtml) + IntermediateToken - (247:10,38 [11] Await.cshtml) - CSharp - await Foo() + HtmlContent - (259:10,50 [43] Await.cshtml) + IntermediateToken - (259:10,50 [4] Await.cshtml) - Html -

        + IntermediateToken - (263:10,54 [6] Await.cshtml) - Html - \n + IntermediateToken - (269:11,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (272:11,7 [30] Await.cshtml) - Html - Basic Asynchronous Statement: + CSharpCode - (304:11,39 [14] Await.cshtml) + IntermediateToken - (304:11,39 [14] Await.cshtml) - CSharp - await Foo(); + HtmlContent - (319:11,54 [50] Await.cshtml) + IntermediateToken - (319:11,54 [4] Await.cshtml) - Html -

        + IntermediateToken - (323:11,58 [6] Await.cshtml) - Html - \n + IntermediateToken - (329:12,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (332:12,7 [37] Await.cshtml) - Html - Basic Asynchronous Statement Nested: + CSharpCode - (371:12,46 [1] Await.cshtml) + IntermediateToken - (371:12,46 [1] Await.cshtml) - CSharp - + HtmlContent - (372:12,47 [3] Await.cshtml) + IntermediateToken - (372:12,47 [2] Await.cshtml) - Html - + CSharpExpression - (376:12,51 [11] Await.cshtml) + IntermediateToken - (376:12,51 [11] Await.cshtml) - CSharp - await Foo() + HtmlContent - (387:12,62 [4] Await.cshtml) + IntermediateToken - (387:12,62 [4] Await.cshtml) - Html - + CSharpCode - (391:12,66 [1] Await.cshtml) + IntermediateToken - (391:12,66 [1] Await.cshtml) - CSharp - + HtmlContent - (393:12,68 [54] Await.cshtml) + IntermediateToken - (393:12,68 [4] Await.cshtml) - Html -

        + IntermediateToken - (397:12,72 [6] Await.cshtml) - Html - \n + IntermediateToken - (403:13,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (406:13,7 [41] Await.cshtml) - Html - Basic Incomplete Asynchronous Statement: + CSharpExpression - (448:13,49 [5] Await.cshtml) + IntermediateToken - (448:13,49 [5] Await.cshtml) - CSharp - await + HtmlContent - (453:13,54 [124] Await.cshtml) + IntermediateToken - (453:13,54 [4] Await.cshtml) - Html -

        + IntermediateToken - (457:13,58 [2] Await.cshtml) - Html - \n + IntermediateToken - (459:14,0 [10] Await.cshtml) - Html -
        + IntermediateToken - (469:14,10 [4] Await.cshtml) - Html - \n\n + IntermediateToken - (473:16,0 [8] Await.cshtml) - Html -
        + IntermediateToken - (482:16,9 [6] Await.cshtml) - Html - \n + IntermediateToken - (488:17,4 [3] Await.cshtml) - Html -

        + IntermediateToken - (492:17,8 [37] Await.cshtml) - Html - Advanced Asynchronous Expression Test + IntermediateToken - (529:17,45 [5] Await.cshtml) - Html -

        + IntermediateToken - (534:17,50 [6] Await.cshtml) - Html - \n + IntermediateToken - (540:18,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (543:18,7 [34] Await.cshtml) - Html - Advanced Asynchronous Expression: + CSharpExpression - (578:18,42 [15] Await.cshtml) + IntermediateToken - (578:18,42 [15] Await.cshtml) - CSharp - await Foo(1, 2) + HtmlContent - (593:18,57 [56] Await.cshtml) + IntermediateToken - (593:18,57 [4] Await.cshtml) - Html -

        + IntermediateToken - (597:18,61 [6] Await.cshtml) - Html - \n + IntermediateToken - (603:19,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (606:19,7 [43] Await.cshtml) - Html - Advanced Asynchronous Expression Extended: + CSharpExpression - (650:19,51 [19] Await.cshtml) + IntermediateToken - (650:19,51 [19] Await.cshtml) - CSharp - await Foo.Bar(1, 2) + HtmlContent - (669:19,70 [45] Await.cshtml) + IntermediateToken - (669:19,70 [4] Await.cshtml) - Html -

        + IntermediateToken - (673:19,74 [6] Await.cshtml) - Html - \n + IntermediateToken - (679:20,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (682:20,7 [32] Await.cshtml) - Html - Advanced Asynchronous Template: + CSharpExpression - (716:20,41 [22] Await.cshtml) + IntermediateToken - (716:20,41 [22] Await.cshtml) - CSharp - await Foo("bob", true) + HtmlContent - (739:20,64 [46] Await.cshtml) + IntermediateToken - (739:20,64 [4] Await.cshtml) - Html -

        + IntermediateToken - (743:20,68 [6] Await.cshtml) - Html - \n + IntermediateToken - (749:21,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (752:21,7 [33] Await.cshtml) - Html - Advanced Asynchronous Statement: + CSharpCode - (787:21,42 [39] Await.cshtml) + IntermediateToken - (787:21,42 [39] Await.cshtml) - CSharp - await Foo(something, hello: "world"); + HtmlContent - (827:21,82 [55] Await.cshtml) + IntermediateToken - (827:21,82 [4] Await.cshtml) - Html -

        + IntermediateToken - (831:21,86 [6] Await.cshtml) - Html - \n + IntermediateToken - (837:22,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (840:22,7 [42] Await.cshtml) - Html - Advanced Asynchronous Statement Extended: + CSharpCode - (884:22,51 [21] Await.cshtml) + IntermediateToken - (884:22,51 [21] Await.cshtml) - CSharp - await Foo.Bar(1, 2) + HtmlContent - (906:22,73 [53] Await.cshtml) + IntermediateToken - (906:22,73 [4] Await.cshtml) - Html -

        + IntermediateToken - (910:22,77 [6] Await.cshtml) - Html - \n + IntermediateToken - (916:23,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (919:23,7 [40] Await.cshtml) - Html - Advanced Asynchronous Statement Nested: + CSharpCode - (961:23,49 [1] Await.cshtml) + IntermediateToken - (961:23,49 [1] Await.cshtml) - CSharp - + HtmlContent - (962:23,50 [3] Await.cshtml) + IntermediateToken - (962:23,50 [2] Await.cshtml) - Html - + CSharpExpression - (966:23,54 [27] Await.cshtml) + IntermediateToken - (966:23,54 [27] Await.cshtml) - CSharp - await Foo(boolValue: false) + HtmlContent - (993:23,81 [4] Await.cshtml) + IntermediateToken - (993:23,81 [4] Await.cshtml) - Html - + CSharpCode - (997:23,85 [1] Await.cshtml) + IntermediateToken - (997:23,85 [1] Await.cshtml) - CSharp - + HtmlContent - (999:23,87 [57] Await.cshtml) + IntermediateToken - (999:23,87 [4] Await.cshtml) - Html -

        + IntermediateToken - (1003:23,91 [6] Await.cshtml) - Html - \n + IntermediateToken - (1009:24,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (1012:24,7 [44] Await.cshtml) - Html - Advanced Incomplete Asynchronous Statement: + CSharpExpression - (1057:24,52 [19] Await.cshtml) + IntermediateToken - (1057:24,52 [19] Await.cshtml) - CSharp - await ("wrrronggg") + HtmlContent - (1076:24,71 [16] Await.cshtml) + IntermediateToken - (1076:24,71 [4] Await.cshtml) - Html -

        + IntermediateToken - (1080:24,75 [2] Await.cshtml) - Html - \n + IntermediateToken - (1082:25,0 [10] Await.cshtml) - Html -
        + CSharpCode - (12:0,12 [76] Await.cshtml) + IntermediateToken - (12:0,12 [76] Await.cshtml) - CSharp - \n public async Task Foo()\n {\n return "Bar";\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt new file mode 100644 index 0000000000..8fd6a5044a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.mappings.txt @@ -0,0 +1,95 @@ +Source Location: (192:9,39 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo()| +Generated Location: (768:19,39 [11] ) +|await Foo()| + +Source Location: (247:10,38 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo()| +Generated Location: (971:26,38 [11] ) +|await Foo()| + +Source Location: (304:11,39 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| await Foo(); | +Generated Location: (1175:33,39 [14] ) +| await Foo(); | + +Source Location: (371:12,46 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| | +Generated Location: (1388:40,46 [1] ) +| | + +Source Location: (376:12,51 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo()| +Generated Location: (1593:47,51 [11] ) +|await Foo()| + +Source Location: (391:12,66 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| | +Generated Location: (1824:54,66 [1] ) +| | + +Source Location: (448:13,49 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await| +Generated Location: (2027:61,49 [5] ) +|await| + +Source Location: (578:18,42 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo(1, 2)| +Generated Location: (2228:68,42 [15] ) +|await Foo(1, 2)| + +Source Location: (650:19,51 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo.Bar(1, 2)| +Generated Location: (2448:75,51 [19] ) +|await Foo.Bar(1, 2)| + +Source Location: (716:20,41 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo("bob", true)| +Generated Location: (2662:82,41 [22] ) +|await Foo("bob", true)| + +Source Location: (787:21,42 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| await Foo(something, hello: "world"); | +Generated Location: (2880:89,42 [39] ) +| await Foo(something, hello: "world"); | + +Source Location: (884:22,51 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| await Foo.Bar(1, 2) | +Generated Location: (3123:96,51 [21] ) +| await Foo.Bar(1, 2) | + +Source Location: (961:23,49 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| | +Generated Location: (3346:103,49 [1] ) +| | + +Source Location: (966:23,54 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await Foo(boolValue: false)| +Generated Location: (3554:110,54 [27] ) +|await Foo(boolValue: false)| + +Source Location: (997:23,85 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| | +Generated Location: (3820:117,85 [1] ) +| | + +Source Location: (1057:24,52 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +|await ("wrrronggg")| +Generated Location: (4026:124,52 [19] ) +|await ("wrrronggg")| + +Source Location: (12:0,12 [76] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml) +| + public async Task Foo() + { + return "Bar"; + } +| +Generated Location: (4259:133,12 [76] ) +| + public async Task Foo() + { + return "Bar"; + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs new file mode 100644 index 0000000000..7eb1804dc5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.codegen.cs @@ -0,0 +1,130 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5a02c3ec89081f6e0a8f4810e127eed40467c358" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5a02c3ec89081f6e0a8f4810e127eed40467c358", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n
        \r\n

        Basic Asynchronous Expression Test

        \r\n

        Basic Asynchronous Expression: "); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo()); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Basic Asynchronous Template: "); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo()); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Basic Asynchronous Statement: "); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + await Foo(); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Basic Asynchronous Statement Nested: "); + WriteLiteral(" "); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo()); + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + WriteLiteral("

        \r\n

        Basic Incomplete Asynchronous Statement: "); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n
        \r\n\r\n
        \r\n

        Advanced Asynchronous Expression Test

        \r\n

        Advanced Asynchronous Expression: "); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo(1, 2)); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Advanced Asynchronous Expression Extended: "); +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo.Bar(1, 2)); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Advanced Asynchronous Template: "); +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo("bob", true)); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Advanced Asynchronous Statement: "); +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + await Foo(something, hello: "world"); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Advanced Asynchronous Statement Extended: "); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + await Foo.Bar(1, 2) + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n

        Advanced Asynchronous Statement Nested: "); + WriteLiteral(" "); +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await Foo(boolValue: false)); + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + WriteLiteral("

        \r\n

        Advanced Incomplete Asynchronous Statement: "); +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + Write(await ("wrrronggg")); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n
        "); + } + #pragma warning restore 1998 +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await.cshtml" + + public async Task Foo() + { + return "Bar"; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt new file mode 100644 index 0000000000..5b906426af --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_Runtime.ir.txt @@ -0,0 +1,143 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (91:6,0 [100] Await.cshtml) + IntermediateToken - (91:6,0 [2] Await.cshtml) - Html - \n + IntermediateToken - (93:7,0 [8] Await.cshtml) - Html -
        + IntermediateToken - (102:7,9 [6] Await.cshtml) - Html - \n + IntermediateToken - (108:8,4 [3] Await.cshtml) - Html -

        + IntermediateToken - (112:8,8 [34] Await.cshtml) - Html - Basic Asynchronous Expression Test + IntermediateToken - (146:8,42 [5] Await.cshtml) - Html -

        + IntermediateToken - (151:8,47 [6] Await.cshtml) - Html - \n + IntermediateToken - (157:9,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (160:9,7 [31] Await.cshtml) - Html - Basic Asynchronous Expression: + CSharpExpression - (192:9,39 [11] Await.cshtml) + IntermediateToken - (192:9,39 [11] Await.cshtml) - CSharp - await Foo() + HtmlContent - (203:9,50 [42] Await.cshtml) + IntermediateToken - (203:9,50 [4] Await.cshtml) - Html -

        + IntermediateToken - (207:9,54 [6] Await.cshtml) - Html - \n + IntermediateToken - (213:10,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (216:10,7 [29] Await.cshtml) - Html - Basic Asynchronous Template: + CSharpExpression - (247:10,38 [11] Await.cshtml) + IntermediateToken - (247:10,38 [11] Await.cshtml) - CSharp - await Foo() + HtmlContent - (259:10,50 [43] Await.cshtml) + IntermediateToken - (259:10,50 [4] Await.cshtml) - Html -

        + IntermediateToken - (263:10,54 [6] Await.cshtml) - Html - \n + IntermediateToken - (269:11,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (272:11,7 [30] Await.cshtml) - Html - Basic Asynchronous Statement: + CSharpCode - (304:11,39 [14] Await.cshtml) + IntermediateToken - (304:11,39 [14] Await.cshtml) - CSharp - await Foo(); + HtmlContent - (319:11,54 [50] Await.cshtml) + IntermediateToken - (319:11,54 [4] Await.cshtml) - Html -

        + IntermediateToken - (323:11,58 [6] Await.cshtml) - Html - \n + IntermediateToken - (329:12,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (332:12,7 [37] Await.cshtml) - Html - Basic Asynchronous Statement Nested: + HtmlContent - (371:12,46 [4] Await.cshtml) + IntermediateToken - (371:12,46 [1] Await.cshtml) - Html - + IntermediateToken - (372:12,47 [2] Await.cshtml) - Html - + CSharpExpression - (376:12,51 [11] Await.cshtml) + IntermediateToken - (376:12,51 [11] Await.cshtml) - CSharp - await Foo() + HtmlContent - (387:12,62 [5] Await.cshtml) + IntermediateToken - (387:12,62 [4] Await.cshtml) - Html - + IntermediateToken - (391:12,66 [1] Await.cshtml) - Html - + CSharpCode - (392:12,67 [0] Await.cshtml) + IntermediateToken - (392:12,67 [0] Await.cshtml) - CSharp - + HtmlContent - (393:12,68 [54] Await.cshtml) + IntermediateToken - (393:12,68 [4] Await.cshtml) - Html -

        + IntermediateToken - (397:12,72 [6] Await.cshtml) - Html - \n + IntermediateToken - (403:13,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (406:13,7 [41] Await.cshtml) - Html - Basic Incomplete Asynchronous Statement: + CSharpExpression - (448:13,49 [5] Await.cshtml) + IntermediateToken - (448:13,49 [5] Await.cshtml) - CSharp - await + HtmlContent - (453:13,54 [124] Await.cshtml) + IntermediateToken - (453:13,54 [4] Await.cshtml) - Html -

        + IntermediateToken - (457:13,58 [2] Await.cshtml) - Html - \n + IntermediateToken - (459:14,0 [10] Await.cshtml) - Html -
        + IntermediateToken - (469:14,10 [4] Await.cshtml) - Html - \n\n + IntermediateToken - (473:16,0 [8] Await.cshtml) - Html -
        + IntermediateToken - (482:16,9 [6] Await.cshtml) - Html - \n + IntermediateToken - (488:17,4 [3] Await.cshtml) - Html -

        + IntermediateToken - (492:17,8 [37] Await.cshtml) - Html - Advanced Asynchronous Expression Test + IntermediateToken - (529:17,45 [5] Await.cshtml) - Html -

        + IntermediateToken - (534:17,50 [6] Await.cshtml) - Html - \n + IntermediateToken - (540:18,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (543:18,7 [34] Await.cshtml) - Html - Advanced Asynchronous Expression: + CSharpExpression - (578:18,42 [15] Await.cshtml) + IntermediateToken - (578:18,42 [15] Await.cshtml) - CSharp - await Foo(1, 2) + HtmlContent - (593:18,57 [56] Await.cshtml) + IntermediateToken - (593:18,57 [4] Await.cshtml) - Html -

        + IntermediateToken - (597:18,61 [6] Await.cshtml) - Html - \n + IntermediateToken - (603:19,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (606:19,7 [43] Await.cshtml) - Html - Advanced Asynchronous Expression Extended: + CSharpExpression - (650:19,51 [19] Await.cshtml) + IntermediateToken - (650:19,51 [19] Await.cshtml) - CSharp - await Foo.Bar(1, 2) + HtmlContent - (669:19,70 [45] Await.cshtml) + IntermediateToken - (669:19,70 [4] Await.cshtml) - Html -

        + IntermediateToken - (673:19,74 [6] Await.cshtml) - Html - \n + IntermediateToken - (679:20,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (682:20,7 [32] Await.cshtml) - Html - Advanced Asynchronous Template: + CSharpExpression - (716:20,41 [22] Await.cshtml) + IntermediateToken - (716:20,41 [22] Await.cshtml) - CSharp - await Foo("bob", true) + HtmlContent - (739:20,64 [46] Await.cshtml) + IntermediateToken - (739:20,64 [4] Await.cshtml) - Html -

        + IntermediateToken - (743:20,68 [6] Await.cshtml) - Html - \n + IntermediateToken - (749:21,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (752:21,7 [33] Await.cshtml) - Html - Advanced Asynchronous Statement: + CSharpCode - (787:21,42 [39] Await.cshtml) + IntermediateToken - (787:21,42 [39] Await.cshtml) - CSharp - await Foo(something, hello: "world"); + HtmlContent - (827:21,82 [55] Await.cshtml) + IntermediateToken - (827:21,82 [4] Await.cshtml) - Html -

        + IntermediateToken - (831:21,86 [6] Await.cshtml) - Html - \n + IntermediateToken - (837:22,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (840:22,7 [42] Await.cshtml) - Html - Advanced Asynchronous Statement Extended: + CSharpCode - (884:22,51 [21] Await.cshtml) + IntermediateToken - (884:22,51 [21] Await.cshtml) - CSharp - await Foo.Bar(1, 2) + HtmlContent - (906:22,73 [53] Await.cshtml) + IntermediateToken - (906:22,73 [4] Await.cshtml) - Html -

        + IntermediateToken - (910:22,77 [6] Await.cshtml) - Html - \n + IntermediateToken - (916:23,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (919:23,7 [40] Await.cshtml) - Html - Advanced Asynchronous Statement Nested: + HtmlContent - (961:23,49 [4] Await.cshtml) + IntermediateToken - (961:23,49 [1] Await.cshtml) - Html - + IntermediateToken - (962:23,50 [2] Await.cshtml) - Html - + CSharpExpression - (966:23,54 [27] Await.cshtml) + IntermediateToken - (966:23,54 [27] Await.cshtml) - CSharp - await Foo(boolValue: false) + HtmlContent - (993:23,81 [5] Await.cshtml) + IntermediateToken - (993:23,81 [4] Await.cshtml) - Html - + IntermediateToken - (997:23,85 [1] Await.cshtml) - Html - + CSharpCode - (998:23,86 [0] Await.cshtml) + IntermediateToken - (998:23,86 [0] Await.cshtml) - CSharp - + HtmlContent - (999:23,87 [57] Await.cshtml) + IntermediateToken - (999:23,87 [4] Await.cshtml) - Html -

        + IntermediateToken - (1003:23,91 [6] Await.cshtml) - Html - \n + IntermediateToken - (1009:24,4 [2] Await.cshtml) - Html -

        + IntermediateToken - (1012:24,7 [44] Await.cshtml) - Html - Advanced Incomplete Asynchronous Statement: + CSharpExpression - (1057:24,52 [19] Await.cshtml) + IntermediateToken - (1057:24,52 [19] Await.cshtml) - CSharp - await ("wrrronggg") + HtmlContent - (1076:24,71 [16] Await.cshtml) + IntermediateToken - (1076:24,71 [4] Await.cshtml) - Html -

        + IntermediateToken - (1080:24,75 [2] Await.cshtml) - Html - \n + IntermediateToken - (1082:25,0 [10] Await.cshtml) - Html -
        + CSharpCode - (12:0,12 [76] Await.cshtml) + IntermediateToken - (12:0,12 [76] Await.cshtml) - CSharp - \n public async Task Foo()\n {\n return "Bar";\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml new file mode 100644 index 0000000000..b58b6b44ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml @@ -0,0 +1,9 @@ +@addTagHelper "*, TestAssembly" + +
        +

        +

        + + +

        +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..658cf27126 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,68 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" + __o = ViewBag.DefaultInterval; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Type = "text"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "checkbox"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..38d793eaeb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt @@ -0,0 +1,84 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] BasicTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [73] BasicTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] BasicTagHelpers.cshtml) - Html - \n\n + IntermediateToken - (35:2,0 [4] BasicTagHelpers.cshtml) - Html -
        + IntermediateToken - (98:2,63 [6] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (104:3,4 [216] BasicTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (145:3,45 [10] BasicTagHelpers.cshtml) + IntermediateToken - (145:3,45 [10] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (155:4,8 [25] BasicTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - data - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (164:4,17 [10] BasicTagHelpers.cshtml) + IntermediateToken - (164:4,17 [10] BasicTagHelpers.cshtml) - Html - -delay1000 + DefaultTagHelperExecute - + HtmlContent - (180:4,33 [10] BasicTagHelpers.cshtml) + IntermediateToken - (180:4,33 [10] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (190:5,8 [71] BasicTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperHtmlAttribute - - data-interval - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (212:5,30 [7] BasicTagHelpers.cshtml) + IntermediateToken - (212:5,30 [7] BasicTagHelpers.cshtml) - Html - 2000 + + CSharpExpression - (220:5,38 [23] BasicTagHelpers.cshtml) + IntermediateToken - (220:5,38 [23] BasicTagHelpers.cshtml) - CSharp - ViewBag.DefaultInterval + HtmlContent - (243:5,61 [4] BasicTagHelpers.cshtml) + IntermediateToken - (243:5,61 [4] BasicTagHelpers.cshtml) - Html - + 1 + DefaultTagHelperProperty - (255:5,73 [4] BasicTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (255:5,73 [4] BasicTagHelpers.cshtml) + IntermediateToken - (255:5,73 [4] BasicTagHelpers.cshtml) - Html - text + DefaultTagHelperProperty - (255:5,73 [4] BasicTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (255:5,73 [4] BasicTagHelpers.cshtml) + IntermediateToken - (255:5,73 [4] BasicTagHelpers.cshtml) - Html - text + DefaultTagHelperExecute - + HtmlContent - (261:5,79 [10] BasicTagHelpers.cshtml) + IntermediateToken - (261:5,79 [10] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (271:6,8 [39] BasicTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (284:6,21 [8] BasicTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (284:6,21 [8] BasicTagHelpers.cshtml) + IntermediateToken - (284:6,21 [8] BasicTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (284:6,21 [8] BasicTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (284:6,21 [8] BasicTagHelpers.cshtml) + IntermediateToken - (284:6,21 [8] BasicTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (303:6,40 [4] BasicTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (303:6,40 [4] BasicTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (310:6,47 [6] BasicTagHelpers.cshtml) + IntermediateToken - (310:6,47 [6] BasicTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (114:3,14 [11] BasicTagHelpers.cshtml) + IntermediateToken - (114:3,14 [11] BasicTagHelpers.cshtml) - Html - Hello World + DefaultTagHelperHtmlAttribute - - data-delay - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (139:3,39 [4] BasicTagHelpers.cshtml) + IntermediateToken - (139:3,39 [4] BasicTagHelpers.cshtml) - Html - 1000 + DefaultTagHelperExecute - + HtmlContent - (320:7,8 [8] BasicTagHelpers.cshtml) + IntermediateToken - (320:7,8 [2] BasicTagHelpers.cshtml) - Html - \n + IntermediateToken - (322:8,0 [6] BasicTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..a2450c46b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1191:20,37 [17] ) +|"*, TestAssembly"| + +Source Location: (220:5,38 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml) +|ViewBag.DefaultInterval| +Generated Location: (2102:41,38 [23] ) +|ViewBag.DefaultInterval| + +Source Location: (303:6,40 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml) +|true| +Generated Location: (2914:55,42 [4] ) +|true| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml new file mode 100644 index 0000000000..089363600c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml @@ -0,0 +1,10 @@ +@tagHelperPrefix "THS" +@addTagHelper "*, TestAssembly" + + + +

        + + +
        +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.codegen.cs new file mode 100644 index 0000000000..92e4fa5dc6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.codegen.cs @@ -0,0 +1,64 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" +global::System.Object __typeHelper = "THS"; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "checkbox"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" + __TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt new file mode 100644 index 0000000000..837de656c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt @@ -0,0 +1,60 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (17:0,17 [5] BasicTagHelpers_Prefixed.cshtml) - "THS" + DirectiveToken - (38:1,14 [17] BasicTagHelpers_Prefixed.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (22:0,22 [2] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (22:0,22 [2] BasicTagHelpers_Prefixed.cshtml) - Html - \n + HtmlContent - (55:1,31 [54] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (55:1,31 [4] BasicTagHelpers_Prefixed.cshtml) - Html - \n\n + IntermediateToken - (59:3,0 [7] BasicTagHelpers_Prefixed.cshtml) - Html - + IntermediateToken - (103:3,44 [6] BasicTagHelpers_Prefixed.cshtml) - Html - \n + TagHelper - (109:4,4 [136] BasicTagHelpers_Prefixed.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (135:4,30 [56] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (135:4,30 [10] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (145:5,8 [2] BasicTagHelpers_Prefixed.cshtml) - Html -

        + IntermediateToken - (148:5,11 [4] BasicTagHelpers_Prefixed.cshtml) - Html -

        + IntermediateToken - (152:5,15 [10] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (162:6,8 [6] BasicTagHelpers_Prefixed.cshtml) - Html - + IntermediateToken - (181:6,27 [10] BasicTagHelpers_Prefixed.cshtml) - Html - \n + TagHelper - (191:7,8 [41] BasicTagHelpers_Prefixed.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) - Html - checkbox + DefaultTagHelperProperty - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) - Html - checkbox + DefaultTagHelperProperty - (226:7,43 [4] BasicTagHelpers_Prefixed.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (226:7,43 [4] BasicTagHelpers_Prefixed.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (232:7,49 [6] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (232:7,49 [6] BasicTagHelpers_Prefixed.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (122:4,17 [11] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (122:4,17 [11] BasicTagHelpers_Prefixed.cshtml) - Html - Hello World + DefaultTagHelperExecute - + HtmlContent - (245:8,11 [11] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (245:8,11 [2] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (247:9,0 [9] BasicTagHelpers_Prefixed.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.mappings.txt new file mode 100644 index 0000000000..63bd2edaff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (17:0,17 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml) +|"THS"| +Generated Location: (1209:20,37 [5] ) +|"THS"| + +Source Location: (38:1,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml) +|"*, TestAssembly"| +Generated Location: (1483:30,37 [17] ) +|"*, TestAssembly"| + +Source Location: (226:7,43 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml) +|true| +Generated Location: (2389:51,43 [4] ) +|true| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs new file mode 100644 index 0000000000..6d015f413d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs @@ -0,0 +1,86 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b7372519d2a9b45537aba0e7d34309526d3014c3" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b7372519d2a9b45537aba0e7d34309526d3014c3", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n

        \r\n \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt new file mode 100644 index 0000000000..ce074408ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.ir.txt @@ -0,0 +1,47 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (57:2,0 [52] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (57:2,0 [2] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (59:3,0 [7] BasicTagHelpers_Prefixed.cshtml) - Html - + IntermediateToken - (103:3,44 [6] BasicTagHelpers_Prefixed.cshtml) - Html - \n + TagHelper - (109:4,4 [136] BasicTagHelpers_Prefixed.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (135:4,30 [56] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (135:4,30 [10] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (145:5,8 [2] BasicTagHelpers_Prefixed.cshtml) - Html -

        + IntermediateToken - (148:5,11 [4] BasicTagHelpers_Prefixed.cshtml) - Html -

        + IntermediateToken - (152:5,15 [10] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (162:6,8 [6] BasicTagHelpers_Prefixed.cshtml) - Html - + IntermediateToken - (181:6,27 [10] BasicTagHelpers_Prefixed.cshtml) - Html - \n + TagHelper - (191:7,8 [41] BasicTagHelpers_Prefixed.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (207:7,24 [8] BasicTagHelpers_Prefixed.cshtml) - __tagHelperAttribute_0 - type - Type + DefaultTagHelperProperty - (226:7,43 [4] BasicTagHelpers_Prefixed.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (226:7,43 [4] BasicTagHelpers_Prefixed.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (232:7,49 [6] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (232:7,49 [6] BasicTagHelpers_Prefixed.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (245:8,11 [11] BasicTagHelpers_Prefixed.cshtml) + IntermediateToken - (245:8,11 [2] BasicTagHelpers_Prefixed.cshtml) - Html - \n + IntermediateToken - (247:9,0 [9] BasicTagHelpers_Prefixed.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml new file mode 100644 index 0000000000..56ac77231a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml @@ -0,0 +1,10 @@ +@addTagHelper "*, TestAssembly" +@removeTagHelper "doesntmatter, nice" + +
        +

        +

        + + +

        +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..e31a729b2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.codegen.cs @@ -0,0 +1,119 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2e30c5c6e01a148ccf4ed5dd4a81939641312a17" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2e30c5c6e01a148ccf4ed5dd4a81939641312a17", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n
        \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..ef78c52e75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_Runtime.ir.txt @@ -0,0 +1,55 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_RemoveTagHelper_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (72:2,0 [49] BasicTagHelpers_RemoveTagHelper.cshtml) + IntermediateToken - (72:2,0 [2] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + IntermediateToken - (74:3,0 [4] BasicTagHelpers_RemoveTagHelper.cshtml) - Html -
        + IntermediateToken - (115:3,41 [6] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + TagHelper - (121:4,4 [130] BasicTagHelpers_RemoveTagHelper.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (144:4,27 [10] BasicTagHelpers_RemoveTagHelper.cshtml) + IntermediateToken - (144:4,27 [10] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + TagHelper - (154:5,8 [7] BasicTagHelpers_RemoveTagHelper.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperExecute - + HtmlContent - (161:5,15 [10] BasicTagHelpers_RemoveTagHelper.cshtml) + IntermediateToken - (161:5,15 [10] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + TagHelper - (171:6,8 [21] BasicTagHelpers_RemoveTagHelper.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (184:6,21 [4] BasicTagHelpers_RemoveTagHelper.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (184:6,21 [4] BasicTagHelpers_RemoveTagHelper.cshtml) - __tagHelperAttribute_0 - type - Type + DefaultTagHelperExecute - + HtmlContent - (192:6,29 [10] BasicTagHelpers_RemoveTagHelper.cshtml) + IntermediateToken - (192:6,29 [10] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + TagHelper - (202:7,8 [39] BasicTagHelpers_RemoveTagHelper.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (215:7,21 [8] BasicTagHelpers_RemoveTagHelper.cshtml) - __tagHelperAttribute_1 - type - Type + PreallocatedTagHelperProperty - (215:7,21 [8] BasicTagHelpers_RemoveTagHelper.cshtml) - __tagHelperAttribute_1 - type - Type + DefaultTagHelperProperty - (234:7,40 [4] BasicTagHelpers_RemoveTagHelper.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (234:7,40 [4] BasicTagHelpers_RemoveTagHelper.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (241:7,47 [6] BasicTagHelpers_RemoveTagHelper.cshtml) + IntermediateToken - (241:7,47 [6] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (251:8,8 [8] BasicTagHelpers_RemoveTagHelper.cshtml) + IntermediateToken - (251:8,8 [2] BasicTagHelpers_RemoveTagHelper.cshtml) - Html - \n + IntermediateToken - (253:9,0 [6] BasicTagHelpers_RemoveTagHelper.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..48bed63896 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.codegen.cs @@ -0,0 +1,135 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2775a5b97b6aa9fc7b162124fddb7400ec1e2472" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2775a5b97b6aa9fc7b162124fddb7400ec1e2472", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data", new global::Microsoft.AspNetCore.Html.HtmlString("-delay1000"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-delay", new global::Microsoft.AspNetCore.Html.HtmlString("1000"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n
        \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + BeginWriteTagHelperAttribute(); + WriteLiteral("2000 + "); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" + Write(ViewBag.DefaultInterval); + +#line default +#line hidden +#nullable disable + WriteLiteral(" + 1"); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("data-interval", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_2.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_2.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..ce7caef785 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Runtime.ir.txt @@ -0,0 +1,69 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - data - -delay1000 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_2 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_4 - data-delay - 1000 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [71] BasicTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] BasicTagHelpers.cshtml) - Html - \n + IntermediateToken - (35:2,0 [4] BasicTagHelpers.cshtml) - Html -
        + IntermediateToken - (98:2,63 [6] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (104:3,4 [216] BasicTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (145:3,45 [10] BasicTagHelpers.cshtml) + IntermediateToken - (145:3,45 [10] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (155:4,8 [25] BasicTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (180:4,33 [10] BasicTagHelpers.cshtml) + IntermediateToken - (180:4,33 [10] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (190:5,8 [71] BasicTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperHtmlAttribute - - data-interval - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (212:5,30 [7] BasicTagHelpers.cshtml) + IntermediateToken - (212:5,30 [7] BasicTagHelpers.cshtml) - Html - 2000 + + CSharpExpression - (220:5,38 [23] BasicTagHelpers.cshtml) + IntermediateToken - (220:5,38 [23] BasicTagHelpers.cshtml) - CSharp - ViewBag.DefaultInterval + HtmlContent - (243:5,61 [4] BasicTagHelpers.cshtml) + IntermediateToken - (243:5,61 [4] BasicTagHelpers.cshtml) - Html - + 1 + PreallocatedTagHelperProperty - (255:5,73 [4] BasicTagHelpers.cshtml) - __tagHelperAttribute_1 - type - Type + PreallocatedTagHelperProperty - (255:5,73 [4] BasicTagHelpers.cshtml) - __tagHelperAttribute_1 - type - Type + DefaultTagHelperExecute - + HtmlContent - (261:5,79 [10] BasicTagHelpers.cshtml) + IntermediateToken - (261:5,79 [10] BasicTagHelpers.cshtml) - Html - \n + TagHelper - (271:6,8 [39] BasicTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (284:6,21 [8] BasicTagHelpers.cshtml) - __tagHelperAttribute_2 - type - Type + PreallocatedTagHelperProperty - (284:6,21 [8] BasicTagHelpers.cshtml) - __tagHelperAttribute_2 - type - Type + DefaultTagHelperProperty - (303:6,40 [4] BasicTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (303:6,40 [4] BasicTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (310:6,47 [6] BasicTagHelpers.cshtml) + IntermediateToken - (310:6,47 [6] BasicTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_4 + DefaultTagHelperExecute - + HtmlContent - (320:7,8 [8] BasicTagHelpers.cshtml) + IntermediateToken - (320:7,8 [2] BasicTagHelpers.cshtml) - Html - \n + IntermediateToken - (322:8,0 [6] BasicTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml new file mode 100644 index 0000000000..8d27de89cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml @@ -0,0 +1,37 @@ +@{ + int i = 1; +} + +@while(i <= 10) { +

        Hello from C#, #@(i)

        + i += 1; +} + +@if(i == 11) { +

        We wrote 10 lines!

        +} + +@switch(i) { + case 11: +

        No really, we wrote 10 lines!

        + break; + default: +

        Actually, we didn't...

        + break; +} + +@for(int j = 1; j <= 10; j += 2) { +

        Hello again from C#, #@(j)

        +} + +@try { +

        That time, we wrote 5 lines!

        +} catch(Exception ex) { +

        Oh no! An error occurred: @(ex.Message)

        +} + +

        i is now @i

        + +@lock(new object()) { +

        This block is locked, for your security!

        +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.codegen.cs new file mode 100644 index 0000000000..e4fa8fb5e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.codegen.cs @@ -0,0 +1,176 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + + int i = 1; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + while(i <= 10) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + + i += 1; +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + if(i == 11) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + switch(i) { + case 11: + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + + break; + default: + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + + break; +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + for(int j = 1; j <= 10; j += 2) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + __o = j; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + try { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + +} catch(Exception ex) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + __o = ex.Message; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + lock(new object()) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.codegen.html new file mode 100644 index 0000000000..dc08c79219 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.codegen.html @@ -0,0 +1,37 @@ + + + + + +

        Hello from C#, #

        + + + + +

        We wrote 10 lines!

        + + + + +

        No really, we wrote 10 lines!

        + + +

        Actually, we didn't...

        + + + + +

        Hello again from C#, #

        + + + +

        That time, we wrote 5 lines!

        + +

        Oh no! An error occurred:

        + + +

        i is now

        + + +

        This block is locked, for your security!

        + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt new file mode 100644 index 0000000000..d7ad6ccc2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt @@ -0,0 +1,110 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [18] Blocks.cshtml) + IntermediateToken - (2:0,2 [18] Blocks.cshtml) - CSharp - \n int i = 1;\n + HtmlContent - (23:3,0 [2] Blocks.cshtml) + IntermediateToken - (23:3,0 [2] Blocks.cshtml) - Html - \n + CSharpCode - (26:4,1 [22] Blocks.cshtml) + IntermediateToken - (26:4,1 [22] Blocks.cshtml) - CSharp - while(i <= 10) {\n + HtmlContent - (48:5,4 [19] Blocks.cshtml) + IntermediateToken - (48:5,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (51:5,7 [16] Blocks.cshtml) - Html - Hello from C#, # + CSharpExpression - (69:5,25 [1] Blocks.cshtml) + IntermediateToken - (69:5,25 [1] Blocks.cshtml) - CSharp - i + HtmlContent - (71:5,27 [4] Blocks.cshtml) + IntermediateToken - (71:5,27 [4] Blocks.cshtml) - Html -

        + CSharpCode - (75:5,31 [16] Blocks.cshtml) + IntermediateToken - (75:5,31 [16] Blocks.cshtml) - CSharp - \n i += 1;\n} + HtmlContent - (91:7,1 [4] Blocks.cshtml) + IntermediateToken - (91:7,1 [4] Blocks.cshtml) - Html - \n\n + CSharpCode - (96:9,1 [19] Blocks.cshtml) + IntermediateToken - (96:9,1 [19] Blocks.cshtml) - CSharp - if(i == 11) {\n + HtmlContent - (115:10,4 [25] Blocks.cshtml) + IntermediateToken - (115:10,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (118:10,7 [18] Blocks.cshtml) - Html - We wrote 10 lines! + IntermediateToken - (136:10,25 [4] Blocks.cshtml) - Html -

        + CSharpCode - (140:10,29 [3] Blocks.cshtml) + IntermediateToken - (140:10,29 [3] Blocks.cshtml) - CSharp - \n} + HtmlContent - (143:11,1 [4] Blocks.cshtml) + IntermediateToken - (143:11,1 [4] Blocks.cshtml) - Html - \n\n + CSharpCode - (148:13,1 [35] Blocks.cshtml) + IntermediateToken - (148:13,1 [35] Blocks.cshtml) - CSharp - switch(i) {\n case 11:\n + HtmlContent - (183:15,8 [36] Blocks.cshtml) + IntermediateToken - (183:15,8 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (186:15,11 [29] Blocks.cshtml) - Html - No really, we wrote 10 lines! + IntermediateToken - (215:15,40 [4] Blocks.cshtml) - Html -

        + CSharpCode - (219:15,44 [40] Blocks.cshtml) + IntermediateToken - (219:15,44 [40] Blocks.cshtml) - CSharp - \n break;\n default:\n + HtmlContent - (259:18,8 [29] Blocks.cshtml) + IntermediateToken - (259:18,8 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (262:18,11 [22] Blocks.cshtml) - Html - Actually, we didn't... + IntermediateToken - (284:18,33 [4] Blocks.cshtml) - Html -

        + CSharpCode - (288:18,37 [19] Blocks.cshtml) + IntermediateToken - (288:18,37 [19] Blocks.cshtml) - CSharp - \n break;\n} + HtmlContent - (307:20,1 [4] Blocks.cshtml) + IntermediateToken - (307:20,1 [4] Blocks.cshtml) - Html - \n\n + CSharpCode - (312:22,1 [39] Blocks.cshtml) + IntermediateToken - (312:22,1 [39] Blocks.cshtml) - CSharp - for(int j = 1; j <= 10; j += 2) {\n + HtmlContent - (351:23,4 [25] Blocks.cshtml) + IntermediateToken - (351:23,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (354:23,7 [22] Blocks.cshtml) - Html - Hello again from C#, # + CSharpExpression - (378:23,31 [1] Blocks.cshtml) + IntermediateToken - (378:23,31 [1] Blocks.cshtml) - CSharp - j + HtmlContent - (380:23,33 [4] Blocks.cshtml) + IntermediateToken - (380:23,33 [4] Blocks.cshtml) - Html -

        + CSharpCode - (384:23,37 [3] Blocks.cshtml) + IntermediateToken - (384:23,37 [3] Blocks.cshtml) - CSharp - \n} + HtmlContent - (387:24,1 [4] Blocks.cshtml) + IntermediateToken - (387:24,1 [4] Blocks.cshtml) - Html - \n\n + CSharpCode - (392:26,1 [11] Blocks.cshtml) + IntermediateToken - (392:26,1 [11] Blocks.cshtml) - CSharp - try {\n + HtmlContent - (403:27,4 [35] Blocks.cshtml) + IntermediateToken - (403:27,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (406:27,7 [28] Blocks.cshtml) - Html - That time, we wrote 5 lines! + IntermediateToken - (434:27,35 [4] Blocks.cshtml) - Html -

        + CSharpCode - (438:27,39 [31] Blocks.cshtml) + IntermediateToken - (438:27,39 [31] Blocks.cshtml) - CSharp - \n} catch(Exception ex) {\n + HtmlContent - (469:29,4 [29] Blocks.cshtml) + IntermediateToken - (469:29,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (472:29,7 [26] Blocks.cshtml) - Html - Oh no! An error occurred: + CSharpExpression - (500:29,35 [10] Blocks.cshtml) + IntermediateToken - (500:29,35 [10] Blocks.cshtml) - CSharp - ex.Message + HtmlContent - (511:29,46 [4] Blocks.cshtml) + IntermediateToken - (511:29,46 [4] Blocks.cshtml) - Html -

        + CSharpCode - (515:29,50 [3] Blocks.cshtml) + IntermediateToken - (515:29,50 [3] Blocks.cshtml) - CSharp - \n} + HtmlContent - (518:30,1 [16] Blocks.cshtml) + IntermediateToken - (518:30,1 [4] Blocks.cshtml) - Html - \n\n + IntermediateToken - (522:32,0 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (525:32,3 [9] Blocks.cshtml) - Html - i is now + CSharpExpression - (535:32,13 [1] Blocks.cshtml) + IntermediateToken - (535:32,13 [1] Blocks.cshtml) - CSharp - i + HtmlContent - (536:32,14 [8] Blocks.cshtml) + IntermediateToken - (536:32,14 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (540:32,18 [4] Blocks.cshtml) - Html - \n\n + CSharpCode - (545:34,1 [26] Blocks.cshtml) + IntermediateToken - (545:34,1 [26] Blocks.cshtml) - CSharp - lock(new object()) {\n + HtmlContent - (571:35,4 [47] Blocks.cshtml) + IntermediateToken - (571:35,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (574:35,7 [40] Blocks.cshtml) - Html - This block is locked, for your security! + IntermediateToken - (614:35,47 [4] Blocks.cshtml) - Html -

        + CSharpCode - (618:35,51 [3] Blocks.cshtml) + IntermediateToken - (618:35,51 [3] Blocks.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.mappings.txt new file mode 100644 index 0000000000..111f6a27e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.mappings.txt @@ -0,0 +1,139 @@ +Source Location: (2:0,2 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| + int i = 1; +| +Generated Location: (732:19,2 [18] ) +| + int i = 1; +| + +Source Location: (26:4,1 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|while(i <= 10) { + | +Generated Location: (902:27,1 [22] ) +|while(i <= 10) { + | + +Source Location: (69:5,25 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|i| +Generated Location: (1102:35,25 [1] ) +|i| + +Source Location: (75:5,31 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| + i += 1; +}| +Generated Location: (1288:42,31 [16] ) +| + i += 1; +}| + +Source Location: (96:9,1 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|if(i == 11) { + | +Generated Location: (1459:51,1 [19] ) +|if(i == 11) { + | + +Source Location: (140:10,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| +}| +Generated Location: (1661:59,29 [3] ) +| +}| + +Source Location: (148:13,1 [35] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|switch(i) { + case 11: + | +Generated Location: (1819:67,1 [35] ) +|switch(i) { + case 11: + | + +Source Location: (219:15,44 [40] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| + break; + default: + | +Generated Location: (2052:76,44 [40] ) +| + break; + default: + | + +Source Location: (288:18,37 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| + break; +}| +Generated Location: (2283:86,37 [19] ) +| + break; +}| + +Source Location: (312:22,1 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|for(int j = 1; j <= 10; j += 2) { + | +Generated Location: (2457:95,1 [39] ) +|for(int j = 1; j <= 10; j += 2) { + | + +Source Location: (378:23,31 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|j| +Generated Location: (2681:103,31 [1] ) +|j| + +Source Location: (384:23,37 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| +}| +Generated Location: (2874:110,37 [3] ) +| +}| + +Source Location: (392:26,1 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|try { + | +Generated Location: (3032:118,1 [11] ) +|try { + | + +Source Location: (438:27,39 [31] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| +} catch(Exception ex) { + | +Generated Location: (3236:126,39 [31] ) +| +} catch(Exception ex) { + | + +Source Location: (500:29,35 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|ex.Message| +Generated Location: (3456:135,35 [10] ) +|ex.Message| + +Source Location: (515:29,50 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| +}| +Generated Location: (3671:142,50 [3] ) +| +}| + +Source Location: (535:32,13 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|i| +Generated Location: (3841:150,13 [1] ) +|i| + +Source Location: (545:34,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +|lock(new object()) { + | +Generated Location: (3998:157,1 [26] ) +|lock(new object()) { + | + +Source Location: (618:35,51 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml) +| +}| +Generated Location: (4229:165,51 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs new file mode 100644 index 0000000000..ce6adeb982 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.codegen.cs @@ -0,0 +1,174 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ed55fda2b7b0b96b044fc45da658dc062479924f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ed55fda2b7b0b96b044fc45da658dc062479924f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + + int i = 1; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + while(i <= 10) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello from C#, #"); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + i += 1; +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + if(i == 11) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        We wrote 10 lines!

        \r\n"); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + switch(i) { + case 11: + +#line default +#line hidden +#nullable disable + WriteLiteral("

        No really, we wrote 10 lines!

        \r\n"); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + break; + default: + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Actually, we didn\'t...

        \r\n"); +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + break; +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + for(int j = 1; j <= 10; j += 2) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello again from C#, #"); +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + Write(j); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + try { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        That time, we wrote 5 lines!

        \r\n"); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" +} catch(Exception ex) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Oh no! An error occurred: "); +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + Write(ex.Message); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n

        i is now "); +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n\r\n"); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" + lock(new object()) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        This block is locked, for your security!

        \r\n"); +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt new file mode 100644 index 0000000000..36e2a8f3c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_Runtime.ir.txt @@ -0,0 +1,121 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [18] Blocks.cshtml) + IntermediateToken - (2:0,2 [18] Blocks.cshtml) - CSharp - \n int i = 1;\n + HtmlContent - (23:3,0 [2] Blocks.cshtml) + IntermediateToken - (23:3,0 [2] Blocks.cshtml) - Html - \n + CSharpCode - (26:4,1 [18] Blocks.cshtml) + IntermediateToken - (26:4,1 [18] Blocks.cshtml) - CSharp - while(i <= 10) {\n + HtmlContent - (44:5,0 [23] Blocks.cshtml) + IntermediateToken - (44:5,0 [4] Blocks.cshtml) - Html - + IntermediateToken - (48:5,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (51:5,7 [16] Blocks.cshtml) - Html - Hello from C#, # + CSharpExpression - (69:5,25 [1] Blocks.cshtml) + IntermediateToken - (69:5,25 [1] Blocks.cshtml) - CSharp - i + HtmlContent - (71:5,27 [6] Blocks.cshtml) + IntermediateToken - (71:5,27 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (75:5,31 [2] Blocks.cshtml) - Html - \n + CSharpCode - (77:6,0 [16] Blocks.cshtml) + IntermediateToken - (77:6,0 [16] Blocks.cshtml) - CSharp - i += 1;\n}\n + HtmlContent - (93:8,0 [2] Blocks.cshtml) + IntermediateToken - (93:8,0 [2] Blocks.cshtml) - Html - \n + CSharpCode - (96:9,1 [15] Blocks.cshtml) + IntermediateToken - (96:9,1 [15] Blocks.cshtml) - CSharp - if(i == 11) {\n + HtmlContent - (111:10,0 [31] Blocks.cshtml) + IntermediateToken - (111:10,0 [4] Blocks.cshtml) - Html - + IntermediateToken - (115:10,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (118:10,7 [18] Blocks.cshtml) - Html - We wrote 10 lines! + IntermediateToken - (136:10,25 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (140:10,29 [2] Blocks.cshtml) - Html - \n + CSharpCode - (142:11,0 [3] Blocks.cshtml) + IntermediateToken - (142:11,0 [3] Blocks.cshtml) - CSharp - }\n + HtmlContent - (145:12,0 [2] Blocks.cshtml) + IntermediateToken - (145:12,0 [2] Blocks.cshtml) - Html - \n + CSharpCode - (148:13,1 [27] Blocks.cshtml) + IntermediateToken - (148:13,1 [27] Blocks.cshtml) - CSharp - switch(i) {\n case 11:\n + HtmlContent - (175:15,0 [46] Blocks.cshtml) + IntermediateToken - (175:15,0 [8] Blocks.cshtml) - Html - + IntermediateToken - (183:15,8 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (186:15,11 [29] Blocks.cshtml) - Html - No really, we wrote 10 lines! + IntermediateToken - (215:15,40 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (219:15,44 [2] Blocks.cshtml) - Html - \n + CSharpCode - (221:16,0 [30] Blocks.cshtml) + IntermediateToken - (221:16,0 [30] Blocks.cshtml) - CSharp - break;\n default:\n + HtmlContent - (251:18,0 [39] Blocks.cshtml) + IntermediateToken - (251:18,0 [8] Blocks.cshtml) - Html - + IntermediateToken - (259:18,8 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (262:18,11 [22] Blocks.cshtml) - Html - Actually, we didn't... + IntermediateToken - (284:18,33 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (288:18,37 [2] Blocks.cshtml) - Html - \n + CSharpCode - (290:19,0 [19] Blocks.cshtml) + IntermediateToken - (290:19,0 [19] Blocks.cshtml) - CSharp - break;\n}\n + HtmlContent - (309:21,0 [2] Blocks.cshtml) + IntermediateToken - (309:21,0 [2] Blocks.cshtml) - Html - \n + CSharpCode - (312:22,1 [35] Blocks.cshtml) + IntermediateToken - (312:22,1 [35] Blocks.cshtml) - CSharp - for(int j = 1; j <= 10; j += 2) {\n + HtmlContent - (347:23,0 [29] Blocks.cshtml) + IntermediateToken - (347:23,0 [4] Blocks.cshtml) - Html - + IntermediateToken - (351:23,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (354:23,7 [22] Blocks.cshtml) - Html - Hello again from C#, # + CSharpExpression - (378:23,31 [1] Blocks.cshtml) + IntermediateToken - (378:23,31 [1] Blocks.cshtml) - CSharp - j + HtmlContent - (380:23,33 [6] Blocks.cshtml) + IntermediateToken - (380:23,33 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (384:23,37 [2] Blocks.cshtml) - Html - \n + CSharpCode - (386:24,0 [3] Blocks.cshtml) + IntermediateToken - (386:24,0 [3] Blocks.cshtml) - CSharp - }\n + HtmlContent - (389:25,0 [2] Blocks.cshtml) + IntermediateToken - (389:25,0 [2] Blocks.cshtml) - Html - \n + CSharpCode - (392:26,1 [7] Blocks.cshtml) + IntermediateToken - (392:26,1 [7] Blocks.cshtml) - CSharp - try {\n + HtmlContent - (399:27,0 [41] Blocks.cshtml) + IntermediateToken - (399:27,0 [4] Blocks.cshtml) - Html - + IntermediateToken - (403:27,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (406:27,7 [28] Blocks.cshtml) - Html - That time, we wrote 5 lines! + IntermediateToken - (434:27,35 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (438:27,39 [2] Blocks.cshtml) - Html - \n + CSharpCode - (440:28,0 [25] Blocks.cshtml) + IntermediateToken - (440:28,0 [25] Blocks.cshtml) - CSharp - } catch(Exception ex) {\n + HtmlContent - (465:29,0 [33] Blocks.cshtml) + IntermediateToken - (465:29,0 [4] Blocks.cshtml) - Html - + IntermediateToken - (469:29,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (472:29,7 [26] Blocks.cshtml) - Html - Oh no! An error occurred: + CSharpExpression - (500:29,35 [10] Blocks.cshtml) + IntermediateToken - (500:29,35 [10] Blocks.cshtml) - CSharp - ex.Message + HtmlContent - (511:29,46 [6] Blocks.cshtml) + IntermediateToken - (511:29,46 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (515:29,50 [2] Blocks.cshtml) - Html - \n + CSharpCode - (517:30,0 [3] Blocks.cshtml) + IntermediateToken - (517:30,0 [3] Blocks.cshtml) - CSharp - }\n + HtmlContent - (520:31,0 [14] Blocks.cshtml) + IntermediateToken - (520:31,0 [2] Blocks.cshtml) - Html - \n + IntermediateToken - (522:32,0 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (525:32,3 [9] Blocks.cshtml) - Html - i is now + CSharpExpression - (535:32,13 [1] Blocks.cshtml) + IntermediateToken - (535:32,13 [1] Blocks.cshtml) - CSharp - i + HtmlContent - (536:32,14 [8] Blocks.cshtml) + IntermediateToken - (536:32,14 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (540:32,18 [4] Blocks.cshtml) - Html - \n\n + CSharpCode - (545:34,1 [22] Blocks.cshtml) + IntermediateToken - (545:34,1 [22] Blocks.cshtml) - CSharp - lock(new object()) {\n + HtmlContent - (567:35,0 [53] Blocks.cshtml) + IntermediateToken - (567:35,0 [4] Blocks.cshtml) - Html - + IntermediateToken - (571:35,4 [2] Blocks.cshtml) - Html -

        + IntermediateToken - (574:35,7 [40] Blocks.cshtml) - Html - This block is locked, for your security! + IntermediateToken - (614:35,47 [4] Blocks.cshtml) - Html -

        + IntermediateToken - (618:35,51 [2] Blocks.cshtml) - Html - \n + CSharpCode - (620:36,0 [1] Blocks.cshtml) + IntermediateToken - (620:36,0 [1] Blocks.cshtml) - CSharp - } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml new file mode 100644 index 0000000000..e2c134767e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml @@ -0,0 +1,43 @@ + + @{ + var nameLookup = new Dictionary() + { + ["John Doe"] = ("John", "Doe", true) + }; + + @* This is all C# 7 bits that should work. *@ + + int Sixteen = 0b0001_0000; + long BillionsAndBillions = 100_000_000_000; + double AvogadroConstant = 6.022_140_857_747_474e23; + decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M; + } + + @if (nameLookup.TryGetValue("John Doe", out var entry)) + { + if (entry.Extra is bool alive) + { + // Do Something + } + } +

        + Here's a very unique number: @(1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M) +

        + +
        + @((First: "John", Last: "Doe").First) @* Value Tuples *@ +
        + + @switch (entry.Extra) + { + case int age: + // Do something + break; + case IEnumerable childrenNames: + // Do more something + break; + case null: + // Do even more of something + break; + } + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.codegen.cs new file mode 100644 index 0000000000..d72f3f599f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.codegen.cs @@ -0,0 +1,93 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + + var nameLookup = new Dictionary() + { + ["John Doe"] = ("John", "Doe", true) + }; + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + + + int Sixteen = 0b0001_0000; + long BillionsAndBillions = 100_000_000_000; + double AvogadroConstant = 6.022_140_857_747_474e23; + decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + if (nameLookup.TryGetValue("John Doe", out var entry)) + { + if (entry.Extra is bool alive) + { + // Do Something + } + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + __o = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + __o = (First: "John", Last: "Doe").First; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + switch (entry.Extra) + { + case int age: + // Do something + break; + case IEnumerable childrenNames: + // Do more something + break; + case null: + // Do even more of something + break; + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.codegen.html new file mode 100644 index 0000000000..a2aad32abe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.codegen.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + +

        + Here's a very unique number: +

        + +
        + +
        + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt new file mode 100644 index 0000000000..88f3ed74c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt @@ -0,0 +1,50 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [12] CSharp7.cshtml) + IntermediateToken - (0:0,0 [5] CSharp7.cshtml) - Html - + IntermediateToken - (6:0,6 [6] CSharp7.cshtml) - Html - \n + CSharpCode - (14:1,6 [187] CSharp7.cshtml) + IntermediateToken - (14:1,6 [187] CSharp7.cshtml) - CSharp - \n var nameLookup = new Dictionary()\n {\n ["John Doe"] = ("John", "Doe", true)\n };\n\n + CSharpCode - (246:7,53 [253] CSharp7.cshtml) + IntermediateToken - (246:7,53 [253] CSharp7.cshtml) - CSharp - \n\n int Sixteen = 0b0001_0000;\n long BillionsAndBillions = 100_000_000_000;\n double AvogadroConstant = 6.022_140_857_747_474e23;\n decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M;\n + HtmlContent - (502:14,0 [6] CSharp7.cshtml) + IntermediateToken - (502:14,0 [6] CSharp7.cshtml) - Html - \n + CSharpCode - (509:15,5 [159] CSharp7.cshtml) + IntermediateToken - (509:15,5 [159] CSharp7.cshtml) - CSharp - if (nameLookup.TryGetValue("John Doe", out var entry))\n {\n if (entry.Extra is bool alive)\n {\n // Do Something\n }\n } + HtmlContent - (668:21,5 [48] CSharp7.cshtml) + IntermediateToken - (668:21,5 [6] CSharp7.cshtml) - Html - \n + IntermediateToken - (674:22,4 [2] CSharp7.cshtml) - Html -

        + IntermediateToken - (677:22,7 [39] CSharp7.cshtml) - Html - \n Here's a very unique number: + CSharpExpression - (718:23,39 [62] CSharp7.cshtml) + IntermediateToken - (718:23,39 [62] CSharp7.cshtml) - CSharp - 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M + HtmlContent - (781:23,102 [33] CSharp7.cshtml) + IntermediateToken - (781:23,102 [6] CSharp7.cshtml) - Html - \n + IntermediateToken - (787:24,4 [4] CSharp7.cshtml) - Html -

        + IntermediateToken - (791:24,8 [8] CSharp7.cshtml) - Html - \n\n + IntermediateToken - (799:26,4 [4] CSharp7.cshtml) - Html -
        + IntermediateToken - (804:26,9 [10] CSharp7.cshtml) - Html - \n + CSharpExpression - (816:27,10 [34] CSharp7.cshtml) + IntermediateToken - (816:27,10 [34] CSharp7.cshtml) - CSharp - (First: "John", Last: "Doe").First + HtmlContent - (851:27,45 [1] CSharp7.cshtml) + IntermediateToken - (851:27,45 [1] CSharp7.cshtml) - Html - + HtmlContent - (870:27,64 [20] CSharp7.cshtml) + IntermediateToken - (870:27,64 [6] CSharp7.cshtml) - Html - \n + IntermediateToken - (876:28,4 [6] CSharp7.cshtml) - Html -
        + IntermediateToken - (882:28,10 [8] CSharp7.cshtml) - Html - \n\n + CSharpCode - (891:30,5 [291] CSharp7.cshtml) + IntermediateToken - (891:30,5 [291] CSharp7.cshtml) - CSharp - switch (entry.Extra)\n {\n case int age:\n // Do something\n break;\n case IEnumerable childrenNames:\n // Do more something\n break;\n case null:\n // Do even more of something\n break;\n } + HtmlContent - (1182:41,5 [9] CSharp7.cshtml) + IntermediateToken - (1182:41,5 [2] CSharp7.cshtml) - Html - \n + IntermediateToken - (1184:42,0 [7] CSharp7.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.mappings.txt new file mode 100644 index 0000000000..ad00d2d80d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.mappings.txt @@ -0,0 +1,88 @@ +Source Location: (14:1,6 [187] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml) +| + var nameLookup = new Dictionary() + { + ["John Doe"] = ("John", "Doe", true) + }; + + | +Generated Location: (738:19,6 [187] ) +| + var nameLookup = new Dictionary() + { + ["John Doe"] = ("John", "Doe", true) + }; + + | + +Source Location: (246:7,53 [253] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml) +| + + int Sixteen = 0b0001_0000; + long BillionsAndBillions = 100_000_000_000; + double AvogadroConstant = 6.022_140_857_747_474e23; + decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M; + | +Generated Location: (1132:32,53 [253] ) +| + + int Sixteen = 0b0001_0000; + long BillionsAndBillions = 100_000_000_000; + double AvogadroConstant = 6.022_140_857_747_474e23; + decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M; + | + +Source Location: (509:15,5 [159] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml) +|if (nameLookup.TryGetValue("John Doe", out var entry)) + { + if (entry.Extra is bool alive) + { + // Do Something + } + }| +Generated Location: (1545:45,5 [159] ) +|if (nameLookup.TryGetValue("John Doe", out var entry)) + { + if (entry.Extra is bool alive) + { + // Do Something + } + }| + +Source Location: (718:23,39 [62] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml) +|1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M| +Generated Location: (1898:58,39 [62] ) +|1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M| + +Source Location: (816:27,10 [34] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml) +|(First: "John", Last: "Doe").First| +Generated Location: (2126:65,10 [34] ) +|(First: "John", Last: "Doe").First| + +Source Location: (891:30,5 [291] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml) +|switch (entry.Extra) + { + case int age: + // Do something + break; + case IEnumerable childrenNames: + // Do more something + break; + case null: + // Do even more of something + break; + }| +Generated Location: (2321:72,5 [291] ) +|switch (entry.Extra) + { + case int age: + // Do something + break; + case IEnumerable childrenNames: + // Do more something + break; + case null: + // Do even more of something + break; + }| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs new file mode 100644 index 0000000000..cf2fd1a3bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.codegen.cs @@ -0,0 +1,96 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "69466b91f73ea9f94ccef045495a0da11bb763c6" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"69466b91f73ea9f94ccef045495a0da11bb763c6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + + var nameLookup = new Dictionary() + { + ["John Doe"] = ("John", "Doe", true) + }; + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + + + int Sixteen = 0b0001_0000; + long BillionsAndBillions = 100_000_000_000; + double AvogadroConstant = 6.022_140_857_747_474e23; + decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M; + + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + if (nameLookup.TryGetValue("John Doe", out var entry)) + { + if (entry.Extra is bool alive) + { + // Do Something + } + } + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n Here\'s a very unique number: "); +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + Write(1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n

        \r\n\r\n
        \r\n "); +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + Write((First: "John", Last: "Doe").First); + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + WriteLiteral("\r\n
        \r\n\r\n"); +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7.cshtml" + switch (entry.Extra) + { + case int age: + // Do something + break; + case IEnumerable childrenNames: + // Do more something + break; + case null: + // Do even more of something + break; + } + +#line default +#line hidden +#nullable disable + WriteLiteral(""); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt new file mode 100644 index 0000000000..b6cb7face8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_Runtime.ir.txt @@ -0,0 +1,51 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [8] CSharp7.cshtml) + IntermediateToken - (0:0,0 [5] CSharp7.cshtml) - Html - + IntermediateToken - (6:0,6 [2] CSharp7.cshtml) - Html - \n + CSharpCode - (8:1,0 [4] CSharp7.cshtml) + IntermediateToken - (8:1,0 [4] CSharp7.cshtml) - CSharp - + CSharpCode - (14:1,6 [187] CSharp7.cshtml) + IntermediateToken - (14:1,6 [187] CSharp7.cshtml) - CSharp - \n var nameLookup = new Dictionary()\n {\n ["John Doe"] = ("John", "Doe", true)\n };\n\n + CSharpCode - (246:7,53 [253] CSharp7.cshtml) + IntermediateToken - (246:7,53 [253] CSharp7.cshtml) - CSharp - \n\n int Sixteen = 0b0001_0000;\n long BillionsAndBillions = 100_000_000_000;\n double AvogadroConstant = 6.022_140_857_747_474e23;\n decimal GoldenRatio = 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M;\n + HtmlContent - (502:14,0 [2] CSharp7.cshtml) + IntermediateToken - (502:14,0 [2] CSharp7.cshtml) - Html - \n + CSharpCode - (504:15,0 [4] CSharp7.cshtml) + IntermediateToken - (504:15,0 [4] CSharp7.cshtml) - CSharp - + CSharpCode - (509:15,5 [161] CSharp7.cshtml) + IntermediateToken - (509:15,5 [161] CSharp7.cshtml) - CSharp - if (nameLookup.TryGetValue("John Doe", out var entry))\n {\n if (entry.Extra is bool alive)\n {\n // Do Something\n }\n }\n + HtmlContent - (670:22,0 [46] CSharp7.cshtml) + IntermediateToken - (670:22,0 [4] CSharp7.cshtml) - Html - + IntermediateToken - (674:22,4 [2] CSharp7.cshtml) - Html -

        + IntermediateToken - (677:22,7 [39] CSharp7.cshtml) - Html - \n Here's a very unique number: + CSharpExpression - (718:23,39 [62] CSharp7.cshtml) + IntermediateToken - (718:23,39 [62] CSharp7.cshtml) - CSharp - 1.618_033_988_749_894_848_204_586_834_365_638_117_720_309_179M + HtmlContent - (781:23,102 [33] CSharp7.cshtml) + IntermediateToken - (781:23,102 [6] CSharp7.cshtml) - Html - \n + IntermediateToken - (787:24,4 [4] CSharp7.cshtml) - Html -

        + IntermediateToken - (791:24,8 [8] CSharp7.cshtml) - Html - \n\n + IntermediateToken - (799:26,4 [4] CSharp7.cshtml) - Html -
        + IntermediateToken - (804:26,9 [2] CSharp7.cshtml) - Html - \n + IntermediateToken - (806:27,0 [8] CSharp7.cshtml) - Html - + CSharpExpression - (816:27,10 [34] CSharp7.cshtml) + IntermediateToken - (816:27,10 [34] CSharp7.cshtml) - CSharp - (First: "John", Last: "Doe").First + HtmlContent - (851:27,45 [1] CSharp7.cshtml) + IntermediateToken - (851:27,45 [1] CSharp7.cshtml) - Html - + HtmlContent - (870:27,64 [16] CSharp7.cshtml) + IntermediateToken - (870:27,64 [6] CSharp7.cshtml) - Html - \n + IntermediateToken - (876:28,4 [6] CSharp7.cshtml) - Html -
        + IntermediateToken - (882:28,10 [4] CSharp7.cshtml) - Html - \n\n + CSharpCode - (886:30,0 [4] CSharp7.cshtml) + IntermediateToken - (886:30,0 [4] CSharp7.cshtml) - CSharp - + CSharpCode - (891:30,5 [293] CSharp7.cshtml) + IntermediateToken - (891:30,5 [293] CSharp7.cshtml) - CSharp - switch (entry.Extra)\n {\n case int age:\n // Do something\n break;\n case IEnumerable childrenNames:\n // Do more something\n break;\n case null:\n // Do even more of something\n break;\n }\n + HtmlContent - (1184:42,0 [7] CSharp7.cshtml) + IntermediateToken - (1184:42,0 [7] CSharp7.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml new file mode 100644 index 0000000000..83b95d4458 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml @@ -0,0 +1,67 @@ +@using System.Collections.Generic + +@{ + IAsyncEnumerable GetAsyncEnumerable() + { + return null; + } + + await foreach (var val in GetAsyncEnumerable()) + { + + } + + Range range = 1..5; + using var disposable = GetLastDisposableInRange(range); + + var words = Array.Empty(); + var testEnum = GetEnum(); + static TestEnum GetEnum() + { + return TestEnum.First; + } +} + +@words[1..2] +@(words[^2..^0]) + +@(testEnum switch +{ + TestEnum.First => "The First!", + TestEnum.Second => "The Second!", + _ => "The others", +}) + +@await foreach (var val in GetAsyncEnumerable()) +{ + @val +} + +@Person!.Name +@People![0]!.Name![1] +@DoSomething!(Person!) + +@functions { + enum TestEnum + { + First, + Second + } + + IDisposable GetLastDisposableInRange(Range range) + { + var disposables = (IDisposable[])ViewData["disposables"]; + return disposables[range][^1]; + } + + private Human? Person { get; set; } + + private Human?[]? People { get; set; } + + private Func? DoSomething { get; set; } + + private class Human + { + public string? Name { get; set; } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.codegen.cs new file mode 100644 index 0000000000..1059516778 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.codegen.cs @@ -0,0 +1,155 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +using System.Collections.Generic; + +#line default +#line hidden +#nullable disable + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp8_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + + IAsyncEnumerable GetAsyncEnumerable() + { + return null; + } + + await foreach (var val in GetAsyncEnumerable()) + { + + } + + Range range = 1..5; + using var disposable = GetLastDisposableInRange(range); + + var words = Array.Empty(); + var testEnum = GetEnum(); + static TestEnum GetEnum() + { + return TestEnum.First; + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = words[1..2]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = words[^2..^0]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = testEnum switch +{ + TestEnum.First => "The First!", + TestEnum.Second => "The Second!", + _ => "The others", +}; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + await foreach (var val in GetAsyncEnumerable()) +{ + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = val; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 40 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = Person!.Name; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 41 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = People![0]!.Name![1]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 42 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +__o = DoSomething!(Person!); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 44 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + + enum TestEnum + { + First, + Second + } + + IDisposable GetLastDisposableInRange(Range range) + { + var disposables = (IDisposable[])ViewData["disposables"]; + return disposables[range][^1]; + } + + private Human? Person { get; set; } + + private Human?[]? People { get; set; } + + private Func? DoSomething { get; set; } + + private class Human + { + public string? Name { get; set; } + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.codegen.html new file mode 100644 index 0000000000..2e0ee4dc6e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.codegen.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.ir.txt new file mode 100644 index 0000000000..e91175b961 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.ir.txt @@ -0,0 +1,52 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + UsingDirective - (1:0,1 [32] CSharp8.cshtml) - System.Collections.Generic + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp8_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:0,33 [4] CSharp8.cshtml) + IntermediateToken - (33:0,33 [4] CSharp8.cshtml) - Html - \n\n + CSharpCode - (39:2,2 [396] CSharp8.cshtml) + IntermediateToken - (39:2,2 [396] CSharp8.cshtml) - CSharp - \n IAsyncEnumerable GetAsyncEnumerable()\n {\n return null;\n }\n\n await foreach (var val in GetAsyncEnumerable())\n {\n\n }\n\n Range range = 1..5;\n using var disposable = GetLastDisposableInRange(range);\n\n var words = Array.Empty();\n var testEnum = GetEnum();\n static TestEnum GetEnum()\n {\n return TestEnum.First;\n }\n + HtmlContent - (438:23,0 [2] CSharp8.cshtml) + IntermediateToken - (438:23,0 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (441:24,1 [11] CSharp8.cshtml) + IntermediateToken - (441:24,1 [11] CSharp8.cshtml) - CSharp - words[1..2] + HtmlContent - (452:24,12 [2] CSharp8.cshtml) + IntermediateToken - (452:24,12 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (456:25,2 [13] CSharp8.cshtml) + IntermediateToken - (456:25,2 [13] CSharp8.cshtml) - CSharp - words[^2..^0] + HtmlContent - (470:25,16 [4] CSharp8.cshtml) + IntermediateToken - (470:25,16 [4] CSharp8.cshtml) - Html - \n\n + CSharpExpression - (476:27,2 [121] CSharp8.cshtml) + IntermediateToken - (476:27,2 [121] CSharp8.cshtml) - CSharp - testEnum switch\n{\n TestEnum.First => "The First!",\n TestEnum.Second => "The Second!",\n _ => "The others",\n} + HtmlContent - (598:32,2 [4] CSharp8.cshtml) + IntermediateToken - (598:32,2 [4] CSharp8.cshtml) - Html - \n\n + CSharpCode - (603:34,1 [56] CSharp8.cshtml) + IntermediateToken - (603:34,1 [56] CSharp8.cshtml) - CSharp - await foreach (var val in GetAsyncEnumerable())\n{\n + CSharpExpression - (660:36,5 [3] CSharp8.cshtml) + IntermediateToken - (660:36,5 [3] CSharp8.cshtml) - CSharp - val + CSharpCode - (663:36,8 [3] CSharp8.cshtml) + IntermediateToken - (663:36,8 [3] CSharp8.cshtml) - CSharp - \n} + HtmlContent - (666:37,1 [4] CSharp8.cshtml) + IntermediateToken - (666:37,1 [4] CSharp8.cshtml) - Html - \n\n + CSharpExpression - (671:39,1 [12] CSharp8.cshtml) + IntermediateToken - (671:39,1 [12] CSharp8.cshtml) - CSharp - Person!.Name + HtmlContent - (683:39,13 [2] CSharp8.cshtml) + IntermediateToken - (683:39,13 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (686:40,1 [20] CSharp8.cshtml) + IntermediateToken - (686:40,1 [20] CSharp8.cshtml) - CSharp - People![0]!.Name![1] + HtmlContent - (706:40,21 [2] CSharp8.cshtml) + IntermediateToken - (706:40,21 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (709:41,1 [21] CSharp8.cshtml) + IntermediateToken - (709:41,1 [21] CSharp8.cshtml) - CSharp - DoSomething!(Person!) + HtmlContent - (730:41,22 [4] CSharp8.cshtml) + IntermediateToken - (730:41,22 [4] CSharp8.cshtml) - Html - \n\n + CSharpCode - (746:43,12 [480] CSharp8.cshtml) + IntermediateToken - (746:43,12 [480] CSharp8.cshtml) - CSharp - \n enum TestEnum\n {\n First,\n Second\n }\n\n IDisposable GetLastDisposableInRange(Range range)\n {\n var disposables = (IDisposable[])ViewData["disposables"];\n return disposables[range][^1];\n }\n\n private Human? Person { get; set; }\n\n private Human?[]? People { get; set; }\n\n private Func? DoSomething { get; set; }\n\n private class Human\n {\n public string? Name { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.mappings.txt new file mode 100644 index 0000000000..a573b6fdbb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_DesignTime.mappings.txt @@ -0,0 +1,162 @@ +Source Location: (1:0,1 [32] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|using System.Collections.Generic| +Generated Location: (249:7,0 [32] ) +|using System.Collections.Generic| + +Source Location: (39:2,2 [396] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +| + IAsyncEnumerable GetAsyncEnumerable() + { + return null; + } + + await foreach (var val in GetAsyncEnumerable()) + { + + } + + Range range = 1..5; + using var disposable = GetLastDisposableInRange(range); + + var words = Array.Empty(); + var testEnum = GetEnum(); + static TestEnum GetEnum() + { + return TestEnum.First; + } +| +Generated Location: (921:26,2 [396] ) +| + IAsyncEnumerable GetAsyncEnumerable() + { + return null; + } + + await foreach (var val in GetAsyncEnumerable()) + { + + } + + Range range = 1..5; + using var disposable = GetLastDisposableInRange(range); + + var words = Array.Empty(); + var testEnum = GetEnum(); + static TestEnum GetEnum() + { + return TestEnum.First; + } +| + +Source Location: (441:24,1 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|words[1..2]| +Generated Location: (1476:52,6 [11] ) +|words[1..2]| + +Source Location: (456:25,2 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|words[^2..^0]| +Generated Location: (1649:59,6 [13] ) +|words[^2..^0]| + +Source Location: (476:27,2 [121] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|testEnum switch +{ + TestEnum.First => "The First!", + TestEnum.Second => "The Second!", + _ => "The others", +}| +Generated Location: (1824:66,6 [121] ) +|testEnum switch +{ + TestEnum.First => "The First!", + TestEnum.Second => "The Second!", + _ => "The others", +}| + +Source Location: (603:34,1 [56] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|await foreach (var val in GetAsyncEnumerable()) +{ + | +Generated Location: (2102:78,1 [56] ) +|await foreach (var val in GetAsyncEnumerable()) +{ + | + +Source Location: (660:36,5 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|val| +Generated Location: (2319:87,6 [3] ) +|val| + +Source Location: (663:36,8 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +| +}| +Generated Location: (2486:94,8 [3] ) +| +}| + +Source Location: (671:39,1 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|Person!.Name| +Generated Location: (2650:102,6 [12] ) +|Person!.Name| + +Source Location: (686:40,1 [20] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|People![0]!.Name![1]| +Generated Location: (2824:109,6 [20] ) +|People![0]!.Name![1]| + +Source Location: (709:41,1 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +|DoSomething!(Person!)| +Generated Location: (3006:116,6 [21] ) +|DoSomething!(Person!)| + +Source Location: (746:43,12 [480] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml) +| + enum TestEnum + { + First, + Second + } + + IDisposable GetLastDisposableInRange(Range range) + { + var disposables = (IDisposable[])ViewData["disposables"]; + return disposables[range][^1]; + } + + private Human? Person { get; set; } + + private Human?[]? People { get; set; } + + private Func? DoSomething { get; set; } + + private class Human + { + public string? Name { get; set; } + } +| +Generated Location: (3244:125,12 [480] ) +| + enum TestEnum + { + First, + Second + } + + IDisposable GetLastDisposableInRange(Range range) + { + var disposables = (IDisposable[])ViewData["disposables"]; + return disposables[range][^1]; + } + + private Human? Person { get; set; } + + private Human?[]? People { get; set; } + + private Func? DoSomething { get; set; } + + private class Human + { + public string? Name { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_Runtime.codegen.cs new file mode 100644 index 0000000000..d535be6fbe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_Runtime.codegen.cs @@ -0,0 +1,160 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f830678e508a850354b4240a5821a1d75347fa64" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp8_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +using System.Collections.Generic; + +#line default +#line hidden +#nullable disable + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f830678e508a850354b4240a5821a1d75347fa64", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp8_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + + IAsyncEnumerable GetAsyncEnumerable() + { + return null; + } + + await foreach (var val in GetAsyncEnumerable()) + { + + } + + Range range = 1..5; + using var disposable = GetLastDisposableInRange(range); + + var words = Array.Empty(); + var testEnum = GetEnum(); + static TestEnum GetEnum() + { + return TestEnum.First; + } + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(words[1..2]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(words[^2..^0]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n\r\n"); +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(testEnum switch +{ + TestEnum.First => "The First!", + TestEnum.Second => "The Second!", + _ => "The others", +}); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n\r\n"); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + await foreach (var val in GetAsyncEnumerable()) +{ + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(val); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 40 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(Person!.Name); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 41 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(People![0]!.Name![1]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 42 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" +Write(DoSomething!(Person!)); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 44 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8.cshtml" + + enum TestEnum + { + First, + Second + } + + IDisposable GetLastDisposableInRange(Range range) + { + var disposables = (IDisposable[])ViewData["disposables"]; + return disposables[range][^1]; + } + + private Human? Person { get; set; } + + private Human?[]? People { get; set; } + + private Func? DoSomething { get; set; } + + private class Human + { + public string? Name { get; set; } + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_Runtime.ir.txt new file mode 100644 index 0000000000..db92e0b6bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp8_Runtime.ir.txt @@ -0,0 +1,47 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + UsingDirective - (1:0,1 [34] CSharp8.cshtml) - System.Collections.Generic + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp8_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (35:1,0 [2] CSharp8.cshtml) + IntermediateToken - (35:1,0 [2] CSharp8.cshtml) - Html - \n + CSharpCode - (39:2,2 [396] CSharp8.cshtml) + IntermediateToken - (39:2,2 [396] CSharp8.cshtml) - CSharp - \n IAsyncEnumerable GetAsyncEnumerable()\n {\n return null;\n }\n\n await foreach (var val in GetAsyncEnumerable())\n {\n\n }\n\n Range range = 1..5;\n using var disposable = GetLastDisposableInRange(range);\n\n var words = Array.Empty();\n var testEnum = GetEnum();\n static TestEnum GetEnum()\n {\n return TestEnum.First;\n }\n + HtmlContent - (438:23,0 [2] CSharp8.cshtml) + IntermediateToken - (438:23,0 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (441:24,1 [11] CSharp8.cshtml) + IntermediateToken - (441:24,1 [11] CSharp8.cshtml) - CSharp - words[1..2] + HtmlContent - (452:24,12 [2] CSharp8.cshtml) + IntermediateToken - (452:24,12 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (456:25,2 [13] CSharp8.cshtml) + IntermediateToken - (456:25,2 [13] CSharp8.cshtml) - CSharp - words[^2..^0] + HtmlContent - (470:25,16 [4] CSharp8.cshtml) + IntermediateToken - (470:25,16 [4] CSharp8.cshtml) - Html - \n\n + CSharpExpression - (476:27,2 [121] CSharp8.cshtml) + IntermediateToken - (476:27,2 [121] CSharp8.cshtml) - CSharp - testEnum switch\n{\n TestEnum.First => "The First!",\n TestEnum.Second => "The Second!",\n _ => "The others",\n} + HtmlContent - (598:32,2 [4] CSharp8.cshtml) + IntermediateToken - (598:32,2 [4] CSharp8.cshtml) - Html - \n\n + CSharpCode - (603:34,1 [56] CSharp8.cshtml) + IntermediateToken - (603:34,1 [56] CSharp8.cshtml) - CSharp - await foreach (var val in GetAsyncEnumerable())\n{\n + CSharpExpression - (660:36,5 [3] CSharp8.cshtml) + IntermediateToken - (660:36,5 [3] CSharp8.cshtml) - CSharp - val + CSharpCode - (663:36,8 [5] CSharp8.cshtml) + IntermediateToken - (663:36,8 [5] CSharp8.cshtml) - CSharp - \n}\n + HtmlContent - (668:38,0 [2] CSharp8.cshtml) + IntermediateToken - (668:38,0 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (671:39,1 [12] CSharp8.cshtml) + IntermediateToken - (671:39,1 [12] CSharp8.cshtml) - CSharp - Person!.Name + HtmlContent - (683:39,13 [2] CSharp8.cshtml) + IntermediateToken - (683:39,13 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (686:40,1 [20] CSharp8.cshtml) + IntermediateToken - (686:40,1 [20] CSharp8.cshtml) - CSharp - People![0]!.Name![1] + HtmlContent - (706:40,21 [2] CSharp8.cshtml) + IntermediateToken - (706:40,21 [2] CSharp8.cshtml) - Html - \n + CSharpExpression - (709:41,1 [21] CSharp8.cshtml) + IntermediateToken - (709:41,1 [21] CSharp8.cshtml) - CSharp - DoSomething!(Person!) + HtmlContent - (730:41,22 [4] CSharp8.cshtml) + IntermediateToken - (730:41,22 [4] CSharp8.cshtml) - Html - \n\n + CSharpCode - (746:43,12 [480] CSharp8.cshtml) + IntermediateToken - (746:43,12 [480] CSharp8.cshtml) - CSharp - \n enum TestEnum\n {\n First,\n Second\n }\n\n IDisposable GetLastDisposableInRange(Range range)\n {\n var disposables = (IDisposable[])ViewData["disposables"];\n return disposables[range][^1];\n }\n\n private Human? Person { get; set; }\n\n private Human?[]? People { get; set; }\n\n private Func? DoSomething { get; set; }\n\n private class Human\n {\n public string? Name { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml new file mode 100644 index 0000000000..1c78883a10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml @@ -0,0 +1,5 @@ +@{ + for(int i = 1; i <= 10; i++) { + Output.Write("

        Hello from C#, #" + i.ToString() + "

        "); + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml new file mode 100644 index 0000000000..38417d481c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml @@ -0,0 +1 @@ +@{ \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs new file mode 100644 index 0000000000..3c1f46fb0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.html new file mode 100644 index 0000000000..136d06384a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.codegen.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..c3072c6248 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt new file mode 100644 index 0000000000..764d204441 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [0] CodeBlockAtEOF.cshtml) + IntermediateToken - (2:0,2 [0] CodeBlockAtEOF.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt new file mode 100644 index 0000000000..8500fe260a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (2:0,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml) +|| +Generated Location: (748:19,2 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs new file mode 100644 index 0000000000..95ce16e337 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.codegen.cs @@ -0,0 +1,18 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b4fbc3b07404cc5be74ae0ba920a16e9cf39a378" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b4fbc3b07404cc5be74ae0ba920a16e9cf39a378", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt new file mode 100644 index 0000000000..c3072c6248 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt new file mode 100644 index 0000000000..daf2692204 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.ir.txt @@ -0,0 +1,8 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [0] CodeBlockAtEOF.cshtml) + IntermediateToken - (2:0,2 [0] CodeBlockAtEOF.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml new file mode 100644 index 0000000000..9c34a940eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml @@ -0,0 +1,4 @@ +@{ + var a = 1; foo + var b = 1; bar @(a+b) +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs new file mode 100644 index 0000000000..b887486ba1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + + var a = 1; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + + var b = 1; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + __o = a+b; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.html new file mode 100644 index 0000000000..a6e01f1a0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.codegen.html @@ -0,0 +1,4 @@ + + foo + bar + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt new file mode 100644 index 0000000000..8a220afc95 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [17] CodeBlockWithTextElement.cshtml) + IntermediateToken - (2:0,2 [17] CodeBlockWithTextElement.cshtml) - CSharp - \n var a = 1; + HtmlContent - (25:1,21 [3] CodeBlockWithTextElement.cshtml) + IntermediateToken - (25:1,21 [3] CodeBlockWithTextElement.cshtml) - Html - foo + CSharpCode - (35:1,31 [22] CodeBlockWithTextElement.cshtml) + IntermediateToken - (35:1,31 [22] CodeBlockWithTextElement.cshtml) - CSharp - \n var b = 1; + HtmlContent - (63:2,23 [4] CodeBlockWithTextElement.cshtml) + IntermediateToken - (63:2,23 [4] CodeBlockWithTextElement.cshtml) - Html - bar + CSharpExpression - (69:2,29 [3] CodeBlockWithTextElement.cshtml) + IntermediateToken - (69:2,29 [3] CodeBlockWithTextElement.cshtml) - CSharp - a+b + CSharpCode - (80:2,40 [2] CodeBlockWithTextElement.cshtml) + IntermediateToken - (80:2,40 [2] CodeBlockWithTextElement.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt new file mode 100644 index 0000000000..3705416169 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.mappings.txt @@ -0,0 +1,26 @@ +Source Location: (2:0,2 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml) +| + var a = 1; | +Generated Location: (768:19,2 [17] ) +| + var a = 1; | + +Source Location: (35:1,31 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml) +| + var b = 1; | +Generated Location: (987:27,31 [22] ) +| + var b = 1; | + +Source Location: (69:2,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml) +|a+b| +Generated Location: (1218:35,38 [3] ) +|a+b| + +Source Location: (80:2,40 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml) +| +| +Generated Location: (1442:42,49 [2] ) +| +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs new file mode 100644 index 0000000000..59764e3772 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.codegen.cs @@ -0,0 +1,43 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b794c71d64ba4731b2802f7d0dae1f863a9f9dd9" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b794c71d64ba4731b2802f7d0dae1f863a9f9dd9", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + + var a = 1; + +#line default +#line hidden +#nullable disable + WriteLiteral("foo"); +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + + var b = 1; + +#line default +#line hidden +#nullable disable + WriteLiteral("bar "); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml" + Write(a+b); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt new file mode 100644 index 0000000000..0c163f3a41 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_Runtime.ir.txt @@ -0,0 +1,18 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [17] CodeBlockWithTextElement.cshtml) + IntermediateToken - (2:0,2 [17] CodeBlockWithTextElement.cshtml) - CSharp - \n var a = 1; + HtmlContent - (25:1,21 [3] CodeBlockWithTextElement.cshtml) + IntermediateToken - (25:1,21 [3] CodeBlockWithTextElement.cshtml) - Html - foo + CSharpCode - (35:1,31 [22] CodeBlockWithTextElement.cshtml) + IntermediateToken - (35:1,31 [22] CodeBlockWithTextElement.cshtml) - CSharp - \n var b = 1; + HtmlContent - (63:2,23 [4] CodeBlockWithTextElement.cshtml) + IntermediateToken - (63:2,23 [4] CodeBlockWithTextElement.cshtml) - Html - bar + CSharpExpression - (69:2,29 [3] CodeBlockWithTextElement.cshtml) + IntermediateToken - (69:2,29 [3] CodeBlockWithTextElement.cshtml) - CSharp - a+b + CSharpCode - (80:2,40 [2] CodeBlockWithTextElement.cshtml) + IntermediateToken - (80:2,40 [2] CodeBlockWithTextElement.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.codegen.cs new file mode 100644 index 0000000000..49483b617e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml" + + for(int i = 1; i <= 10; i++) { + Output.Write("

        Hello from C#, #" + i.ToString() + "

        "); + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.codegen.html new file mode 100644 index 0000000000..f857199dcf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.codegen.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt new file mode 100644 index 0000000000..2dadb8d1fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [115] CodeBlock.cshtml) + IntermediateToken - (2:0,2 [115] CodeBlock.cshtml) - CSharp - \n for(int i = 1; i <= 10; i++) {\n Output.Write("

        Hello from C#, #" + i.ToString() + "

        ");\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.mappings.txt new file mode 100644 index 0000000000..6d4378fb88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (2:0,2 [115] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml) +| + for(int i = 1; i <= 10; i++) { + Output.Write("

        Hello from C#, #" + i.ToString() + "

        "); + } +| +Generated Location: (738:19,2 [115] ) +| + for(int i = 1; i <= 10; i++) { + Output.Write("

        Hello from C#, #" + i.ToString() + "

        "); + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs new file mode 100644 index 0000000000..d3255c7b03 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.codegen.cs @@ -0,0 +1,28 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d570564dcb19afbfb9fcd1b8a7e339d22c0d0c97" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d570564dcb19afbfb9fcd1b8a7e339d22c0d0c97", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock.cshtml" + + for(int i = 1; i <= 10; i++) { + Output.Write("

        Hello from C#, #" + i.ToString() + "

        "); + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt new file mode 100644 index 0000000000..f700c27032 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_Runtime.ir.txt @@ -0,0 +1,8 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [115] CodeBlock.cshtml) + IntermediateToken - (2:0,2 [115] CodeBlock.cshtml) - CSharp - \n for(int i = 1; i <= 10; i++) {\n Output.Write("

        Hello from C#, #" + i.ToString() + "

        ");\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml new file mode 100644 index 0000000000..546906282c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml @@ -0,0 +1,38 @@ +@addTagHelper "*, TestAssembly" + +@if (true) +{ + var checkbox = "checkbox"; + +
        +

        +

        +

        Set Time:

        + @if (false) + { +

        New Time:

        + } + else + { +

        Current Time:

        + + + } +

        +

        + @{ var @object = false;} + +

        +

        + +

        +

        + +

        +

        + +

        + @someMethod(@

        ) +

        +
        +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..8f32099009 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,307 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + if (true) +{ + var checkbox = "checkbox"; + + + +#line default +#line hidden +#nullable disable + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = @@(1+2); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + if (false) + { + + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "text"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + + } + else + { + + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __o = checkbox; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Type = string.Empty; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + + + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __o = true ? "checkbox" : "anything"; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Type = string.Empty; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + + + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + if(true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Type = string.Empty; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + + } + +#line default +#line hidden +#nullable disable + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + var @object = false; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = (@object); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __TestNamespace_PTagHelper.Age = DateTimeOffset.Now.Year - 1970; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __TestNamespace_InputTagHelper2.Checked = (DateTimeOffset.Now.Year > 2014); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = -1970 + @DateTimeOffset.Now.Year; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = DateTimeOffset.Now.Year - 1970; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = @( DateTimeOffset.Now.Year ) > 2014 ; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 32 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = ("My age is this long.".Length); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __o = someMethod(item => new Template(async(__razor_template_writer) => { + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + __TestNamespace_InputTagHelper2.Checked = checked; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = 123; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +} +)); + +#line default +#line hidden +#nullable disable + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = ; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..fe2b80c9e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml(36,17): Error RZ2006: Code blocks (e.g. @{var variable = 23;}) must not appear in non-string tag helper attribute values. + Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..30f540a77d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt @@ -0,0 +1,308 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] ComplexTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] ComplexTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] ComplexTagHelpers.cshtml) - Html - \n\n + CSharpCode - (36:2,1 [52] ComplexTagHelpers.cshtml) + IntermediateToken - (36:2,1 [52] ComplexTagHelpers.cshtml) - CSharp - if (true)\n{\n var checkbox = "checkbox";\n\n + HtmlContent - (88:6,4 [51] ComplexTagHelpers.cshtml) + IntermediateToken - (88:6,4 [4] ComplexTagHelpers.cshtml) - Html -
        + IntermediateToken - (129:6,45 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (139:7,8 [39] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (147:7,16 [8] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (147:7,16 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (149:7,18 [0] ComplexTagHelpers.cshtml) - CSharp - + CSharpExpression - (149:7,18 [6] ComplexTagHelpers.cshtml) + IntermediateToken - (149:7,18 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (150:7,19 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (151:7,20 [3] ComplexTagHelpers.cshtml) - CSharp - 1+2 + IntermediateToken - (154:7,23 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (164:7,33 [1] ComplexTagHelpers.cshtml) + IntermediateToken - (164:7,33 [1] ComplexTagHelpers.cshtml) - Html - @ + HtmlContent - (166:7,35 [6] ComplexTagHelpers.cshtml) + IntermediateToken - (166:7,35 [6] ComplexTagHelpers.cshtml) - Html - string + DefaultTagHelperExecute - + HtmlContent - (178:7,47 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (178:7,47 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (188:8,8 [531] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (226:8,46 [46] ComplexTagHelpers.cshtml) + IntermediateToken - (226:8,46 [14] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (240:9,12 [3] ComplexTagHelpers.cshtml) - Html -

        + IntermediateToken - (244:9,16 [9] ComplexTagHelpers.cshtml) - Html - Set Time: + IntermediateToken - (253:9,25 [5] ComplexTagHelpers.cshtml) - Html -

        + IntermediateToken - (258:9,30 [14] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (273:10,13 [43] ComplexTagHelpers.cshtml) + IntermediateToken - (273:10,13 [43] ComplexTagHelpers.cshtml) - CSharp - if (false)\n {\n + TagHelper - (316:12,16 [83] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (319:12,19 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (319:12,19 [10] ComplexTagHelpers.cshtml) - Html - New Time: + TagHelper - (329:12,29 [66] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (342:12,42 [4] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (342:12,42 [4] ComplexTagHelpers.cshtml) + IntermediateToken - (342:12,42 [4] ComplexTagHelpers.cshtml) - Html - text + DefaultTagHelperProperty - (342:12,42 [4] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (342:12,42 [4] ComplexTagHelpers.cshtml) + IntermediateToken - (342:12,42 [4] ComplexTagHelpers.cshtml) - Html - text + DefaultTagHelperHtmlAttribute - - value - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (355:12,55 [0] ComplexTagHelpers.cshtml) + IntermediateToken - (355:12,55 [0] ComplexTagHelpers.cshtml) - Html - + DefaultTagHelperHtmlAttribute - - placeholder - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (370:12,70 [22] ComplexTagHelpers.cshtml) + IntermediateToken - (370:12,70 [22] ComplexTagHelpers.cshtml) - Html - Enter in a new time... + DefaultTagHelperExecute - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperExecute - + CSharpCode - (399:12,99 [66] ComplexTagHelpers.cshtml) + IntermediateToken - (399:12,99 [66] ComplexTagHelpers.cshtml) - CSharp - \n }\n else\n {\n + TagHelper - (465:16,16 [58] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (468:16,19 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (468:16,19 [14] ComplexTagHelpers.cshtml) - Html - Current Time: + TagHelper - (482:16,33 [37] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (494:16,45 [9] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (495:16,46 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (495:16,46 [8] ComplexTagHelpers.cshtml) - CSharp - checkbox + DefaultTagHelperProperty - (494:16,45 [9] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (495:16,46 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (495:16,46 [8] ComplexTagHelpers.cshtml) - CSharp - checkbox + DefaultTagHelperProperty - (512:16,63 [4] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (512:16,63 [4] ComplexTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperExecute - + CSharpCode - (523:16,74 [18] ComplexTagHelpers.cshtml) + IntermediateToken - (523:16,74 [18] ComplexTagHelpers.cshtml) - CSharp - \n + TagHelper - (541:17,16 [50] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (554:17,29 [33] ComplexTagHelpers.cshtml) - tYPe - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpExpression - (556:17,31 [30] ComplexTagHelpers.cshtml) + IntermediateToken - (556:17,31 [30] ComplexTagHelpers.cshtml) - CSharp - true ? "checkbox" : "anything" + DefaultTagHelperProperty - (554:17,29 [33] ComplexTagHelpers.cshtml) - tYPe - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpExpression - (556:17,31 [30] ComplexTagHelpers.cshtml) + IntermediateToken - (556:17,31 [30] ComplexTagHelpers.cshtml) - CSharp - true ? "checkbox" : "anything" + DefaultTagHelperExecute - + CSharpCode - (591:17,66 [18] ComplexTagHelpers.cshtml) + IntermediateToken - (591:17,66 [18] ComplexTagHelpers.cshtml) - CSharp - \n + TagHelper - (609:18,16 [81] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (622:18,29 [66] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpCode - (623:18,30 [11] ComplexTagHelpers.cshtml) + IntermediateToken - (623:18,30 [11] ComplexTagHelpers.cshtml) - CSharp - if(true) { + HtmlContent - (640:18,47 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (640:18,47 [8] ComplexTagHelpers.cshtml) - Html - checkbox + CSharpCode - (655:18,62 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (655:18,62 [10] ComplexTagHelpers.cshtml) - CSharp - } else { + HtmlContent - (671:18,78 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (671:18,78 [8] ComplexTagHelpers.cshtml) - Html - anything + CSharpCode - (686:18,93 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (686:18,93 [2] ComplexTagHelpers.cshtml) - CSharp - } + DefaultTagHelperProperty - (622:18,29 [66] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpCode - (623:18,30 [11] ComplexTagHelpers.cshtml) + IntermediateToken - (623:18,30 [11] ComplexTagHelpers.cshtml) - CSharp - if(true) { + HtmlContent - (640:18,47 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (640:18,47 [8] ComplexTagHelpers.cshtml) - Html - checkbox + CSharpCode - (655:18,62 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (655:18,62 [10] ComplexTagHelpers.cshtml) - CSharp - } else { + HtmlContent - (671:18,78 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (671:18,78 [8] ComplexTagHelpers.cshtml) - Html - anything + CSharpCode - (686:18,93 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (686:18,93 [2] ComplexTagHelpers.cshtml) - CSharp - } + DefaultTagHelperExecute - + CSharpCode - (690:18,97 [15] ComplexTagHelpers.cshtml) + IntermediateToken - (690:18,97 [15] ComplexTagHelpers.cshtml) - CSharp - \n } + HtmlContent - (705:19,13 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (705:19,13 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - time - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (197:8,17 [7] ComplexTagHelpers.cshtml) - + IntermediateToken - (197:8,17 [7] ComplexTagHelpers.cshtml) - Html - Current + HtmlAttributeValue - (204:8,24 [6] ComplexTagHelpers.cshtml) - + IntermediateToken - (205:8,25 [5] ComplexTagHelpers.cshtml) - Html - Time: + CSharpExpressionAttributeValue - (210:8,30 [14] ComplexTagHelpers.cshtml) - + IntermediateToken - (212:8,32 [12] ComplexTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperExecute - + HtmlContent - (719:20,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (719:20,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (729:21,8 [181] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (816:21,95 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (816:21,95 [14] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (832:22,14 [21] ComplexTagHelpers.cshtml) + IntermediateToken - (832:22,14 [21] ComplexTagHelpers.cshtml) - CSharp - var @object = false; + HtmlContent - (856:23,0 [12] ComplexTagHelpers.cshtml) + IntermediateToken - (856:23,0 [12] ComplexTagHelpers.cshtml) - Html - + TagHelper - (868:23,12 [28] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (884:23,28 [10] ComplexTagHelpers.cshtml) - ChecKED - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (885:23,29 [9] ComplexTagHelpers.cshtml) + IntermediateToken - (885:23,29 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (886:23,30 [7] ComplexTagHelpers.cshtml) - CSharp - @object + IntermediateToken - (893:23,37 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (896:23,40 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (896:23,40 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (741:21,20 [11] ComplexTagHelpers.cshtml) + IntermediateToken - (741:21,20 [11] ComplexTagHelpers.cshtml) - Html - first value + DefaultTagHelperProperty - (759:21,38 [31] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (760:21,39 [23] ComplexTagHelpers.cshtml) + IntermediateToken - (760:21,39 [23] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year + IntermediateToken - (783:21,62 [2] ComplexTagHelpers.cshtml) - CSharp - - + IntermediateToken - (785:21,64 [5] ComplexTagHelpers.cshtml) - CSharp - 1970 + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (801:21,80 [12] ComplexTagHelpers.cshtml) + IntermediateToken - (801:21,80 [12] ComplexTagHelpers.cshtml) - Html - second value + DefaultTagHelperExecute - + HtmlContent - (910:24,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (910:24,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (920:25,8 [155] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (962:25,50 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (962:25,50 [14] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (976:26,12 [85] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (992:26,28 [5] ComplexTagHelpers.cshtml) + IntermediateToken - (992:26,28 [5] ComplexTagHelpers.cshtml) - Html - hello + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (1008:26,44 [5] ComplexTagHelpers.cshtml) + IntermediateToken - (1008:26,44 [5] ComplexTagHelpers.cshtml) - Html - world + DefaultTagHelperProperty - (1024:26,60 [33] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (1025:26,61 [32] ComplexTagHelpers.cshtml) + IntermediateToken - (1025:26,61 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (1026:26,62 [30] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year > 2014 + IntermediateToken - (1056:26,92 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (1061:26,97 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1061:26,97 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (928:25,16 [32] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (928:25,16 [5] ComplexTagHelpers.cshtml) - CSharp - -1970 + IntermediateToken - (933:25,21 [2] ComplexTagHelpers.cshtml) - CSharp - + + IntermediateToken - (935:25,23 [1] ComplexTagHelpers.cshtml) - CSharp - + CSharpExpression - (936:25,24 [24] ComplexTagHelpers.cshtml) + IntermediateToken - (936:25,24 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (937:25,25 [23] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year + DefaultTagHelperExecute - + HtmlContent - (1075:27,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1075:27,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1085:28,8 [116] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (1125:28,48 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (1125:28,48 [14] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1139:29,12 [48] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (1155:29,28 [30] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1155:29,28 [30] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year > 2014 + DefaultTagHelperExecute - + HtmlContent - (1187:29,60 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1187:29,60 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1093:28,16 [30] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1093:28,16 [30] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year\-1970 + DefaultTagHelperExecute - + HtmlContent - (1201:30,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1201:30,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1211:31,8 [133] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (1253:31,50 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (1253:31,50 [14] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1267:32,12 [63] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (1283:32,28 [43] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1283:32,28 [3] ComplexTagHelpers.cshtml) - CSharp - + CSharpExpression - (1286:32,31 [30] ComplexTagHelpers.cshtml) + IntermediateToken - (1286:32,31 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (1287:32,32 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (1288:32,33 [27] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year + IntermediateToken - (1315:32,60 [1] ComplexTagHelpers.cshtml) - CSharp - ) + IntermediateToken - (1316:32,61 [2] ComplexTagHelpers.cshtml) - CSharp - > + IntermediateToken - (1318:32,63 [5] ComplexTagHelpers.cshtml) - CSharp - 2014 + IntermediateToken - (1323:32,68 [3] ComplexTagHelpers.cshtml) - CSharp - + DefaultTagHelperExecute - + HtmlContent - (1330:32,75 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1330:32,75 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1219:31,16 [32] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (1220:31,17 [31] ComplexTagHelpers.cshtml) + IntermediateToken - (1220:31,17 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (1221:31,18 [29] ComplexTagHelpers.cshtml) - CSharp - "My age is this long.".Length + IntermediateToken - (1250:31,47 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (1344:33,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1344:33,12 [10] ComplexTagHelpers.cshtml) - Html - \n + CSharpExpression - (1355:34,9 [69] ComplexTagHelpers.cshtml) + IntermediateToken - (1355:34,9 [11] ComplexTagHelpers.cshtml) - CSharp - someMethod( + Template - (1367:34,21 [57] ComplexTagHelpers.cshtml) + TagHelper - (1367:34,21 [57] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + TagHelper - (1394:34,48 [26] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (1409:34,63 [8] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (1410:34,64 [7] ComplexTagHelpers.cshtml) + IntermediateToken - (1410:34,64 [7] ComplexTagHelpers.cshtml) - CSharp - checked + DefaultTagHelperExecute - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1375:34,29 [3] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1375:34,29 [3] ComplexTagHelpers.cshtml) - CSharp - 123 + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (1387:34,41 [5] ComplexTagHelpers.cshtml) + IntermediateToken - (1387:34,41 [5] ComplexTagHelpers.cshtml) - Html - hello + DefaultTagHelperExecute - + IntermediateToken - (1424:34,78 [1] ComplexTagHelpers.cshtml) - CSharp - ) + HtmlContent - (1425:34,79 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1425:34,79 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1435:35,8 [22] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1443:35,16 [8] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + CSharpCode - (1445:35,18 [5] ComplexTagHelpers.cshtml) + IntermediateToken - (1445:35,18 [5] ComplexTagHelpers.cshtml) - CSharp - 1 + 2 + DefaultTagHelperExecute - + HtmlContent - (1457:35,30 [12] ComplexTagHelpers.cshtml) + IntermediateToken - (1457:35,30 [6] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (1463:36,4 [6] ComplexTagHelpers.cshtml) - Html -
        + CSharpCode - (1469:36,10 [3] ComplexTagHelpers.cshtml) + IntermediateToken - (1469:36,10 [3] ComplexTagHelpers.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..f3b69d6fd2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,293 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1195:20,37 [17] ) +|"*, TestAssembly"| + +Source Location: (36:2,1 [52] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|if (true) +{ + var checkbox = "checkbox"; + + | +Generated Location: (1692:37,1 [52] ) +|if (true) +{ + var checkbox = "checkbox"; + + | + +Source Location: (147:7,16 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|@| +Generated Location: (2036:49,33 [1] ) +|@| + +Source Location: (149:7,18 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|| +Generated Location: (2037:49,34 [0] ) +|| + +Source Location: (149:7,18 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|@| +Generated Location: (2037:49,34 [1] ) +|@| + +Source Location: (150:7,19 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|(| +Generated Location: (2038:49,35 [1] ) +|(| + +Source Location: (151:7,20 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|1+2| +Generated Location: (2039:49,36 [3] ) +|1+2| + +Source Location: (154:7,23 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|)| +Generated Location: (2042:49,39 [1] ) +|)| + +Source Location: (273:10,13 [43] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|if (false) + { + | +Generated Location: (2298:57,13 [43] ) +|if (false) + { + | + +Source Location: (399:12,99 [66] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| + } + else + { + | +Generated Location: (3208:73,99 [66] ) +| + } + else + { + | + +Source Location: (495:16,46 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|checkbox| +Generated Location: (3693:86,46 [8] ) +|checkbox| + +Source Location: (512:16,63 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|true| +Generated Location: (4084:95,63 [4] ) +|true| + +Source Location: (523:16,74 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| + | +Generated Location: (4575:105,74 [18] ) +| + | + +Source Location: (556:17,31 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|true ? "checkbox" : "anything"| +Generated Location: (4997:115,31 [30] ) +|true ? "checkbox" : "anything"| + +Source Location: (591:17,66 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| + | +Generated Location: (5489:125,66 [18] ) +| + | + +Source Location: (623:18,30 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|if(true) { | +Generated Location: (5910:135,30 [11] ) +|if(true) { | + +Source Location: (655:18,62 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| } else { | +Generated Location: (6148:142,62 [10] ) +| } else { | + +Source Location: (686:18,93 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| }| +Generated Location: (6416:149,93 [2] ) +| }| + +Source Location: (690:18,97 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| + }| +Generated Location: (6910:159,97 [15] ) +| + }| + +Source Location: (212:8,32 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (7216:168,32 [12] ) +|DateTime.Now| + +Source Location: (832:22,14 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| var @object = false;| +Generated Location: (7484:176,14 [21] ) +| var @object = false;| + +Source Location: (885:23,29 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|(| +Generated Location: (7920:185,42 [1] ) +|(| + +Source Location: (886:23,30 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|@object| +Generated Location: (7921:185,43 [7] ) +|@object| + +Source Location: (893:23,37 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|)| +Generated Location: (7928:185,50 [1] ) +|)| + +Source Location: (760:21,39 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|DateTimeOffset.Now.Year| +Generated Location: (8304:194,38 [23] ) +|DateTimeOffset.Now.Year| + +Source Location: (783:21,62 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| -| +Generated Location: (8327:194,61 [2] ) +| -| + +Source Location: (785:21,64 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| 1970| +Generated Location: (8329:194,63 [5] ) +| 1970| + +Source Location: (1025:26,61 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|(| +Generated Location: (8844:204,60 [1] ) +|(| + +Source Location: (1026:26,62 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|DateTimeOffset.Now.Year > 2014| +Generated Location: (8845:204,61 [30] ) +|DateTimeOffset.Now.Year > 2014| + +Source Location: (1056:26,92 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|)| +Generated Location: (8875:204,91 [1] ) +|)| + +Source Location: (928:25,16 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|-1970| +Generated Location: (9246:213,33 [5] ) +|-1970| + +Source Location: (933:25,21 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| +| +Generated Location: (9251:213,38 [2] ) +| +| + +Source Location: (935:25,23 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| | +Generated Location: (9253:213,40 [1] ) +| | + +Source Location: (936:25,24 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|@| +Generated Location: (9254:213,41 [1] ) +|@| + +Source Location: (937:25,25 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|DateTimeOffset.Now.Year| +Generated Location: (9255:213,42 [23] ) +|DateTimeOffset.Now.Year| + +Source Location: (1155:29,28 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|DateTimeOffset.Now.Year > 2014| +Generated Location: (9770:223,42 [30] ) +|DateTimeOffset.Now.Year > 2014| + +Source Location: (1093:28,16 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|DateTimeOffset.Now.Year - 1970| +Generated Location: (10170:232,33 [30] ) +|DateTimeOffset.Now.Year - 1970| + +Source Location: (1283:32,28 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| | +Generated Location: (10692:242,42 [3] ) +| | + +Source Location: (1286:32,31 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|@| +Generated Location: (10695:242,45 [1] ) +|@| + +Source Location: (1287:32,32 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|(| +Generated Location: (10696:242,46 [1] ) +|(| + +Source Location: (1288:32,33 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| DateTimeOffset.Now.Year | +Generated Location: (10697:242,47 [27] ) +| DateTimeOffset.Now.Year | + +Source Location: (1315:32,60 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|)| +Generated Location: (10724:242,74 [1] ) +|)| + +Source Location: (1316:32,61 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| >| +Generated Location: (10725:242,75 [2] ) +| >| + +Source Location: (1318:32,63 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| 2014| +Generated Location: (10727:242,77 [5] ) +| 2014| + +Source Location: (1323:32,68 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| | +Generated Location: (10732:242,82 [3] ) +| | + +Source Location: (1220:31,17 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|(| +Generated Location: (11105:251,33 [1] ) +|(| + +Source Location: (1221:31,18 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|"My age is this long.".Length| +Generated Location: (11106:251,34 [29] ) +|"My age is this long.".Length| + +Source Location: (1250:31,47 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|)| +Generated Location: (11135:251,63 [1] ) +|)| + +Source Location: (1355:34,9 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|someMethod(| +Generated Location: (11387:259,9 [11] ) +|someMethod(| + +Source Location: (1410:34,64 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|checked| +Generated Location: (11824:264,63 [7] ) +|checked| + +Source Location: (1375:34,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|123| +Generated Location: (12185:273,33 [3] ) +|123| + +Source Location: (1424:34,78 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +|)| +Generated Location: (12313:280,1 [1] ) +|)| + +Source Location: (1469:36,10 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml) +| +}| +Generated Location: (12860:296,10 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..e0c1d6acf6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.codegen.cs @@ -0,0 +1,566 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ab167e80e48e48d9984ecd76158a2d87f90f3460" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ab167e80e48e48d9984ecd76158a2d87f90f3460", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", new global::Microsoft.AspNetCore.Html.HtmlString(""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("placeholder", new global::Microsoft.AspNetCore.Html.HtmlString("Enter in a new time..."), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("unbound", new global::Microsoft.AspNetCore.Html.HtmlString("first value"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("unbound", new global::Microsoft.AspNetCore.Html.HtmlString("second value"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("unbound", new global::Microsoft.AspNetCore.Html.HtmlString("hello"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_6 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("unbound", new global::Microsoft.AspNetCore.Html.HtmlString("world"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_7 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("hello"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + if (true) +{ + var checkbox = "checkbox"; + + +#line default +#line hidden +#nullable disable + WriteLiteral("
        \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = @@(1+2); + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + BeginWriteTagHelperAttribute(); + WriteLiteral("@"); + WriteLiteral("string"); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("class", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n

        Set Time:

        \r\n"); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + if (false) + { + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("New Time: "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + } + else + { + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Current Time: "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + WriteLiteral(checkbox); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper.Type = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __TestNamespace_InputTagHelper.Type, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + WriteLiteral(true ? "checkbox" : "anything"); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper.Type = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("tYPe", __TestNamespace_InputTagHelper.Type, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + if(true) { + +#line default +#line hidden +#nullable disable + WriteLiteral("checkbox"); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable + WriteLiteral("anything"); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper.Type = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __TestNamespace_InputTagHelper.Type, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "time", 3, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 197, "Current", 197, 7, true); + AddHtmlAttributeValue(" ", 204, "Time:", 205, 6, true); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +AddHtmlAttributeValue(" ", 210, DateTime.Now, 211, 13, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n"); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + var @object = false; + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = (@object); + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("ChecKED", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = DateTimeOffset.Now.Year - 1970; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_6); +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = (DateTimeOffset.Now.Year > 2014); + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = -1970 + @DateTimeOffset.Now.Year; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = DateTimeOffset.Now.Year > 2014; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = DateTimeOffset.Now.Year - 1970; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = @( DateTimeOffset.Now.Year ) > 2014 ; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 32 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = ("My age is this long.".Length); + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" + Write(someMethod(item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = checked; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 35 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = 123; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_7); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + PopWriter(); +} +))); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = ; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        \r\n"); +#nullable restore +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.diagnostics.txt new file mode 100644 index 0000000000..fe2b80c9e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml(36,17): Error RZ2006: Code blocks (e.g. @{var variable = 23;}) must not appear in non-string tag helper attribute values. + Already in an expression (code) context. If necessary an explicit expression (e.g. @(@readonly)) may be used. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..79168e02ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_Runtime.ir.txt @@ -0,0 +1,309 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - value - - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - placeholder - Enter in a new time... - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - unbound - first value - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_4 - unbound - second value - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_5 - unbound - hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_6 - unbound - world - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_7 - class - hello - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (36:2,1 [48] ComplexTagHelpers.cshtml) + IntermediateToken - (36:2,1 [48] ComplexTagHelpers.cshtml) - CSharp - if (true)\n{\n var checkbox = "checkbox";\n\n + HtmlContent - (84:6,0 [55] ComplexTagHelpers.cshtml) + IntermediateToken - (84:6,0 [4] ComplexTagHelpers.cshtml) - Html - + IntermediateToken - (88:6,4 [4] ComplexTagHelpers.cshtml) - Html -
        + IntermediateToken - (129:6,45 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (139:7,8 [39] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (147:7,16 [8] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (147:7,16 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (149:7,18 [0] ComplexTagHelpers.cshtml) - CSharp - + CSharpExpression - (149:7,18 [6] ComplexTagHelpers.cshtml) + IntermediateToken - (149:7,18 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (150:7,19 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (151:7,20 [3] ComplexTagHelpers.cshtml) - CSharp - 1+2 + IntermediateToken - (154:7,23 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (164:7,33 [1] ComplexTagHelpers.cshtml) + IntermediateToken - (164:7,33 [1] ComplexTagHelpers.cshtml) - Html - @ + HtmlContent - (166:7,35 [6] ComplexTagHelpers.cshtml) + IntermediateToken - (166:7,35 [6] ComplexTagHelpers.cshtml) - Html - string + DefaultTagHelperExecute - + HtmlContent - (178:7,47 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (178:7,47 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (188:8,8 [531] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (226:8,46 [34] ComplexTagHelpers.cshtml) + IntermediateToken - (226:8,46 [14] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (240:9,12 [3] ComplexTagHelpers.cshtml) - Html -

        + IntermediateToken - (244:9,16 [9] ComplexTagHelpers.cshtml) - Html - Set Time: + IntermediateToken - (253:9,25 [5] ComplexTagHelpers.cshtml) - Html -

        + IntermediateToken - (258:9,30 [2] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (260:10,0 [12] ComplexTagHelpers.cshtml) + IntermediateToken - (260:10,0 [12] ComplexTagHelpers.cshtml) - CSharp - + CSharpCode - (273:10,13 [27] ComplexTagHelpers.cshtml) + IntermediateToken - (273:10,13 [27] ComplexTagHelpers.cshtml) - CSharp - if (false)\n {\n + HtmlContent - (300:12,0 [16] ComplexTagHelpers.cshtml) + IntermediateToken - (300:12,0 [16] ComplexTagHelpers.cshtml) - Html - + TagHelper - (316:12,16 [83] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (319:12,19 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (319:12,19 [10] ComplexTagHelpers.cshtml) - Html - New Time: + TagHelper - (329:12,29 [66] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (342:12,42 [4] ComplexTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (342:12,42 [4] ComplexTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperExecute - + HtmlContent - (399:12,99 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (399:12,99 [2] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (401:13,0 [48] ComplexTagHelpers.cshtml) + IntermediateToken - (401:13,0 [48] ComplexTagHelpers.cshtml) - CSharp - }\n else\n {\n + HtmlContent - (449:16,0 [16] ComplexTagHelpers.cshtml) + IntermediateToken - (449:16,0 [16] ComplexTagHelpers.cshtml) - Html - + TagHelper - (465:16,16 [58] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (468:16,19 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (468:16,19 [14] ComplexTagHelpers.cshtml) - Html - Current Time: + TagHelper - (482:16,33 [37] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (494:16,45 [9] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (495:16,46 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (495:16,46 [8] ComplexTagHelpers.cshtml) - CSharp - checkbox + DefaultTagHelperProperty - (494:16,45 [9] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (495:16,46 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (495:16,46 [8] ComplexTagHelpers.cshtml) - CSharp - checkbox + DefaultTagHelperProperty - (512:16,63 [4] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (512:16,63 [4] ComplexTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperExecute - + HtmlContent - (523:16,74 [18] ComplexTagHelpers.cshtml) + IntermediateToken - (523:16,74 [2] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (525:17,0 [16] ComplexTagHelpers.cshtml) - Html - + TagHelper - (541:17,16 [50] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (554:17,29 [33] ComplexTagHelpers.cshtml) - tYPe - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpExpression - (556:17,31 [30] ComplexTagHelpers.cshtml) + IntermediateToken - (556:17,31 [30] ComplexTagHelpers.cshtml) - CSharp - true ? "checkbox" : "anything" + DefaultTagHelperProperty - (554:17,29 [33] ComplexTagHelpers.cshtml) - tYPe - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpExpression - (556:17,31 [30] ComplexTagHelpers.cshtml) + IntermediateToken - (556:17,31 [30] ComplexTagHelpers.cshtml) - CSharp - true ? "checkbox" : "anything" + DefaultTagHelperExecute - + HtmlContent - (591:17,66 [18] ComplexTagHelpers.cshtml) + IntermediateToken - (591:17,66 [2] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (593:18,0 [16] ComplexTagHelpers.cshtml) - Html - + TagHelper - (609:18,16 [81] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (622:18,29 [66] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpCode - (623:18,30 [11] ComplexTagHelpers.cshtml) + IntermediateToken - (623:18,30 [11] ComplexTagHelpers.cshtml) - CSharp - if(true) { + HtmlContent - (640:18,47 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (640:18,47 [8] ComplexTagHelpers.cshtml) - Html - checkbox + CSharpCode - (655:18,62 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (655:18,62 [10] ComplexTagHelpers.cshtml) - CSharp - } else { + HtmlContent - (671:18,78 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (671:18,78 [8] ComplexTagHelpers.cshtml) - Html - anything + CSharpCode - (686:18,93 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (686:18,93 [2] ComplexTagHelpers.cshtml) - CSharp - } + DefaultTagHelperProperty - (622:18,29 [66] ComplexTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.SingleQuotes + CSharpCode - (623:18,30 [11] ComplexTagHelpers.cshtml) + IntermediateToken - (623:18,30 [11] ComplexTagHelpers.cshtml) - CSharp - if(true) { + HtmlContent - (640:18,47 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (640:18,47 [8] ComplexTagHelpers.cshtml) - Html - checkbox + CSharpCode - (655:18,62 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (655:18,62 [10] ComplexTagHelpers.cshtml) - CSharp - } else { + HtmlContent - (671:18,78 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (671:18,78 [8] ComplexTagHelpers.cshtml) - Html - anything + CSharpCode - (686:18,93 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (686:18,93 [2] ComplexTagHelpers.cshtml) - CSharp - } + DefaultTagHelperExecute - + HtmlContent - (690:18,97 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (690:18,97 [2] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (692:19,0 [15] ComplexTagHelpers.cshtml) + IntermediateToken - (692:19,0 [15] ComplexTagHelpers.cshtml) - CSharp - }\n + HtmlContent - (707:20,0 [8] ComplexTagHelpers.cshtml) + IntermediateToken - (707:20,0 [8] ComplexTagHelpers.cshtml) - Html - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - time - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (197:8,17 [7] ComplexTagHelpers.cshtml) - + IntermediateToken - (197:8,17 [7] ComplexTagHelpers.cshtml) - Html - Current + HtmlAttributeValue - (204:8,24 [6] ComplexTagHelpers.cshtml) - + IntermediateToken - (205:8,25 [5] ComplexTagHelpers.cshtml) - Html - Time: + CSharpExpressionAttributeValue - (210:8,30 [14] ComplexTagHelpers.cshtml) - + IntermediateToken - (212:8,32 [12] ComplexTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperExecute - + HtmlContent - (719:20,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (719:20,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (729:21,8 [181] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (816:21,95 [2] ComplexTagHelpers.cshtml) + IntermediateToken - (816:21,95 [2] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (818:22,0 [12] ComplexTagHelpers.cshtml) + IntermediateToken - (818:22,0 [12] ComplexTagHelpers.cshtml) - CSharp - + CSharpCode - (832:22,14 [21] ComplexTagHelpers.cshtml) + IntermediateToken - (832:22,14 [21] ComplexTagHelpers.cshtml) - CSharp - var @object = false; + HtmlContent - (856:23,0 [12] ComplexTagHelpers.cshtml) + IntermediateToken - (856:23,0 [12] ComplexTagHelpers.cshtml) - Html - + TagHelper - (868:23,12 [28] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (884:23,28 [10] ComplexTagHelpers.cshtml) - ChecKED - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (885:23,29 [9] ComplexTagHelpers.cshtml) + IntermediateToken - (885:23,29 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (886:23,30 [7] ComplexTagHelpers.cshtml) - CSharp - @object + IntermediateToken - (893:23,37 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (896:23,40 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (896:23,40 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperProperty - (759:21,38 [31] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (760:21,39 [23] ComplexTagHelpers.cshtml) + IntermediateToken - (760:21,39 [23] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year + IntermediateToken - (783:21,62 [2] ComplexTagHelpers.cshtml) - CSharp - - + IntermediateToken - (785:21,64 [5] ComplexTagHelpers.cshtml) - CSharp - 1970 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_4 + DefaultTagHelperExecute - + HtmlContent - (910:24,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (910:24,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (920:25,8 [155] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (962:25,50 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (962:25,50 [14] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (976:26,12 [85] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_6 + DefaultTagHelperProperty - (1024:26,60 [33] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (1025:26,61 [32] ComplexTagHelpers.cshtml) + IntermediateToken - (1025:26,61 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (1026:26,62 [30] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year > 2014 + IntermediateToken - (1056:26,92 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (1061:26,97 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1061:26,97 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (928:25,16 [32] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (928:25,16 [5] ComplexTagHelpers.cshtml) - CSharp - -1970 + IntermediateToken - (933:25,21 [2] ComplexTagHelpers.cshtml) - CSharp - + + IntermediateToken - (935:25,23 [1] ComplexTagHelpers.cshtml) - CSharp - + CSharpExpression - (936:25,24 [24] ComplexTagHelpers.cshtml) + IntermediateToken - (936:25,24 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (937:25,25 [23] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year + DefaultTagHelperExecute - + HtmlContent - (1075:27,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1075:27,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1085:28,8 [116] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (1125:28,48 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (1125:28,48 [14] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1139:29,12 [48] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (1155:29,28 [30] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1155:29,28 [30] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year > 2014 + DefaultTagHelperExecute - + HtmlContent - (1187:29,60 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1187:29,60 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1093:28,16 [30] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1093:28,16 [30] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year\-1970 + DefaultTagHelperExecute - + HtmlContent - (1201:30,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1201:30,12 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1211:31,8 [133] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (1253:31,50 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (1253:31,50 [14] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1267:32,12 [63] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (1283:32,28 [43] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1283:32,28 [3] ComplexTagHelpers.cshtml) - CSharp - + CSharpExpression - (1286:32,31 [30] ComplexTagHelpers.cshtml) + IntermediateToken - (1286:32,31 [1] ComplexTagHelpers.cshtml) - CSharp - @ + IntermediateToken - (1287:32,32 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (1288:32,33 [27] ComplexTagHelpers.cshtml) - CSharp - DateTimeOffset.Now.Year + IntermediateToken - (1315:32,60 [1] ComplexTagHelpers.cshtml) - CSharp - ) + IntermediateToken - (1316:32,61 [2] ComplexTagHelpers.cshtml) - CSharp - > + IntermediateToken - (1318:32,63 [5] ComplexTagHelpers.cshtml) - CSharp - 2014 + IntermediateToken - (1323:32,68 [3] ComplexTagHelpers.cshtml) - CSharp - + DefaultTagHelperExecute - + HtmlContent - (1330:32,75 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1330:32,75 [10] ComplexTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1219:31,16 [32] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (1220:31,17 [31] ComplexTagHelpers.cshtml) + IntermediateToken - (1220:31,17 [1] ComplexTagHelpers.cshtml) - CSharp - ( + IntermediateToken - (1221:31,18 [29] ComplexTagHelpers.cshtml) - CSharp - "My age is this long.".Length + IntermediateToken - (1250:31,47 [1] ComplexTagHelpers.cshtml) - CSharp - ) + DefaultTagHelperExecute - + HtmlContent - (1344:33,12 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1344:33,12 [2] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (1346:34,0 [8] ComplexTagHelpers.cshtml) - Html - + CSharpExpression - (1355:34,9 [69] ComplexTagHelpers.cshtml) + IntermediateToken - (1355:34,9 [11] ComplexTagHelpers.cshtml) - CSharp - someMethod( + Template - (1367:34,21 [57] ComplexTagHelpers.cshtml) + TagHelper - (1367:34,21 [57] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + TagHelper - (1394:34,48 [26] ComplexTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (1409:34,63 [8] ComplexTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (1410:34,64 [7] ComplexTagHelpers.cshtml) + IntermediateToken - (1410:34,64 [7] ComplexTagHelpers.cshtml) - CSharp - checked + DefaultTagHelperExecute - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1375:34,29 [3] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (1375:34,29 [3] ComplexTagHelpers.cshtml) - CSharp - 123 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_7 + DefaultTagHelperExecute - + IntermediateToken - (1424:34,78 [1] ComplexTagHelpers.cshtml) - CSharp - ) + HtmlContent - (1425:34,79 [10] ComplexTagHelpers.cshtml) + IntermediateToken - (1425:34,79 [10] ComplexTagHelpers.cshtml) - Html - \n + TagHelper - (1435:35,8 [22] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (1443:35,16 [8] ComplexTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + CSharpCode - (1445:35,18 [5] ComplexTagHelpers.cshtml) + IntermediateToken - (1445:35,18 [5] ComplexTagHelpers.cshtml) - CSharp - 1 + 2 + DefaultTagHelperExecute - + HtmlContent - (1457:35,30 [14] ComplexTagHelpers.cshtml) + IntermediateToken - (1457:35,30 [6] ComplexTagHelpers.cshtml) - Html - \n + IntermediateToken - (1463:36,4 [6] ComplexTagHelpers.cshtml) - Html -
        + IntermediateToken - (1469:36,10 [2] ComplexTagHelpers.cshtml) - Html - \n + CSharpCode - (1471:37,0 [1] ComplexTagHelpers.cshtml) + IntermediateToken - (1471:37,0 [1] ComplexTagHelpers.cshtml) - CSharp - } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml new file mode 100644 index 0000000000..be1a9c2079 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml @@ -0,0 +1,15 @@ +@{ + var ch = true; + var cls = "bar"; +
        +

        +

        +

        + + +

        + + + + +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs new file mode 100644 index 0000000000..d34404fec1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.cs @@ -0,0 +1,189 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + var ch = true; + var cls = "bar"; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = cls; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = cls; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = cls; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = ch; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = ch; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + if(cls != null) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = cls; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = Url.Content("~/Scripts/jquery-1.6.2.min.js"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + __o = Url.Content("~/Scripts/modernizr-2.0.6-development-only.js"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.html new file mode 100644 index 0000000000..46a4402680 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.codegen.html @@ -0,0 +1,15 @@ + + + + +

        +

        +

        + + +

        + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt new file mode 100644 index 0000000000..64a6847890 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt @@ -0,0 +1,128 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [48] ConditionalAttributes.cshtml) + IntermediateToken - (2:0,2 [48] ConditionalAttributes.cshtml) - CSharp - \n var ch = true;\n var cls = "bar";\n + HtmlContent - (50:3,4 [16] ConditionalAttributes.cshtml) + IntermediateToken - (50:3,4 [2] ConditionalAttributes.cshtml) - Html - + CSharpCode - (66:3,20 [6] ConditionalAttributes.cshtml) + IntermediateToken - (66:3,20 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (72:4,4 [2] ConditionalAttributes.cshtml) + IntermediateToken - (72:4,4 [2] ConditionalAttributes.cshtml) - Html -

        + CSharpCode - (90:4,22 [6] ConditionalAttributes.cshtml) + IntermediateToken - (90:4,22 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (96:5,4 [2] ConditionalAttributes.cshtml) + IntermediateToken - (96:5,4 [2] ConditionalAttributes.cshtml) - Html -

        + CSharpCode - (118:5,26 [6] ConditionalAttributes.cshtml) + IntermediateToken - (118:5,26 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (124:6,4 [2] ConditionalAttributes.cshtml) + IntermediateToken - (124:6,4 [2] ConditionalAttributes.cshtml) - Html -

        + CSharpCode - (146:6,26 [6] ConditionalAttributes.cshtml) + IntermediateToken - (146:6,26 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (152:7,4 [22] ConditionalAttributes.cshtml) + IntermediateToken - (152:7,4 [6] ConditionalAttributes.cshtml) - Html - + CSharpCode - (191:7,43 [6] ConditionalAttributes.cshtml) + IntermediateToken - (191:7,43 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (197:8,4 [22] ConditionalAttributes.cshtml) + IntermediateToken - (197:8,4 [6] ConditionalAttributes.cshtml) - Html - + CSharpCode - (240:8,47 [6] ConditionalAttributes.cshtml) + IntermediateToken - (240:8,47 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (246:9,4 [2] ConditionalAttributes.cshtml) + IntermediateToken - (246:9,4 [2] ConditionalAttributes.cshtml) - Html -

        + CSharpCode - (285:9,43 [6] ConditionalAttributes.cshtml) + IntermediateToken - (285:9,43 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (291:10,4 [18] ConditionalAttributes.cshtml) + IntermediateToken - (291:10,4 [2] ConditionalAttributes.cshtml) - Html - + CSharpCode - (309:10,22 [6] ConditionalAttributes.cshtml) + IntermediateToken - (309:10,22 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (315:11,4 [7] ConditionalAttributes.cshtml) + IntermediateToken - (315:11,4 [7] ConditionalAttributes.cshtml) - Html - + CSharpCode - (407:11,96 [6] ConditionalAttributes.cshtml) + IntermediateToken - (407:11,96 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (413:12,4 [7] ConditionalAttributes.cshtml) + IntermediateToken - (413:12,4 [7] ConditionalAttributes.cshtml) - Html - + CSharpCode - (521:12,112 [6] ConditionalAttributes.cshtml) + IntermediateToken - (521:12,112 [6] ConditionalAttributes.cshtml) - CSharp - \n + HtmlContent - (527:13,4 [111] ConditionalAttributes.cshtml) + IntermediateToken - (527:13,4 [7] ConditionalAttributes.cshtml) - Html - + CSharpCode - (638:13,115 [2] ConditionalAttributes.cshtml) + IntermediateToken - (638:13,115 [2] ConditionalAttributes.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt new file mode 100644 index 0000000000..688c94ed16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.mappings.txt @@ -0,0 +1,138 @@ +Source Location: (2:0,2 [48] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + var ch = true; + var cls = "bar"; + | +Generated Location: (762:19,2 [48] ) +| + var ch = true; + var cls = "bar"; + | + +Source Location: (66:3,20 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (998:29,20 [6] ) +| + | + +Source Location: (83:4,15 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|cls| +Generated Location: (1187:37,15 [3] ) +|cls| + +Source Location: (90:4,22 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (1381:44,22 [6] ) +| + | + +Source Location: (111:5,19 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|cls| +Generated Location: (1574:52,19 [3] ) +|cls| + +Source Location: (118:5,26 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (1772:59,26 [6] ) +| + | + +Source Location: (135:6,15 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|cls| +Generated Location: (1961:67,15 [3] ) +|cls| + +Source Location: (146:6,26 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (2159:74,26 [6] ) +| + | + +Source Location: (185:7,37 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|ch| +Generated Location: (2370:82,37 [2] ) +|ch| + +Source Location: (191:7,43 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (2584:89,43 [6] ) +| + | + +Source Location: (234:8,41 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|ch| +Generated Location: (2799:97,41 [2] ) +|ch| + +Source Location: (240:8,47 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (3017:104,47 [6] ) +| + | + +Source Location: (257:9,15 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|if(cls != null) { | +Generated Location: (3207:112,15 [18] ) +|if(cls != null) { | + +Source Location: (276:9,34 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|cls| +Generated Location: (3428:119,34 [3] ) +|cls| + +Source Location: (279:9,37 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| }| +Generated Location: (3638:126,37 [2] ) +| }| + +Source Location: (285:9,43 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (3852:133,43 [6] ) +| + | + +Source Location: (309:10,22 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (4049:141,22 [6] ) +| + | + +Source Location: (329:11,18 [44] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|Url.Content("~/Scripts/jquery-1.6.2.min.js")| +Generated Location: (4242:149,18 [44] ) +|Url.Content("~/Scripts/jquery-1.6.2.min.js")| + +Source Location: (407:11,96 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (4552:156,96 [6] ) +| + | + +Source Location: (427:12,18 [60] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +|Url.Content("~/Scripts/modernizr-2.0.6-development-only.js")| +Generated Location: (4745:164,18 [60] ) +|Url.Content("~/Scripts/modernizr-2.0.6-development-only.js")| + +Source Location: (521:12,112 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| + | +Generated Location: (5087:171,112 [6] ) +| + | + +Source Location: (638:13,115 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml) +| +| +Generated Location: (5377:179,115 [2] ) +| +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..af91e920b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_Runtime.codegen.cs @@ -0,0 +1,130 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f0a97e23ecfbaaaa77b528650156cb123ebdbe60" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"f0a97e23ecfbaaaa77b528650156cb123ebdbe60", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes.cshtml" + + var ch = true; + var cls = "bar"; + +#line default +#line hidden +#nullable disable + WriteLiteral(" \r\n \r\n + IntermediateToken - (66:3,20 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (68:4,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (72:4,4 [2] ConditionalAttributes.cshtml) - Html -

        + IntermediateToken - (90:4,22 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (92:5,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (96:5,4 [2] ConditionalAttributes.cshtml) - Html -

        + IntermediateToken - (118:5,26 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (120:6,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (124:6,4 [2] ConditionalAttributes.cshtml) - Html -

        + IntermediateToken - (146:6,26 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (148:7,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (152:7,4 [6] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (191:7,43 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (193:8,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (197:8,4 [6] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (240:8,47 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (242:9,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (246:9,4 [2] ConditionalAttributes.cshtml) - Html -

        + IntermediateToken - (285:9,43 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (287:10,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (291:10,4 [2] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (309:10,22 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (311:11,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (315:11,4 [7] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (407:11,96 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (409:12,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (413:12,4 [7] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (521:12,112 [2] ConditionalAttributes.cshtml) - Html - \n + IntermediateToken - (523:13,0 [4] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (527:13,4 [7] ConditionalAttributes.cshtml) - Html - + IntermediateToken - (638:13,115 [2] ConditionalAttributes.cshtml) - Html - \n + CSharpCode - (640:14,0 [0] ConditionalAttributes.cshtml) + IntermediateToken - (640:14,0 [0] ConditionalAttributes.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml new file mode 100644 index 0000000000..c71c637b14 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml @@ -0,0 +1,13 @@ +@addTagHelper "*, TestAssembly" + +2 TagHelpers. +1 TagHelper. +2 TagHelpers +2 TagHelpers +0 TagHelpers. +1 TagHelper +1 TagHelper +1 TagHelper + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..9b80cf8113 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.codegen.cs @@ -0,0 +1,250 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "385650281a1d9679c38ffc205756c3c26f6927e7" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"385650281a1d9679c38ffc205756c3c26f6927e7", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("href", new global::Microsoft.AspNetCore.Html.HtmlString("~/"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("href", new global::Microsoft.AspNetCore.Html.HtmlString("~/hello"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("href", new global::Microsoft.AspNetCore.Html.HtmlString("~/?hello=world"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("href", new global::Microsoft.AspNetCore.Html.HtmlString("~/?hello=world@false"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", new global::Microsoft.AspNetCore.Html.HtmlString("3 TagHelpers"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_6 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "texty", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_7 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_8 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", new global::Microsoft.AspNetCore.Html.HtmlString("2 TagHelper"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.ATagHelper __TestNamespace_ATagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + private global::TestNamespace.ATagHelperMultipleSelectors __TestNamespace_ATagHelperMultipleSelectors; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + private global::TestNamespace.CatchAllTagHelper2 __TestNamespace_CatchAllTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("2 TagHelpers."); + } + ); + __TestNamespace_ATagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_ATagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("1 TagHelper."); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("2 TagHelpers"); + } + ); + __TestNamespace_ATagHelperMultipleSelectors = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_ATagHelperMultipleSelectors); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("2 TagHelpers"); + } + ); + __TestNamespace_ATagHelperMultipleSelectors = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_ATagHelperMultipleSelectors); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "href", 3, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 153, "~/", 153, 2, true); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml" +AddHtmlAttributeValue("", 155, false, 155, 6, false); + +#line default +#line hidden +#nullable disable + AddHtmlAttributeValue("", 161, "?hello=world", 161, 12, true); + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n0 TagHelpers.\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("1 TagHelper"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "href", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 234, "~/", 234, 2, true); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml" +AddHtmlAttributeValue("", 236, false, 236, 6, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("1 TagHelper"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("1 TagHelper"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "href", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + AddHtmlAttributeValue("", 317, "~/?hello=world", 317, 14, true); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes.cshtml" +AddHtmlAttributeValue(" ", 331, false, 332, 6, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_CatchAllTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_CatchAllTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper2); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_6.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_CatchAllTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper2); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_7.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_7); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_8); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt new file mode 100644 index 0000000000..ef34c24d71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CssSelectorTagHelperAttributes_Runtime.ir.txt @@ -0,0 +1,137 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CssSelectorTagHelperAttributes_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - href - ~/ - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - href - ~/hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - href - ~/?hello=world - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - href - ~/?hello=world@false - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_4 - type - text - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_5 - value - 3 TagHelpers - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_6 - type - texty - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_7 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_8 - value - 2 TagHelper - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.ATagHelper - __TestNamespace_ATagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + FieldDeclaration - - private - global::TestNamespace.ATagHelperMultipleSelectors - __TestNamespace_ATagHelperMultipleSelectors + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper2 - __TestNamespace_CatchAllTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (33:1,0 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (35:2,0 [30] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (48:2,13 [13] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (48:2,13 [13] CssSelectorTagHelperAttributes.cshtml) - Html - 2 TagHelpers. + DefaultTagHelperCreate - - TestNamespace.ATagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (65:2,30 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (65:2,30 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (67:3,0 [32] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (83:3,16 [12] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (83:3,16 [12] CssSelectorTagHelperAttributes.cshtml) - Html - 1 TagHelper. + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (99:3,32 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (99:3,32 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (101:4,0 [41] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (126:4,25 [12] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (126:4,25 [12] CssSelectorTagHelperAttributes.cshtml) - Html - 2 TagHelpers + DefaultTagHelperCreate - - TestNamespace.ATagHelperMultipleSelectors + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (142:4,41 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (142:4,41 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (144:5,0 [47] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (175:5,31 [12] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (175:5,31 [12] CssSelectorTagHelperAttributes.cshtml) - Html - 2 TagHelpers + DefaultTagHelperCreate - - TestNamespace.ATagHelperMultipleSelectors + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - href - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (153:5,9 [2] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (153:5,9 [2] CssSelectorTagHelperAttributes.cshtml) - Html - ~/ + CSharpExpressionAttributeValue - (155:5,11 [6] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (156:5,12 [5] CssSelectorTagHelperAttributes.cshtml) - CSharp - false + HtmlAttributeValue - (161:5,17 [12] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (161:5,17 [12] CssSelectorTagHelperAttributes.cshtml) - Html - ?hello=world + DefaultTagHelperExecute - + HtmlContent - (191:5,47 [35] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (191:5,47 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + IntermediateToken - (193:6,0 [2] CssSelectorTagHelperAttributes.cshtml) - Html - + IntermediateToken - (207:6,14 [13] CssSelectorTagHelperAttributes.cshtml) - Html - 0 TagHelpers. + IntermediateToken - (220:6,27 [4] CssSelectorTagHelperAttributes.cshtml) - Html - + IntermediateToken - (224:6,31 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (226:7,0 [32] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (243:7,17 [11] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (243:7,17 [11] CssSelectorTagHelperAttributes.cshtml) - Html - 1 TagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - href - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (234:7,8 [2] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (234:7,8 [2] CssSelectorTagHelperAttributes.cshtml) - Html - ~/ + CSharpExpressionAttributeValue - (236:7,10 [6] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (237:7,11 [5] CssSelectorTagHelperAttributes.cshtml) - CSharp - false + DefaultTagHelperExecute - + HtmlContent - (258:7,32 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (258:7,32 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (260:8,0 [46] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (291:8,31 [11] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (291:8,31 [11] CssSelectorTagHelperAttributes.cshtml) - Html - 1 TagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + HtmlContent - (306:8,46 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (306:8,46 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (308:9,0 [47] CssSelectorTagHelperAttributes.cshtml) - a - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (340:9,32 [11] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (340:9,32 [11] CssSelectorTagHelperAttributes.cshtml) - Html - 1 TagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - href - HtmlAttributeValueStyle.SingleQuotes + HtmlAttributeValue - (317:9,9 [14] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (317:9,9 [14] CssSelectorTagHelperAttributes.cshtml) - Html - ~/?hello=world + CSharpExpressionAttributeValue - (331:9,23 [7] CssSelectorTagHelperAttributes.cshtml) - + IntermediateToken - (333:9,25 [5] CssSelectorTagHelperAttributes.cshtml) - CSharp - false + DefaultTagHelperExecute - + HtmlContent - (355:9,47 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (355:9,47 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (357:10,0 [42] CssSelectorTagHelperAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper2 + PreallocatedTagHelperProperty - (370:10,13 [4] CssSelectorTagHelperAttributes.cshtml) - __tagHelperAttribute_4 - type - Type + PreallocatedTagHelperProperty - (370:10,13 [4] CssSelectorTagHelperAttributes.cshtml) - __tagHelperAttribute_4 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + DefaultTagHelperExecute - + HtmlContent - (399:10,42 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (399:10,42 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (401:11,0 [43] CssSelectorTagHelperAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper2 + PreallocatedTagHelperProperty - (414:11,13 [5] CssSelectorTagHelperAttributes.cshtml) - __tagHelperAttribute_6 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + DefaultTagHelperExecute - + HtmlContent - (444:11,43 [2] CssSelectorTagHelperAttributes.cshtml) + IntermediateToken - (444:11,43 [2] CssSelectorTagHelperAttributes.cshtml) - Html - \n + TagHelper - (446:12,0 [45] CssSelectorTagHelperAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper2 + PreallocatedTagHelperProperty - (459:12,13 [8] CssSelectorTagHelperAttributes.cshtml) - __tagHelperAttribute_7 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_8 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml new file mode 100644 index 0000000000..5dcaeebdbf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml @@ -0,0 +1,15 @@ +

        + @for(int i = 1; i <= 10; i++) { +

        This is item #@i

        + } +
        + +

        +@(Foo(Bar.Baz)) +@Foo(@

        Bar @baz Biz

        ) +

        + +@section Footer { +

        Foo

        + @bar +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.codegen.cs new file mode 100644 index 0000000000..a3ebc4a8ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.codegen.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DesignTime_DesignTime + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" +global::System.Object Footer = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" + for(int i = 1; i <= 10; i++) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" + + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" +__o = Foo(Bar.Baz); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" +__o = Foo(item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" + __o = baz; + +#line default +#line hidden +#nullable disable +} +)); + +#line default +#line hidden +#nullable disable + DefineSection("Footer", async(__razor_section_writer) => { +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml" +__o = bar; + +#line default +#line hidden +#nullable disable + } + ); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.codegen.html new file mode 100644 index 0000000000..be5ba4979a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.codegen.html @@ -0,0 +1,15 @@ +
        + +

        This is item #

        + +
        + +

        + +

        Bar Biz

        +

        + + +

        Foo

        + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt new file mode 100644 index 0000000000..0b8f1e8e9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt @@ -0,0 +1,68 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DesignTime_DesignTime - - + DesignTimeDirective - + DirectiveToken - (173:11,9 [6] DesignTime.cshtml) - Footer + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [19] DesignTime.cshtml) + IntermediateToken - (0:0,0 [4] DesignTime.cshtml) - Html -
        + IntermediateToken - (5:0,5 [14] DesignTime.cshtml) - Html - \n + CSharpCode - (20:1,13 [36] DesignTime.cshtml) + IntermediateToken - (20:1,13 [36] DesignTime.cshtml) - CSharp - for(int i = 1; i <= 10; i++) {\n + HtmlContent - (56:2,4 [17] DesignTime.cshtml) + IntermediateToken - (56:2,4 [2] DesignTime.cshtml) - Html -

        + IntermediateToken - (59:2,7 [14] DesignTime.cshtml) - Html - This is item # + CSharpExpression - (74:2,22 [1] DesignTime.cshtml) + IntermediateToken - (74:2,22 [1] DesignTime.cshtml) - CSharp - i + HtmlContent - (75:2,23 [4] DesignTime.cshtml) + IntermediateToken - (75:2,23 [4] DesignTime.cshtml) - Html -

        + CSharpCode - (79:2,27 [15] DesignTime.cshtml) + IntermediateToken - (79:2,27 [15] DesignTime.cshtml) - CSharp - \n } + HtmlContent - (94:3,13 [17] DesignTime.cshtml) + IntermediateToken - (94:3,13 [2] DesignTime.cshtml) - Html - \n + IntermediateToken - (96:4,0 [6] DesignTime.cshtml) - Html -
        + IntermediateToken - (102:4,6 [4] DesignTime.cshtml) - Html - \n\n + IntermediateToken - (106:6,0 [2] DesignTime.cshtml) - Html -

        + IntermediateToken - (109:6,3 [2] DesignTime.cshtml) - Html - \n + CSharpExpression - (113:7,2 [12] DesignTime.cshtml) + IntermediateToken - (113:7,2 [12] DesignTime.cshtml) - CSharp - Foo(Bar.Baz) + HtmlContent - (126:7,15 [2] DesignTime.cshtml) + IntermediateToken - (126:7,15 [2] DesignTime.cshtml) - Html - \n + CSharpExpression - (129:8,1 [23] DesignTime.cshtml) + IntermediateToken - (129:8,1 [4] DesignTime.cshtml) - CSharp - Foo( + Template - (134:8,6 [18] DesignTime.cshtml) + HtmlContent - (134:8,6 [7] DesignTime.cshtml) + IntermediateToken - (134:8,6 [2] DesignTime.cshtml) - Html -

        + IntermediateToken - (137:8,9 [4] DesignTime.cshtml) - Html - Bar + CSharpExpression - (142:8,14 [3] DesignTime.cshtml) + IntermediateToken - (142:8,14 [3] DesignTime.cshtml) - CSharp - baz + HtmlContent - (145:8,17 [8] DesignTime.cshtml) + IntermediateToken - (145:8,17 [4] DesignTime.cshtml) - Html - Biz + IntermediateToken - (149:8,21 [4] DesignTime.cshtml) - Html -

        + IntermediateToken - (153:8,25 [1] DesignTime.cshtml) - CSharp - ) + HtmlContent - (154:8,26 [10] DesignTime.cshtml) + IntermediateToken - (154:8,26 [2] DesignTime.cshtml) - Html - \n + IntermediateToken - (156:9,0 [4] DesignTime.cshtml) - Html -

        + IntermediateToken - (160:9,4 [4] DesignTime.cshtml) - Html - \n\n + Section - - Footer + HtmlContent - (181:11,17 [22] DesignTime.cshtml) + IntermediateToken - (181:11,17 [6] DesignTime.cshtml) - Html - \n + IntermediateToken - (187:12,4 [2] DesignTime.cshtml) - Html -

        + IntermediateToken - (190:12,7 [3] DesignTime.cshtml) - Html - Foo + IntermediateToken - (193:12,10 [4] DesignTime.cshtml) - Html -

        + IntermediateToken - (197:12,14 [6] DesignTime.cshtml) - Html - \n + CSharpExpression - (204:13,5 [3] DesignTime.cshtml) + IntermediateToken - (204:13,5 [3] DesignTime.cshtml) - CSharp - bar + HtmlContent - (207:13,8 [2] DesignTime.cshtml) + IntermediateToken - (207:13,8 [2] DesignTime.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.mappings.txt new file mode 100644 index 0000000000..eab4e829b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.mappings.txt @@ -0,0 +1,49 @@ +Source Location: (173:11,9 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|Footer| +Generated Location: (507:12,22 [6] ) +|Footer| + +Source Location: (20:1,13 [36] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|for(int i = 1; i <= 10; i++) { + | +Generated Location: (1006:29,13 [36] ) +|for(int i = 1; i <= 10; i++) { + | + +Source Location: (74:2,22 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|i| +Generated Location: (1221:37,22 [1] ) +|i| + +Source Location: (79:2,27 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +| + }| +Generated Location: (1407:44,27 [15] ) +| + }| + +Source Location: (113:7,2 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|Foo(Bar.Baz)| +Generated Location: (1585:52,6 [12] ) +|Foo(Bar.Baz)| + +Source Location: (129:8,1 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|Foo(| +Generated Location: (1761:59,6 [4] ) +|Foo(| + +Source Location: (142:8,14 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|baz| +Generated Location: (1942:62,14 [3] ) +|baz| + +Source Location: (153:8,25 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|)| +Generated Location: (2002:68,1 [1] ) +|)| + +Source Location: (204:13,5 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime.cshtml) +|bar| +Generated Location: (2240:76,6 [3] ) +|bar| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml new file mode 100644 index 0000000000..369558994e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml @@ -0,0 +1,7 @@ +@addTagHelper "*, TestAssembly" + +

        + + + +

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..2075afda99 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "button"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "button"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "button"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = 3; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..63264fc10d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt @@ -0,0 +1,96 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] DuplicateAttributeTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] DuplicateAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (35:2,0 [259] DuplicateAttributeTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (65:2,30 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (65:2,30 [6] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (71:3,4 [39] DuplicateAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) - Html - button + DefaultTagHelperProperty - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) - Html - button + DefaultTagHelperHtmlAttribute - - TYPE - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (98:3,31 [8] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (98:3,31 [8] DuplicateAttributeTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperExecute - + HtmlContent - (110:3,43 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (110:3,43 [6] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (116:4,4 [70] DuplicateAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) - Html - button + DefaultTagHelperProperty - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) - Html - button + DefaultTagHelperProperty - (146:4,34 [4] DuplicateAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (146:4,34 [4] DuplicateAttributeTagHelpers.cshtml) - CSharp - true + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (158:4,46 [8] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (158:4,46 [8] DuplicateAttributeTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperHtmlAttribute - - checked - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (177:4,65 [5] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (177:4,65 [5] DuplicateAttributeTagHelpers.cshtml) - Html - false + DefaultTagHelperExecute - + HtmlContent - (186:4,74 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (186:4,74 [6] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (192:5,4 [96] DuplicateAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) - Html - button + DefaultTagHelperProperty - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) - Html - button + DefaultTagHelperProperty - (222:5,34 [4] DuplicateAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (222:5,34 [4] DuplicateAttributeTagHelpers.cshtml) - CSharp - true + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (233:5,45 [8] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (233:5,45 [8] DuplicateAttributeTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperHtmlAttribute - - checked - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (251:5,63 [4] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (251:5,63 [4] DuplicateAttributeTagHelpers.cshtml) - Html - true + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (263:5,75 [8] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (263:5,75 [8] DuplicateAttributeTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperHtmlAttribute - - checked - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (281:5,93 [4] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (281:5,93 [4] DuplicateAttributeTagHelpers.cshtml) - Html - true + DefaultTagHelperExecute - + HtmlContent - (288:5,100 [2] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (288:5,100 [2] DuplicateAttributeTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (43:2,8 [1] DuplicateAttributeTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (43:2,8 [1] DuplicateAttributeTagHelpers.cshtml) - CSharp - 3 + DefaultTagHelperHtmlAttribute - - AGE - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (51:2,16 [2] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (51:2,16 [2] DuplicateAttributeTagHelpers.cshtml) - Html - 40 + DefaultTagHelperHtmlAttribute - - Age - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (60:2,25 [3] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (60:2,25 [3] DuplicateAttributeTagHelpers.cshtml) - Html - 500 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..f59f79018f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1217:20,37 [17] ) +|"*, TestAssembly"| + +Source Location: (146:4,34 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml) +|true| +Generated Location: (2558:46,42 [4] ) +|true| + +Source Location: (222:5,34 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml) +|true| +Generated Location: (3214:58,42 [4] ) +|true| + +Source Location: (43:2,8 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml) +|3| +Generated Location: (3598:67,33 [1] ) +|3| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..d15f5b0ca3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.codegen.cs @@ -0,0 +1,154 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4dc2ea6fc4bd045c34a90867a6a72183a3d01323" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4dc2ea6fc4bd045c34a90867a6a72183a3d01323", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "button", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("TYPE", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("checked", new global::Microsoft.AspNetCore.Html.HtmlString("false"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "button", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("checked", new global::Microsoft.AspNetCore.Html.HtmlString("true"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_6 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("checked", new global::Microsoft.AspNetCore.Html.HtmlString("true"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_7 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("AGE", new global::Microsoft.AspNetCore.Html.HtmlString("40"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_8 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("Age", new global::Microsoft.AspNetCore.Html.HtmlString("500"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_6); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = 3; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_7); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_8); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..f2e84ead91 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_Runtime.ir.txt @@ -0,0 +1,69 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - button - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - TYPE - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - checked - false - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_4 - type - button - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_5 - checked - true - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_6 - checked - true - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_7 - AGE - 40 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_8 - Age - 500 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (35:2,0 [259] DuplicateAttributeTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (65:2,30 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (65:2,30 [6] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (71:3,4 [39] DuplicateAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (84:3,17 [6] DuplicateAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (110:3,43 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (110:3,43 [6] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (116:4,4 [70] DuplicateAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (129:4,17 [6] DuplicateAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + DefaultTagHelperProperty - (146:4,34 [4] DuplicateAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (146:4,34 [4] DuplicateAttributeTagHelpers.cshtml) - CSharp - true + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + HtmlContent - (186:4,74 [6] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (186:4,74 [6] DuplicateAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (192:5,4 [96] DuplicateAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) - __tagHelperAttribute_4 - type - Type + PreallocatedTagHelperProperty - (205:5,17 [6] DuplicateAttributeTagHelpers.cshtml) - __tagHelperAttribute_4 - type - Type + DefaultTagHelperProperty - (222:5,34 [4] DuplicateAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (222:5,34 [4] DuplicateAttributeTagHelpers.cshtml) - CSharp - true + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_6 + DefaultTagHelperExecute - + HtmlContent - (288:5,100 [2] DuplicateAttributeTagHelpers.cshtml) + IntermediateToken - (288:5,100 [2] DuplicateAttributeTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (43:2,8 [1] DuplicateAttributeTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (43:2,8 [1] DuplicateAttributeTagHelpers.cshtml) - CSharp - 3 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_7 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_8 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml new file mode 100644 index 0000000000..9963a14d5e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml @@ -0,0 +1,3 @@ +@addTagHelper "*, TestAssembly" + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..976fa497d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.codegen.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_DesignTime + { + #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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "checkbox"; + __TestNamespace_CatchAllTagHelper.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml" +__TestNamespace_InputTagHelper.Checked = true; + +#line default +#line hidden +#nullable disable + __TestNamespace_CatchAllTagHelper.Checked = __TestNamespace_InputTagHelper.Checked; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..2ea133100c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] DuplicateTargetTagHelper.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] DuplicateTargetTagHelper.cshtml) + IntermediateToken - (31:0,31 [4] DuplicateTargetTagHelper.cshtml) - Html - \n\n + TagHelper - (35:2,0 [40] DuplicateTargetTagHelper.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) + IntermediateToken - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) - Html - checkbox + DefaultTagHelperProperty - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) - type - string TestNamespace.CatchAllTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) + IntermediateToken - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) - Html - checkbox + DefaultTagHelperProperty - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - checked - bool TestNamespace.InputTagHelper.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - CSharp - true + DefaultTagHelperProperty - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - checked - bool TestNamespace.CatchAllTagHelper.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - CSharp - true + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..b4d7ec361d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml) +|"*, TestAssembly"| +Generated Location: (1135:19,37 [17] ) +|"*, TestAssembly"| + +Source Location: (67:2,32 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml) +|true| +Generated Location: (2045:40,41 [4] ) +|true| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..85a97f8875 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.codegen.cs @@ -0,0 +1,69 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "97a60a6d99646ce1d67aab46447cc8f582f6f03a" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"97a60a6d99646ce1d67aab46447cc8f582f6f03a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "checkbox", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_CatchAllTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper.cshtml" +__TestNamespace_InputTagHelper.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_CatchAllTagHelper.Checked = __TestNamespace_InputTagHelper.Checked; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..d86a4d2b8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateTargetTagHelper_Runtime.ir.txt @@ -0,0 +1,23 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateTargetTagHelper_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] DuplicateTargetTagHelper.cshtml) + IntermediateToken - (33:1,0 [2] DuplicateTargetTagHelper.cshtml) - Html - \n + TagHelper - (35:2,0 [40] DuplicateTargetTagHelper.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperProperty - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (48:2,13 [8] DuplicateTargetTagHelper.cshtml) - __tagHelperAttribute_0 - type - Type + DefaultTagHelperProperty - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - checked - bool TestNamespace.InputTagHelper.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - CSharp - true + DefaultTagHelperProperty - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - checked - bool TestNamespace.CatchAllTagHelper.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (67:2,32 [4] DuplicateTargetTagHelper.cshtml) - CSharp - true + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml new file mode 100644 index 0000000000..5e69ed1d81 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml @@ -0,0 +1,14 @@ +@addTagHelper "*, TestAssembly" + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..0d54c019c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,262 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_DesignTime + { + #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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_InputTagHelper = CreateTagHelper(); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = string.Empty; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = false; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Bound = string.Empty; +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = long.MinValue; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = string.Empty; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = false; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = int.MaxValue; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Bound = string.Empty; +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = long.MinValue; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = string.Empty; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = false; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = int.MaxValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = long.MinValue; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = int.MaxValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = string.Empty; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + __o = false; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..76f7d9c916 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt @@ -0,0 +1,133 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] DynamicAttributeTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (35:2,0 [40] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (51:2,16 [6] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (51:2,16 [6] DynamicAttributeTagHelpers.cshtml) - Html - prefix + CSharpExpressionAttributeValue - (57:2,22 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (59:2,24 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperExecute - + HtmlContent - (75:2,40 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (75:2,40 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (79:4,0 [71] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpCodeAttributeValue - (95:4,16 [44] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (96:4,17 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (109:4,30 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (109:4,30 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + IntermediateToken - (121:4,42 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (132:4,53 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (132:4,53 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + IntermediateToken - (137:4,58 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + HtmlAttributeValue - (139:4,60 [7] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (140:4,61 [6] DynamicAttributeTagHelpers.cshtml) - Html - suffix + DefaultTagHelperExecute - + HtmlContent - (150:4,71 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (150:4,71 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (154:6,0 [83] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperProperty - (168:6,14 [27] DynamicAttributeTagHelpers.cshtml) - bound - string TestNamespace.InputTagHelper.Bound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (168:6,14 [7] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (168:6,14 [6] DynamicAttributeTagHelpers.cshtml) - Html - prefix + IntermediateToken - (174:6,20 [1] DynamicAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (176:6,22 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (176:6,22 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlContent - (188:6,34 [7] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (188:6,34 [7] DynamicAttributeTagHelpers.cshtml) - Html - suffix + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (206:6,52 [6] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (206:6,52 [6] DynamicAttributeTagHelpers.cshtml) - Html - prefix + CSharpExpressionAttributeValue - (212:6,58 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (214:6,60 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlAttributeValue - (226:6,72 [7] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (227:6,73 [6] DynamicAttributeTagHelpers.cshtml) - Html - suffix + DefaultTagHelperExecute - + HtmlContent - (237:6,83 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (237:6,83 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (241:8,0 [183] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperProperty - (255:8,14 [73] DynamicAttributeTagHelpers.cshtml) - bound - string TestNamespace.InputTagHelper.Bound - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (256:8,15 [13] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (256:8,15 [13] DynamicAttributeTagHelpers.cshtml) - CSharp - long.MinValue + HtmlContent - (269:8,28 [1] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (269:8,28 [1] DynamicAttributeTagHelpers.cshtml) - Html - + CSharpCode - (271:8,30 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (271:8,30 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (284:8,43 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (284:8,43 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + CSharpCode - (296:8,55 [10] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (296:8,55 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (307:8,66 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (307:8,66 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + CSharpCode - (312:8,71 [2] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (312:8,71 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + HtmlContent - (314:8,73 [1] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (314:8,73 [1] DynamicAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (316:8,75 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (316:8,75 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - int.MaxValue + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpressionAttributeValue - (347:9,16 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (348:9,17 [13] DynamicAttributeTagHelpers.cshtml) - CSharp - long.MinValue + CSharpCodeAttributeValue - (361:9,30 [45] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (363:9,32 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (376:9,45 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (376:9,45 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + IntermediateToken - (388:9,57 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (399:9,68 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (399:9,68 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + IntermediateToken - (404:9,73 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + CSharpExpressionAttributeValue - (406:9,75 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (408:9,77 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - int.MaxValue + DefaultTagHelperExecute - + HtmlContent - (424:9,93 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (424:9,93 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (428:11,0 [80] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpressionAttributeValue - (444:11,16 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (445:11,17 [13] DynamicAttributeTagHelpers.cshtml) - CSharp - long.MinValue + CSharpExpressionAttributeValue - (458:11,30 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (460:11,32 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlAttributeValue - (472:11,44 [7] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (473:11,45 [6] DynamicAttributeTagHelpers.cshtml) - Html - static + HtmlAttributeValue - (479:11,51 [11] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (483:11,55 [7] DynamicAttributeTagHelpers.cshtml) - Html - content + CSharpExpressionAttributeValue - (490:11,62 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (492:11,64 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - int.MaxValue + DefaultTagHelperExecute - + HtmlContent - (508:11,80 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (508:11,80 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (512:13,0 [64] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpCodeAttributeValue - (528:13,16 [44] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (529:13,17 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (542:13,30 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (542:13,30 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + IntermediateToken - (554:13,42 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (565:13,53 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (565:13,53 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + IntermediateToken - (570:13,58 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..27ed6fbeb7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,155 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1047:18,37 [17] ) +|"*, TestAssembly"| + +Source Location: (59:2,24 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (1679:36,24 [12] ) +|DateTime.Now| + +Source Location: (96:4,17 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|if (true) { | +Generated Location: (2061:45,17 [12] ) +|if (true) { | + +Source Location: (109:4,30 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|string.Empty| +Generated Location: (2276:52,30 [12] ) +|string.Empty| + +Source Location: (121:4,42 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| } else { | +Generated Location: (2504:59,42 [10] ) +| } else { | + +Source Location: (132:4,53 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|false| +Generated Location: (2740:66,53 [5] ) +|false| + +Source Location: (137:4,58 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| }| +Generated Location: (2977:73,58 [2] ) +| }| + +Source Location: (176:6,22 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (3353:82,22 [12] ) +|DateTime.Now| + +Source Location: (214:6,60 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (3665:90,60 [12] ) +|DateTime.Now| + +Source Location: (256:8,15 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|long.MinValue| +Generated Location: (4045:99,15 [13] ) +|long.MinValue| + +Source Location: (271:8,30 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|if (true) { | +Generated Location: (4262:106,30 [12] ) +|if (true) { | + +Source Location: (284:8,43 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|string.Empty| +Generated Location: (4490:113,43 [12] ) +|string.Empty| + +Source Location: (296:8,55 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| } else { | +Generated Location: (4731:120,55 [10] ) +| } else { | + +Source Location: (307:8,66 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|false| +Generated Location: (4980:127,66 [5] ) +|false| + +Source Location: (312:8,71 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| }| +Generated Location: (5230:134,71 [2] ) +| }| + +Source Location: (316:8,75 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|int.MaxValue| +Generated Location: (5480:141,75 [12] ) +|int.MaxValue| + +Source Location: (348:9,17 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|long.MinValue| +Generated Location: (5750:149,17 [13] ) +|long.MinValue| + +Source Location: (363:9,32 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|if (true) { | +Generated Location: (5970:156,32 [12] ) +|if (true) { | + +Source Location: (376:9,45 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|string.Empty| +Generated Location: (6201:163,45 [12] ) +|string.Empty| + +Source Location: (388:9,57 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| } else { | +Generated Location: (6445:170,57 [10] ) +| } else { | + +Source Location: (399:9,68 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|false| +Generated Location: (6697:177,68 [5] ) +|false| + +Source Location: (404:9,73 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| }| +Generated Location: (6950:184,73 [2] ) +| }| + +Source Location: (408:9,77 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|int.MaxValue| +Generated Location: (7203:191,77 [12] ) +|int.MaxValue| + +Source Location: (445:11,17 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|long.MinValue| +Generated Location: (7586:200,17 [13] ) +|long.MinValue| + +Source Location: (460:11,32 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (7806:207,32 [12] ) +|DateTime.Now| + +Source Location: (492:11,64 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|int.MaxValue| +Generated Location: (8057:214,64 [12] ) +|int.MaxValue| + +Source Location: (529:13,17 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|if (true) { | +Generated Location: (8440:223,17 [12] ) +|if (true) { | + +Source Location: (542:13,30 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|string.Empty| +Generated Location: (8656:230,30 [12] ) +|string.Empty| + +Source Location: (554:13,42 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| } else { | +Generated Location: (8885:237,42 [10] ) +| } else { | + +Source Location: (565:13,53 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +|false| +Generated Location: (9122:244,53 [5] ) +|false| + +Source Location: (570:13,58 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml) +| }| +Generated Location: (9360:251,58 [2] ) +| }| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..ddf57bb8cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.codegen.cs @@ -0,0 +1,372 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "42f11f2c52ff2e658e61f6c5caace4347c07ca48" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"42f11f2c52ff2e658e61f6c5caace4347c07ca48", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unbound", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 51, "prefix", 51, 6, true); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue(" ", 57, DateTime.Now, 58, 13, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unbound", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 95, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => { + PushWriter(__razor_attribute_value_writer); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + Write(string.Empty); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + Write(false); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + PopWriter(); + } + ), 95, 44, false); + AddHtmlAttributeValue(" ", 139, "suffix", 140, 7, true); + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + BeginWriteTagHelperAttribute(); + WriteLiteral("prefix "); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + WriteLiteral(DateTime.Now); + +#line default +#line hidden +#nullable disable + WriteLiteral(" suffix"); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper.Bound = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("bound", __TestNamespace_InputTagHelper.Bound, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unbound", 3, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 206, "prefix", 206, 6, true); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue(" ", 212, DateTime.Now, 213, 13, false); + +#line default +#line hidden +#nullable disable + AddHtmlAttributeValue(" ", 226, "suffix", 227, 7, true); + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + WriteLiteral(long.MinValue); + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + WriteLiteral(string.Empty); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + WriteLiteral(false); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + WriteLiteral(int.MaxValue); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper.Bound = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("bound", __TestNamespace_InputTagHelper.Bound, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unbound", 3, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue("", 347, long.MinValue, 347, 14, false); + +#line default +#line hidden +#nullable disable + AddHtmlAttributeValue(" ", 361, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => { + PushWriter(__razor_attribute_value_writer); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + Write(string.Empty); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + Write(false); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + PopWriter(); + } + ), 362, 44, false); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue(" ", 406, int.MaxValue, 407, 13, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unbound", 5, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue("", 444, long.MinValue, 444, 14, false); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue(" ", 458, DateTime.Now, 459, 13, false); + +#line default +#line hidden +#nullable disable + AddHtmlAttributeValue(" ", 472, "static", 473, 7, true); + AddHtmlAttributeValue(" ", 479, "content", 483, 11, true); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" +AddHtmlAttributeValue(" ", 490, int.MaxValue, 491, 13, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unbound", 1, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 528, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => { + PushWriter(__razor_attribute_value_writer); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + Write(string.Empty); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } else { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + Write(false); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + PopWriter(); + } + ), 528, 44, false); + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..72a0832670 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_Runtime.ir.txt @@ -0,0 +1,127 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_Runtime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] DynamicAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (35:2,0 [40] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (51:2,16 [6] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (51:2,16 [6] DynamicAttributeTagHelpers.cshtml) - Html - prefix + CSharpExpressionAttributeValue - (57:2,22 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (59:2,24 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperExecute - + HtmlContent - (75:2,40 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (75:2,40 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (79:4,0 [71] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpCodeAttributeValue - (95:4,16 [44] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (96:4,17 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (109:4,30 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (109:4,30 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + IntermediateToken - (121:4,42 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (132:4,53 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (132:4,53 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + IntermediateToken - (137:4,58 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + HtmlAttributeValue - (139:4,60 [7] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (140:4,61 [6] DynamicAttributeTagHelpers.cshtml) - Html - suffix + DefaultTagHelperExecute - + HtmlContent - (150:4,71 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (150:4,71 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (154:6,0 [83] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperProperty - (168:6,14 [27] DynamicAttributeTagHelpers.cshtml) - bound - string TestNamespace.InputTagHelper.Bound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (168:6,14 [7] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (168:6,14 [6] DynamicAttributeTagHelpers.cshtml) - Html - prefix + IntermediateToken - (174:6,20 [1] DynamicAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (176:6,22 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (176:6,22 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlContent - (188:6,34 [7] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (188:6,34 [7] DynamicAttributeTagHelpers.cshtml) - Html - suffix + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (206:6,52 [6] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (206:6,52 [6] DynamicAttributeTagHelpers.cshtml) - Html - prefix + CSharpExpressionAttributeValue - (212:6,58 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (214:6,60 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlAttributeValue - (226:6,72 [7] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (227:6,73 [6] DynamicAttributeTagHelpers.cshtml) - Html - suffix + DefaultTagHelperExecute - + HtmlContent - (237:6,83 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (237:6,83 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (241:8,0 [183] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperProperty - (255:8,14 [73] DynamicAttributeTagHelpers.cshtml) - bound - string TestNamespace.InputTagHelper.Bound - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (256:8,15 [13] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (256:8,15 [13] DynamicAttributeTagHelpers.cshtml) - CSharp - long.MinValue + HtmlContent - (269:8,28 [1] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (269:8,28 [1] DynamicAttributeTagHelpers.cshtml) - Html - + CSharpCode - (271:8,30 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (271:8,30 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (284:8,43 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (284:8,43 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + CSharpCode - (296:8,55 [10] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (296:8,55 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (307:8,66 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (307:8,66 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + CSharpCode - (312:8,71 [2] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (312:8,71 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + HtmlContent - (314:8,73 [1] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (314:8,73 [1] DynamicAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (316:8,75 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (316:8,75 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - int.MaxValue + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpressionAttributeValue - (347:9,16 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (348:9,17 [13] DynamicAttributeTagHelpers.cshtml) - CSharp - long.MinValue + CSharpCodeAttributeValue - (361:9,30 [45] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (363:9,32 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (376:9,45 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (376:9,45 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + IntermediateToken - (388:9,57 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (399:9,68 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (399:9,68 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + IntermediateToken - (404:9,73 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + CSharpExpressionAttributeValue - (406:9,75 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (408:9,77 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - int.MaxValue + DefaultTagHelperExecute - + HtmlContent - (424:9,93 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (424:9,93 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (428:11,0 [80] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpressionAttributeValue - (444:11,16 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (445:11,17 [13] DynamicAttributeTagHelpers.cshtml) - CSharp - long.MinValue + CSharpExpressionAttributeValue - (458:11,30 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (460:11,32 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlAttributeValue - (472:11,44 [7] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (473:11,45 [6] DynamicAttributeTagHelpers.cshtml) - Html - static + HtmlAttributeValue - (479:11,51 [11] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (483:11,55 [7] DynamicAttributeTagHelpers.cshtml) - Html - content + CSharpExpressionAttributeValue - (490:11,62 [14] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (492:11,64 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - int.MaxValue + DefaultTagHelperExecute - + HtmlContent - (508:11,80 [4] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (508:11,80 [4] DynamicAttributeTagHelpers.cshtml) - Html - \n\n + TagHelper - (512:13,0 [64] DynamicAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + CSharpCodeAttributeValue - (528:13,16 [44] DynamicAttributeTagHelpers.cshtml) - + IntermediateToken - (529:13,17 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - if (true) { + CSharpExpression - (542:13,30 [12] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (542:13,30 [12] DynamicAttributeTagHelpers.cshtml) - CSharp - string.Empty + IntermediateToken - (554:13,42 [10] DynamicAttributeTagHelpers.cshtml) - CSharp - } else { + CSharpExpression - (565:13,53 [5] DynamicAttributeTagHelpers.cshtml) + IntermediateToken - (565:13,53 [5] DynamicAttributeTagHelpers.cshtml) - CSharp - false + IntermediateToken - (570:13,58 [2] DynamicAttributeTagHelpers.cshtml) - CSharp - } + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml new file mode 100644 index 0000000000..d68f666f72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml @@ -0,0 +1,8 @@ +@addTagHelper *, TestAssembly + +
        + +

        + +

        +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..5b039be663 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_DesignTime + { + #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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + private global::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = ""; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = ; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = ""; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = ; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = ; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..0b20997aff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.diagnostics.txt @@ -0,0 +1,3 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ2008: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..2f02db5b87 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt @@ -0,0 +1,68 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] EmptyAttributeTagHelpers.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [15] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (29:0,29 [4] EmptyAttributeTagHelpers.cshtml) - Html - \n\n + IntermediateToken - (33:2,0 [4] EmptyAttributeTagHelpers.cshtml) - Html -
        + IntermediateToken - (38:2,5 [6] EmptyAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (44:3,4 [34] EmptyAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) - Html - + DefaultTagHelperProperty - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) - Html - + DefaultTagHelperProperty - (66:3,26 [0] EmptyAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (66:3,26 [0] EmptyAttributeTagHelpers.cshtml) - CSharp - + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (74:3,34 [0] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (74:3,34 [0] EmptyAttributeTagHelpers.cshtml) - Html - + DefaultTagHelperExecute - + HtmlContent - (78:3,38 [6] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (78:3,38 [6] EmptyAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (84:4,4 [64] EmptyAttributeTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (94:4,14 [10] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (94:4,14 [10] EmptyAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (104:5,8 [34] EmptyAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) - Html - + DefaultTagHelperProperty - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) - Html - + DefaultTagHelperProperty - (126:5,30 [0] EmptyAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (126:5,30 [0] EmptyAttributeTagHelpers.cshtml) - CSharp - + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (134:5,38 [0] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (134:5,38 [0] EmptyAttributeTagHelpers.cshtml) - Html - + DefaultTagHelperExecute - + HtmlContent - (138:5,42 [6] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (138:5,42 [6] EmptyAttributeTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (92:4,12 [0] EmptyAttributeTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.SingleQuotes + IntermediateToken - (92:4,12 [0] EmptyAttributeTagHelpers.cshtml) - CSharp - + DefaultTagHelperExecute - + HtmlContent - (148:6,8 [8] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (148:6,8 [2] EmptyAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (150:7,0 [6] EmptyAttributeTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..cc280e4a93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml) +|*, TestAssembly| +Generated Location: (1210:20,38 [15] ) +|*, TestAssembly| + +Source Location: (66:3,26 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml) +|| +Generated Location: (2106:41,42 [0] ) +|| + +Source Location: (126:5,30 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml) +|| +Generated Location: (2748:53,42 [0] ) +|| + +Source Location: (92:4,12 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml) +|| +Generated Location: (3124:62,33 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..96c6a32b45 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.codegen.cs @@ -0,0 +1,122 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9c86b0d6e2a590a85271afa26a21f39597a68e3f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"9c86b0d6e2a590a85271afa26a21f39597a68e3f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString(""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + private global::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n
        \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = ; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = ; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml" +__TestNamespace_PTagHelper.Age = ; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt new file mode 100644 index 0000000000..0b20997aff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.diagnostics.txt @@ -0,0 +1,3 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(4,18): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(5,8): Error RZ2008: Attribute 'age' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers.cshtml(6,23): Error RZ2008: Attribute 'checked' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..19769026c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_Runtime.ir.txt @@ -0,0 +1,52 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:1,0 [13] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (31:1,0 [2] EmptyAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (33:2,0 [4] EmptyAttributeTagHelpers.cshtml) - Html -
        + IntermediateToken - (38:2,5 [6] EmptyAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (44:3,4 [34] EmptyAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (56:3,16 [0] EmptyAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + DefaultTagHelperProperty - (66:3,26 [0] EmptyAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (66:3,26 [0] EmptyAttributeTagHelpers.cshtml) - CSharp - + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (78:3,38 [6] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (78:3,38 [6] EmptyAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (84:4,4 [64] EmptyAttributeTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (94:4,14 [10] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (94:4,14 [10] EmptyAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (104:5,8 [34] EmptyAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + PreallocatedTagHelperProperty - (117:5,21 [0] EmptyAttributeTagHelpers.cshtml) - __tagHelperAttribute_0 - type - Type + DefaultTagHelperProperty - (126:5,30 [0] EmptyAttributeTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (126:5,30 [0] EmptyAttributeTagHelpers.cshtml) - CSharp - + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (138:5,42 [6] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (138:5,42 [6] EmptyAttributeTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (92:4,12 [0] EmptyAttributeTagHelpers.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.SingleQuotes + IntermediateToken - (92:4,12 [0] EmptyAttributeTagHelpers.cshtml) - CSharp - + DefaultTagHelperExecute - + HtmlContent - (148:6,8 [8] EmptyAttributeTagHelpers.cshtml) + IntermediateToken - (148:6,8 [2] EmptyAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (150:7,0 [6] EmptyAttributeTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml new file mode 100644 index 0000000000..0366199cd5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml @@ -0,0 +1,3 @@ +This is markup + +@{} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs new file mode 100644 index 0000000000..147fb7b23a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.html new file mode 100644 index 0000000000..9ebe0e3a78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.codegen.html @@ -0,0 +1,3 @@ +This is markup + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt new file mode 100644 index 0000000000..1da8246eee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] EmptyCodeBlock.cshtml) + IntermediateToken - (0:0,0 [18] EmptyCodeBlock.cshtml) - Html - This is markup\n\n + CSharpCode - (20:2,2 [0] EmptyCodeBlock.cshtml) + IntermediateToken - (20:2,2 [0] EmptyCodeBlock.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt new file mode 100644 index 0000000000..c2efdcaf76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (20:2,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml) +|| +Generated Location: (748:19,2 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs new file mode 100644 index 0000000000..d7513d8023 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.codegen.cs @@ -0,0 +1,19 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "fdc98942fed24e572b86269f89a808b0c606cef1" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"fdc98942fed24e572b86269f89a808b0c606cef1", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("This is markup\r\n\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt new file mode 100644 index 0000000000..75e7307e0f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] EmptyCodeBlock.cshtml) + IntermediateToken - (0:0,0 [18] EmptyCodeBlock.cshtml) - Html - This is markup\n\n + CSharpCode - (20:2,2 [0] EmptyCodeBlock.cshtml) + IntermediateToken - (20:2,2 [0] EmptyCodeBlock.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml new file mode 100644 index 0000000000..6790c7eba2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml @@ -0,0 +1,3 @@ +This is markup + +@() \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.codegen.cs new file mode 100644 index 0000000000..a4e6956477 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml" +__o = ; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.codegen.html new file mode 100644 index 0000000000..9ebe0e3a78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.codegen.html @@ -0,0 +1,3 @@ +This is markup + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt new file mode 100644 index 0000000000..cca09001e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] EmptyExplicitExpression.cshtml) + IntermediateToken - (0:0,0 [18] EmptyExplicitExpression.cshtml) - Html - This is markup\n\n + CSharpExpression - (20:2,2 [0] EmptyExplicitExpression.cshtml) + IntermediateToken - (20:2,2 [0] EmptyExplicitExpression.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.mappings.txt new file mode 100644 index 0000000000..3f7d10ade3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (20:2,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml) +|| +Generated Location: (770:19,6 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs new file mode 100644 index 0000000000..60274099a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.codegen.cs @@ -0,0 +1,26 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "25dc9cf13110b5af9a1ca31a8f02abdc45a37244" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"25dc9cf13110b5af9a1ca31a8f02abdc45a37244", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("This is markup\r\n\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml" +Write(); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt new file mode 100644 index 0000000000..c3daa8feb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] EmptyExplicitExpression.cshtml) + IntermediateToken - (0:0,0 [18] EmptyExplicitExpression.cshtml) - Html - This is markup\n\n + CSharpExpression - (20:2,2 [0] EmptyExplicitExpression.cshtml) + IntermediateToken - (20:2,2 [0] EmptyExplicitExpression.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml new file mode 100644 index 0000000000..021306da6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml @@ -0,0 +1,3 @@ +This is markup + +@! \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml new file mode 100644 index 0000000000..a1db8cd602 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml @@ -0,0 +1,3 @@ +@{ + @ +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs new file mode 100644 index 0000000000..eaaeed80bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" +__o = ; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.html new file mode 100644 index 0000000000..1568f6aa34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.codegen.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..84ac278f6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt new file mode 100644 index 0000000000..d167e2f6b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) + IntermediateToken - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n + CSharpExpression - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml) + IntermediateToken - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml) - CSharp - + CSharpCode - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) + IntermediateToken - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt new file mode 100644 index 0000000000..9ba6343fc1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml) +| + | +Generated Location: (778:19,2 [6] ) +| + | + +Source Location: (9:1,5 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml) +|| +Generated Location: (966:27,6 [0] ) +|| + +Source Location: (9:1,5 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml) +| +| +Generated Location: (1148:34,5 [2] ) +| +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs new file mode 100644 index 0000000000..fb302c2676 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.codegen.cs @@ -0,0 +1,25 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf754c5b319ea54f6c9636bd2815d4b47d11886d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"bf754c5b319ea54f6c9636bd2815d4b47d11886d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml" +Write(); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt new file mode 100644 index 0000000000..84ac278f6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt new file mode 100644 index 0000000000..b910f3841c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.ir.txt @@ -0,0 +1,12 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) + IntermediateToken - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n + CSharpExpression - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml) + IntermediateToken - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml) - CSharp - + CSharpCode - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) + IntermediateToken - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.codegen.cs new file mode 100644 index 0000000000..cccfe56121 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml" +__o = ; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.codegen.html new file mode 100644 index 0000000000..76ee36910b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.codegen.html @@ -0,0 +1,3 @@ +This is markup + + ! \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..5524460d0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt new file mode 100644 index 0000000000..60189098dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] EmptyImplicitExpression.cshtml) + IntermediateToken - (0:0,0 [18] EmptyImplicitExpression.cshtml) - Html - This is markup\n\n + CSharpExpression - (19:2,1 [0] EmptyImplicitExpression.cshtml) + IntermediateToken - (19:2,1 [0] EmptyImplicitExpression.cshtml) - CSharp - + HtmlContent - (19:2,1 [1] EmptyImplicitExpression.cshtml) + IntermediateToken - (19:2,1 [1] EmptyImplicitExpression.cshtml) - Html - ! diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.mappings.txt new file mode 100644 index 0000000000..d3539655ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (19:2,1 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml) +|| +Generated Location: (770:19,6 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs new file mode 100644 index 0000000000..9506f47a3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.codegen.cs @@ -0,0 +1,27 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4c215c8ff3e726be334183020106682e47cf8ace" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4c215c8ff3e726be334183020106682e47cf8ace", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("This is markup\r\n\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml" +Write(); + +#line default +#line hidden +#nullable disable + WriteLiteral("!"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt new file mode 100644 index 0000000000..5524460d0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt new file mode 100644 index 0000000000..e4187049bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.ir.txt @@ -0,0 +1,12 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] EmptyImplicitExpression.cshtml) + IntermediateToken - (0:0,0 [18] EmptyImplicitExpression.cshtml) - Html - This is markup\n\n + CSharpExpression - (19:2,1 [0] EmptyImplicitExpression.cshtml) + IntermediateToken - (19:2,1 [0] EmptyImplicitExpression.cshtml) - CSharp - + HtmlContent - (19:2,1 [1] EmptyImplicitExpression.cshtml) + IntermediateToken - (19:2,1 [1] EmptyImplicitExpression.cshtml) - Html - ! diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml new file mode 100644 index 0000000000..d949682156 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml @@ -0,0 +1,11 @@ +@addTagHelper "*, TestAssembly" + +@{ + var enumValue = MyEnum.MyValue; +} + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..87e16e675a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,111 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_DesignTime + { + #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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" + + var enumValue = MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" + __o = MyEnum.MySecondValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MySecondValue; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_CatchAllTagHelper.CatchAll = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = enumValue; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_CatchAllTagHelper.CatchAll = enumValue; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..2418da2ba7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt @@ -0,0 +1,74 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] EnumTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] EnumTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] EnumTagHelpers.cshtml) - Html - \n\n + CSharpCode - (37:2,2 [39] EnumTagHelpers.cshtml) + IntermediateToken - (37:2,2 [39] EnumTagHelpers.cshtml) - CSharp - \n var enumValue = MyEnum.MyValue;\n + HtmlContent - (79:5,0 [2] EnumTagHelpers.cshtml) + IntermediateToken - (79:5,0 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (81:6,0 [33] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (95:6,14 [15] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (96:6,15 [14] EnumTagHelpers.cshtml) + IntermediateToken - (96:6,15 [14] EnumTagHelpers.cshtml) - CSharp - MyEnum.MyValue + DefaultTagHelperExecute - + HtmlContent - (114:6,33 [2] EnumTagHelpers.cshtml) + IntermediateToken - (114:6,33 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (116:7,0 [39] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpressionAttributeValue - (130:7,14 [21] EnumTagHelpers.cshtml) - + IntermediateToken - (131:7,15 [20] EnumTagHelpers.cshtml) - CSharp - MyEnum.MySecondValue + DefaultTagHelperExecute - + HtmlContent - (155:7,39 [2] EnumTagHelpers.cshtml) + IntermediateToken - (155:7,39 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (157:8,0 [25] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (171:8,14 [7] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (171:8,14 [7] EnumTagHelpers.cshtml) - CSharp - MyValue + DefaultTagHelperExecute - + HtmlContent - (182:8,25 [2] EnumTagHelpers.cshtml) + IntermediateToken - (182:8,25 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (184:9,0 [50] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (198:9,14 [13] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (198:9,14 [13] EnumTagHelpers.cshtml) - CSharp - MySecondValue + DefaultTagHelperProperty - (224:9,40 [7] EnumTagHelpers.cshtml) - catch-all - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.CatchAllTagHelper.CatchAll - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (224:9,40 [7] EnumTagHelpers.cshtml) - CSharp - MyValue + DefaultTagHelperExecute - + HtmlContent - (234:9,50 [2] EnumTagHelpers.cshtml) + IntermediateToken - (234:9,50 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (236:10,0 [51] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (250:10,14 [10] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (251:10,15 [9] EnumTagHelpers.cshtml) + IntermediateToken - (251:10,15 [9] EnumTagHelpers.cshtml) - CSharp - enumValue + DefaultTagHelperProperty - (273:10,37 [10] EnumTagHelpers.cshtml) - catch-all - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.CatchAllTagHelper.CatchAll - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (274:10,38 [9] EnumTagHelpers.cshtml) + IntermediateToken - (274:10,38 [9] EnumTagHelpers.cshtml) - CSharp - enumValue + DefaultTagHelperExecute - + HtmlContent - (287:10,51 [2] EnumTagHelpers.cshtml) + IntermediateToken - (287:10,51 [2] EnumTagHelpers.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..e35a09a9a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,49 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1115:19,37 [17] ) +|"*, TestAssembly"| + +Source Location: (37:2,2 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +| + var enumValue = MyEnum.MyValue; +| +Generated Location: (1610:36,2 [39] ) +| + var enumValue = MyEnum.MyValue; +| + +Source Location: (96:6,15 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|MyEnum.MyValue| +Generated Location: (2059:46,39 [14] ) +|MyEnum.MyValue| + +Source Location: (131:7,15 [20] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|MyEnum.MySecondValue| +Generated Location: (2538:56,15 [20] ) +|MyEnum.MySecondValue| + +Source Location: (171:8,14 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|MyValue| +Generated Location: (3140:66,132 [7] ) +|MyValue| + +Source Location: (198:9,14 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|MySecondValue| +Generated Location: (3730:76,132 [13] ) +|MySecondValue| + +Source Location: (224:9,40 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|MyValue| +Generated Location: (4044:83,138 [7] ) +|MyValue| + +Source Location: (251:10,15 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|enumValue| +Generated Location: (4541:93,39 [9] ) +|enumValue| + +Source Location: (274:10,38 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml) +|enumValue| +Generated Location: (4758:100,45 [9] ) +|enumValue| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..729513c20d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.codegen.cs @@ -0,0 +1,182 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a605351a30b7fef3db7e3f61a70a62e29a6badf8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a605351a30b7fef3db7e3f61a70a62e29a6badf8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" + + var enumValue = MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("value", __TestNamespace_InputTagHelper.Value, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "class", 1, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +AddHtmlAttributeValue("", 130, MyEnum.MySecondValue, 130, 21, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("value", __TestNamespace_InputTagHelper.Value, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MySecondValue; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("value", __TestNamespace_InputTagHelper.Value, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_CatchAllTagHelper.CatchAll = global::Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum.MyValue; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("catch-all", __TestNamespace_CatchAllTagHelper.CatchAll, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_InputTagHelper.Value = enumValue; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("value", __TestNamespace_InputTagHelper.Value, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers.cshtml" +__TestNamespace_CatchAllTagHelper.CatchAll = enumValue; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("catch-all", __TestNamespace_CatchAllTagHelper.CatchAll, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..e38db1bbaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_Runtime.ir.txt @@ -0,0 +1,68 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_Runtime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] EnumTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] EnumTagHelpers.cshtml) - Html - \n + CSharpCode - (37:2,2 [39] EnumTagHelpers.cshtml) + IntermediateToken - (37:2,2 [39] EnumTagHelpers.cshtml) - CSharp - \n var enumValue = MyEnum.MyValue;\n + HtmlContent - (79:5,0 [2] EnumTagHelpers.cshtml) + IntermediateToken - (79:5,0 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (81:6,0 [33] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (95:6,14 [15] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (96:6,15 [14] EnumTagHelpers.cshtml) + IntermediateToken - (96:6,15 [14] EnumTagHelpers.cshtml) - CSharp - MyEnum.MyValue + DefaultTagHelperExecute - + HtmlContent - (114:6,33 [2] EnumTagHelpers.cshtml) + IntermediateToken - (114:6,33 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (116:7,0 [39] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpressionAttributeValue - (130:7,14 [21] EnumTagHelpers.cshtml) - + IntermediateToken - (131:7,15 [20] EnumTagHelpers.cshtml) - CSharp - MyEnum.MySecondValue + DefaultTagHelperExecute - + HtmlContent - (155:7,39 [2] EnumTagHelpers.cshtml) + IntermediateToken - (155:7,39 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (157:8,0 [25] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (171:8,14 [7] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (171:8,14 [7] EnumTagHelpers.cshtml) - CSharp - MyValue + DefaultTagHelperExecute - + HtmlContent - (182:8,25 [2] EnumTagHelpers.cshtml) + IntermediateToken - (182:8,25 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (184:9,0 [50] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (198:9,14 [13] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (198:9,14 [13] EnumTagHelpers.cshtml) - CSharp - MySecondValue + DefaultTagHelperProperty - (224:9,40 [7] EnumTagHelpers.cshtml) - catch-all - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.CatchAllTagHelper.CatchAll - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (224:9,40 [7] EnumTagHelpers.cshtml) - CSharp - MyValue + DefaultTagHelperExecute - + HtmlContent - (234:9,50 [2] EnumTagHelpers.cshtml) + IntermediateToken - (234:9,50 [2] EnumTagHelpers.cshtml) - Html - \n + TagHelper - (236:10,0 [51] EnumTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperProperty - (250:10,14 [10] EnumTagHelpers.cshtml) - value - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.InputTagHelper.Value - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (251:10,15 [9] EnumTagHelpers.cshtml) + IntermediateToken - (251:10,15 [9] EnumTagHelpers.cshtml) - CSharp - enumValue + DefaultTagHelperProperty - (273:10,37 [10] EnumTagHelpers.cshtml) - catch-all - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestTagHelperDescriptors.MyEnum TestNamespace.CatchAllTagHelper.CatchAll - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (274:10,38 [9] EnumTagHelpers.cshtml) + IntermediateToken - (274:10,38 [9] EnumTagHelpers.cshtml) - CSharp - enumValue + DefaultTagHelperExecute - + HtmlContent - (287:10,51 [2] EnumTagHelpers.cshtml) + IntermediateToken - (287:10,51 [2] EnumTagHelpers.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml new file mode 100644 index 0000000000..a7bc49af11 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml @@ -0,0 +1,8 @@ +@addTagHelper *, TestAssembly + + + + + Not a TagHelper: + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..c946206dea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,65 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_DesignTime + { + #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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Type = string.Empty; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" + __TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..da8f57f185 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt @@ -0,0 +1,71 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] EscapedTagHelpers.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [5] EscapedTagHelpers.cshtml) + IntermediateToken - (29:0,29 [4] EscapedTagHelpers.cshtml) - Html - \n\n + IntermediateToken - (33:2,0 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (35:2,2 [47] EscapedTagHelpers.cshtml) + IntermediateToken - (35:2,2 [3] EscapedTagHelpers.cshtml) - Html - div + IntermediateToken - (38:2,5 [36] EscapedTagHelpers.cshtml) - Html - class="randomNonTagHelperAttribute" + IntermediateToken - (74:2,41 [1] EscapedTagHelpers.cshtml) - Html - > + IntermediateToken - (75:2,42 [6] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (81:3,4 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (83:3,6 [22] EscapedTagHelpers.cshtml) + IntermediateToken - (83:3,6 [1] EscapedTagHelpers.cshtml) - Html - p + IntermediateToken - (84:3,7 [20] EscapedTagHelpers.cshtml) - Html - class="Hello World" + IntermediateToken - (104:3,27 [1] EscapedTagHelpers.cshtml) - Html - + CSharpExpression - (106:3,29 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (106:3,29 [12] EscapedTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlContent - (118:3,41 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (118:3,41 [1] EscapedTagHelpers.cshtml) - Html - > + IntermediateToken - (119:3,42 [10] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (129:4,8 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (131:4,10 [31] EscapedTagHelpers.cshtml) + IntermediateToken - (131:4,10 [5] EscapedTagHelpers.cshtml) - Html - input + IntermediateToken - (136:4,15 [12] EscapedTagHelpers.cshtml) - Html - type="text" + IntermediateToken - (148:4,27 [1] EscapedTagHelpers.cshtml) - Html - + IntermediateToken - (149:4,28 [2] EscapedTagHelpers.cshtml) - Html - /> + IntermediateToken - (151:4,30 [10] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (161:5,8 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (163:5,10 [22] EscapedTagHelpers.cshtml) + IntermediateToken - (163:5,10 [2] EscapedTagHelpers.cshtml) - Html - em + IntermediateToken - (165:5,12 [1] EscapedTagHelpers.cshtml) - Html - > + IntermediateToken - (166:5,13 [17] EscapedTagHelpers.cshtml) - Html - Not a TagHelper: + IntermediateToken - (183:5,30 [2] EscapedTagHelpers.cshtml) - Html - + IntermediateToken - (189:5,36 [1] EscapedTagHelpers.cshtml) - Html - + TagHelper - (190:5,37 [45] EscapedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (203:5,50 [13] EscapedTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (204:5,51 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (204:5,51 [12] EscapedTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperProperty - (203:5,50 [13] EscapedTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (204:5,51 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (204:5,51 [12] EscapedTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperProperty - (227:5,74 [4] EscapedTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (227:5,74 [4] EscapedTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (235:5,82 [8] EscapedTagHelpers.cshtml) + IntermediateToken - (235:5,82 [6] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (241:6,4 [2] EscapedTagHelpers.cshtml) - Html - + IntermediateToken - (246:6,9 [2] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (248:7,0 [2] EscapedTagHelpers.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..cf674d229b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml) +|*, TestAssembly| +Generated Location: (1118:19,38 [15] ) +|*, TestAssembly| + +Source Location: (106:3,29 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (1642:36,29 [12] ) +|DateTime.Now| + +Source Location: (204:5,51 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml) +|DateTime.Now| +Generated Location: (2078:45,51 [12] ) +|DateTime.Now| + +Source Location: (227:5,74 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml) +|true| +Generated Location: (2483:54,74 [4] ) +|true| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..792e0d3fc7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.codegen.cs @@ -0,0 +1,91 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c1489e9dd98dc3e29bfbfd9a3f271ddec5134446" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c1489e9dd98dc3e29bfbfd9a3f271ddec5134446", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n<"); + WriteLiteral("div class=\"randomNonTagHelperAttribute\">\r\n <"); + WriteLiteral("p class=\"Hello World\" "); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" + Write(DateTime.Now); + +#line default +#line hidden +#nullable disable + WriteLiteral(">\r\n <"); + WriteLiteral("input type=\"text\" />\r\n <"); + WriteLiteral("em>Not a TagHelper: "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" + WriteLiteral(DateTime.Now); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper.Type = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("type", __TestNamespace_InputTagHelper.Type, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers.cshtml" +__TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("checked", __TestNamespace_InputTagHelper2.Checked, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n \r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..10ad7acf39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_Runtime.ir.txt @@ -0,0 +1,65 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_Runtime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:1,0 [3] EscapedTagHelpers.cshtml) + IntermediateToken - (31:1,0 [2] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (33:2,0 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (35:2,2 [47] EscapedTagHelpers.cshtml) + IntermediateToken - (35:2,2 [3] EscapedTagHelpers.cshtml) - Html - div + IntermediateToken - (38:2,5 [36] EscapedTagHelpers.cshtml) - Html - class="randomNonTagHelperAttribute" + IntermediateToken - (74:2,41 [1] EscapedTagHelpers.cshtml) - Html - > + IntermediateToken - (75:2,42 [6] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (81:3,4 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (83:3,6 [22] EscapedTagHelpers.cshtml) + IntermediateToken - (83:3,6 [1] EscapedTagHelpers.cshtml) - Html - p + IntermediateToken - (84:3,7 [20] EscapedTagHelpers.cshtml) - Html - class="Hello World" + IntermediateToken - (104:3,27 [1] EscapedTagHelpers.cshtml) - Html - + CSharpExpression - (106:3,29 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (106:3,29 [12] EscapedTagHelpers.cshtml) - CSharp - DateTime.Now + HtmlContent - (118:3,41 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (118:3,41 [1] EscapedTagHelpers.cshtml) - Html - > + IntermediateToken - (119:3,42 [10] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (129:4,8 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (131:4,10 [31] EscapedTagHelpers.cshtml) + IntermediateToken - (131:4,10 [5] EscapedTagHelpers.cshtml) - Html - input + IntermediateToken - (136:4,15 [12] EscapedTagHelpers.cshtml) - Html - type="text" + IntermediateToken - (148:4,27 [1] EscapedTagHelpers.cshtml) - Html - + IntermediateToken - (149:4,28 [2] EscapedTagHelpers.cshtml) - Html - /> + IntermediateToken - (151:4,30 [10] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (161:5,8 [1] EscapedTagHelpers.cshtml) - Html - < + HtmlContent - (163:5,10 [22] EscapedTagHelpers.cshtml) + IntermediateToken - (163:5,10 [2] EscapedTagHelpers.cshtml) - Html - em + IntermediateToken - (165:5,12 [1] EscapedTagHelpers.cshtml) - Html - > + IntermediateToken - (166:5,13 [17] EscapedTagHelpers.cshtml) - Html - Not a TagHelper: + IntermediateToken - (183:5,30 [2] EscapedTagHelpers.cshtml) - Html - + IntermediateToken - (189:5,36 [1] EscapedTagHelpers.cshtml) - Html - + TagHelper - (190:5,37 [45] EscapedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (203:5,50 [13] EscapedTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (204:5,51 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (204:5,51 [12] EscapedTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperProperty - (203:5,50 [13] EscapedTagHelpers.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (204:5,51 [12] EscapedTagHelpers.cshtml) + IntermediateToken - (204:5,51 [12] EscapedTagHelpers.cshtml) - CSharp - DateTime.Now + DefaultTagHelperProperty - (227:5,74 [4] EscapedTagHelpers.cshtml) - checked - bool TestNamespace.InputTagHelper2.Checked - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (227:5,74 [4] EscapedTagHelpers.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (235:5,82 [8] EscapedTagHelpers.cshtml) + IntermediateToken - (235:5,82 [6] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (241:6,4 [2] EscapedTagHelpers.cshtml) - Html - + IntermediateToken - (246:6,9 [2] EscapedTagHelpers.cshtml) - Html - \n + IntermediateToken - (248:7,0 [2] EscapedTagHelpers.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml new file mode 100644 index 0000000000..10730f1114 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml @@ -0,0 +1 @@ +1 + 1 = @(1+1) \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml new file mode 100644 index 0000000000..a0fdfc9a21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml @@ -0,0 +1,3 @@ +This is markup + +@( \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.codegen.cs new file mode 100644 index 0000000000..07bdbbe86b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml" +__o = ; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.codegen.html new file mode 100644 index 0000000000..6eaf3f7aa0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.codegen.html @@ -0,0 +1,3 @@ +This is markup + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..4e0bfb131d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt new file mode 100644 index 0000000000..947b28d727 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) + IntermediateToken - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) - Html - This is markup\n\n + CSharpExpression - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml) + IntermediateToken - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.mappings.txt new file mode 100644 index 0000000000..a4208a7ee2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (20:2,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml) +|| +Generated Location: (770:19,6 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs new file mode 100644 index 0000000000..d3d9989be5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.codegen.cs @@ -0,0 +1,26 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e8e095026beaca454b3a8d02b1548fa001d08214" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e8e095026beaca454b3a8d02b1548fa001d08214", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("This is markup\r\n\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml" +Write(); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt new file mode 100644 index 0000000000..4e0bfb131d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt new file mode 100644 index 0000000000..5f459014c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) + IntermediateToken - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) - Html - This is markup\n\n + CSharpExpression - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml) + IntermediateToken - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml new file mode 100644 index 0000000000..70d8cefd95 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml @@ -0,0 +1 @@ +
        @(@
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.codegen.cs new file mode 100644 index 0000000000..2cc76e8ce5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml" + __o = item => new Template(async(__razor_template_writer) => { +} +); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.codegen.html new file mode 100644 index 0000000000..fc59317849 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.codegen.html @@ -0,0 +1 @@ +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..04d0a39526 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt new file mode 100644 index 0000000000..b38906f249 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [5] ExplicitExpressionWithMarkup.cshtml) + IntermediateToken - (0:0,0 [4] ExplicitExpressionWithMarkup.cshtml) - Html -
        + CSharpExpression - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) + Template - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) + HtmlContent - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) + IntermediateToken - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) - Html -
        + IntermediateToken - (14:0,14 [0] ExplicitExpressionWithMarkup.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.mappings.txt new file mode 100644 index 0000000000..62cc130627 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml) +|| +Generated Location: (844:21,1 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs new file mode 100644 index 0000000000..fcdf711df5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.codegen.cs @@ -0,0 +1,31 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "47d858755c07db489bd8824b7eaee760bb858bcb" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"47d858755c07db489bd8824b7eaee760bb858bcb", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("
        "); +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml" + Write(item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + WriteLiteral("
        "); + PopWriter(); +} +)); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt new file mode 100644 index 0000000000..04d0a39526 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt new file mode 100644 index 0000000000..8764a82186 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.ir.txt @@ -0,0 +1,14 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [5] ExplicitExpressionWithMarkup.cshtml) + IntermediateToken - (0:0,0 [4] ExplicitExpressionWithMarkup.cshtml) - Html -
        + CSharpExpression - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) + Template - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) + HtmlContent - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) + IntermediateToken - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) - Html -
        + IntermediateToken - (14:0,14 [0] ExplicitExpressionWithMarkup.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.codegen.cs new file mode 100644 index 0000000000..7b344876fd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml" + __o = 1+1; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.codegen.html new file mode 100644 index 0000000000..33b749a2f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.codegen.html @@ -0,0 +1 @@ +1 + 1 = \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt new file mode 100644 index 0000000000..b2f22a261b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [8] ExplicitExpression.cshtml) + IntermediateToken - (0:0,0 [8] ExplicitExpression.cshtml) - Html - 1 + 1 = + CSharpExpression - (10:0,10 [3] ExplicitExpression.cshtml) + IntermediateToken - (10:0,10 [3] ExplicitExpression.cshtml) - CSharp - 1+1 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.mappings.txt new file mode 100644 index 0000000000..e4720d0660 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (10:0,10 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml) +|1+1| +Generated Location: (764:19,10 [3] ) +|1+1| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs new file mode 100644 index 0000000000..8f6c52477e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.codegen.cs @@ -0,0 +1,26 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0fa6894c606c7426da1d8cacfbacf8be971c777f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"0fa6894c606c7426da1d8cacfbacf8be971c777f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("1 + 1 = "); +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression.cshtml" + Write(1+1); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt new file mode 100644 index 0000000000..c1867efbb6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [8] ExplicitExpression.cshtml) + IntermediateToken - (0:0,0 [8] ExplicitExpression.cshtml) - Html - 1 + 1 = + CSharpExpression - (10:0,10 [3] ExplicitExpression.cshtml) + IntermediateToken - (10:0,10 [3] ExplicitExpression.cshtml) - CSharp - 1+1 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml new file mode 100644 index 0000000000..a4d4caa007 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml @@ -0,0 +1,16 @@ +@{ + object foo = null; + string bar = "Foo"; +} + +@if(foo != null) { + @foo +} else { +

        Foo is Null!

        +} + +

        +@if(!String.IsNullOrEmpty(bar)) { + @(bar.Replace("F", "B")) +} +

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.codegen.cs new file mode 100644 index 0000000000..d0cd34cc74 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.codegen.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + + object foo = null; + string bar = "Foo"; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + if(foo != null) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" +__o = foo; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + +} else { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + if(!String.IsNullOrEmpty(bar)) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" +__o = bar.Replace("F", "B"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.codegen.html new file mode 100644 index 0000000000..de86958add --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.codegen.html @@ -0,0 +1,16 @@ + + + + + + + + +

        Foo is Null!

        + + +

        + + + +

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt new file mode 100644 index 0000000000..358e6bc788 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt @@ -0,0 +1,42 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [51] ExpressionsInCode.cshtml) + IntermediateToken - (2:0,2 [51] ExpressionsInCode.cshtml) - CSharp - \n object foo = null;\n string bar = "Foo";\n + HtmlContent - (56:4,0 [2] ExpressionsInCode.cshtml) + IntermediateToken - (56:4,0 [2] ExpressionsInCode.cshtml) - Html - \n + CSharpCode - (59:5,1 [23] ExpressionsInCode.cshtml) + IntermediateToken - (59:5,1 [23] ExpressionsInCode.cshtml) - CSharp - if(foo != null) {\n + CSharpExpression - (83:6,5 [3] ExpressionsInCode.cshtml) + IntermediateToken - (83:6,5 [3] ExpressionsInCode.cshtml) - CSharp - foo + CSharpCode - (86:6,8 [16] ExpressionsInCode.cshtml) + IntermediateToken - (86:6,8 [16] ExpressionsInCode.cshtml) - CSharp - \n} else {\n + HtmlContent - (102:8,4 [19] ExpressionsInCode.cshtml) + IntermediateToken - (102:8,4 [2] ExpressionsInCode.cshtml) - Html -

        + IntermediateToken - (105:8,7 [12] ExpressionsInCode.cshtml) - Html - Foo is Null! + IntermediateToken - (117:8,19 [4] ExpressionsInCode.cshtml) - Html -

        + CSharpCode - (121:8,23 [3] ExpressionsInCode.cshtml) + IntermediateToken - (121:8,23 [3] ExpressionsInCode.cshtml) - CSharp - \n} + HtmlContent - (124:9,1 [9] ExpressionsInCode.cshtml) + IntermediateToken - (124:9,1 [4] ExpressionsInCode.cshtml) - Html - \n\n + IntermediateToken - (128:11,0 [2] ExpressionsInCode.cshtml) - Html -

        + IntermediateToken - (131:11,3 [2] ExpressionsInCode.cshtml) - Html - \n + CSharpCode - (134:12,1 [38] ExpressionsInCode.cshtml) + IntermediateToken - (134:12,1 [38] ExpressionsInCode.cshtml) - CSharp - if(!String.IsNullOrEmpty(bar)) {\n + CSharpExpression - (174:13,6 [21] ExpressionsInCode.cshtml) + IntermediateToken - (174:13,6 [21] ExpressionsInCode.cshtml) - CSharp - bar.Replace("F", "B") + CSharpCode - (196:13,28 [3] ExpressionsInCode.cshtml) + IntermediateToken - (196:13,28 [3] ExpressionsInCode.cshtml) - CSharp - \n} + HtmlContent - (199:14,1 [6] ExpressionsInCode.cshtml) + IntermediateToken - (199:14,1 [2] ExpressionsInCode.cshtml) - Html - \n + IntermediateToken - (201:15,0 [4] ExpressionsInCode.cshtml) - Html -

        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.mappings.txt new file mode 100644 index 0000000000..0db3796826 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.mappings.txt @@ -0,0 +1,58 @@ +Source Location: (2:0,2 [51] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +| + object foo = null; + string bar = "Foo"; +| +Generated Location: (754:19,2 [51] ) +| + object foo = null; + string bar = "Foo"; +| + +Source Location: (59:5,1 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +|if(foo != null) { + | +Generated Location: (968:28,1 [23] ) +|if(foo != null) { + | + +Source Location: (83:6,5 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +|foo| +Generated Location: (1161:36,6 [3] ) +|foo| + +Source Location: (86:6,8 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +| +} else { + | +Generated Location: (1337:43,8 [16] ) +| +} else { + | + +Source Location: (121:8,23 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +| +}| +Generated Location: (1540:52,23 [3] ) +| +}| + +Source Location: (134:12,1 [38] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +|if(!String.IsNullOrEmpty(bar)) { + | +Generated Location: (1709:60,1 [38] ) +|if(!String.IsNullOrEmpty(bar)) { + | + +Source Location: (174:13,6 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +|bar.Replace("F", "B")| +Generated Location: (1918:68,6 [21] ) +|bar.Replace("F", "B")| + +Source Location: (196:13,28 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml) +| +}| +Generated Location: (2133:75,28 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs new file mode 100644 index 0000000000..f5c181ecb9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.codegen.cs @@ -0,0 +1,84 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3ccb5b16f61b84dd82d7402e4a17870a39d09ca9" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"3ccb5b16f61b84dd82d7402e4a17870a39d09ca9", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + + object foo = null; + string bar = "Foo"; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + if(foo != null) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" +Write(foo); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + +} else { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Foo is Null!

        \r\n"); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n

        \r\n"); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + if(!String.IsNullOrEmpty(bar)) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" +Write(bar.Replace("F", "B")); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode.cshtml" + +} + +#line default +#line hidden +#nullable disable + WriteLiteral("

        "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt new file mode 100644 index 0000000000..57aeaa556b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_Runtime.ir.txt @@ -0,0 +1,38 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [51] ExpressionsInCode.cshtml) + IntermediateToken - (2:0,2 [51] ExpressionsInCode.cshtml) - CSharp - \n object foo = null;\n string bar = "Foo";\n + HtmlContent - (56:4,0 [2] ExpressionsInCode.cshtml) + IntermediateToken - (56:4,0 [2] ExpressionsInCode.cshtml) - Html - \n + CSharpCode - (59:5,1 [23] ExpressionsInCode.cshtml) + IntermediateToken - (59:5,1 [23] ExpressionsInCode.cshtml) - CSharp - if(foo != null) {\n + CSharpExpression - (83:6,5 [3] ExpressionsInCode.cshtml) + IntermediateToken - (83:6,5 [3] ExpressionsInCode.cshtml) - CSharp - foo + CSharpCode - (86:6,8 [12] ExpressionsInCode.cshtml) + IntermediateToken - (86:6,8 [12] ExpressionsInCode.cshtml) - CSharp - \n} else {\n + HtmlContent - (98:8,0 [25] ExpressionsInCode.cshtml) + IntermediateToken - (98:8,0 [4] ExpressionsInCode.cshtml) - Html - + IntermediateToken - (102:8,4 [2] ExpressionsInCode.cshtml) - Html -

        + IntermediateToken - (105:8,7 [12] ExpressionsInCode.cshtml) - Html - Foo is Null! + IntermediateToken - (117:8,19 [4] ExpressionsInCode.cshtml) - Html -

        + IntermediateToken - (121:8,23 [2] ExpressionsInCode.cshtml) - Html - \n + CSharpCode - (123:9,0 [3] ExpressionsInCode.cshtml) + IntermediateToken - (123:9,0 [3] ExpressionsInCode.cshtml) - CSharp - }\n + HtmlContent - (126:10,0 [7] ExpressionsInCode.cshtml) + IntermediateToken - (126:10,0 [2] ExpressionsInCode.cshtml) - Html - \n + IntermediateToken - (128:11,0 [2] ExpressionsInCode.cshtml) - Html -

        + IntermediateToken - (131:11,3 [2] ExpressionsInCode.cshtml) - Html - \n + CSharpCode - (134:12,1 [38] ExpressionsInCode.cshtml) + IntermediateToken - (134:12,1 [38] ExpressionsInCode.cshtml) - CSharp - if(!String.IsNullOrEmpty(bar)) {\n + CSharpExpression - (174:13,6 [21] ExpressionsInCode.cshtml) + IntermediateToken - (174:13,6 [21] ExpressionsInCode.cshtml) - CSharp - bar.Replace("F", "B") + CSharpCode - (196:13,28 [5] ExpressionsInCode.cshtml) + IntermediateToken - (196:13,28 [5] ExpressionsInCode.cshtml) - CSharp - \n}\n + HtmlContent - (201:15,0 [4] ExpressionsInCode.cshtml) + IntermediateToken - (201:15,0 [4] ExpressionsInCode.cshtml) - Html -

        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml new file mode 100644 index 0000000000..5d06b37224 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml @@ -0,0 +1,12 @@ +@functions { + +} + +@functions { + Random _rand = new Random(); + private int RandomInt() { + return _rand.Next(); + } +} + +Here's a random number: @RandomInt() \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml new file mode 100644 index 0000000000..6b3de50b2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml @@ -0,0 +1,7 @@ + + + @functions{ +string foo(string input) { + return input + "!"; +} +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.codegen.cs new file mode 100644 index 0000000000..6447c907bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml" + +string foo(string input) { + return input + "!"; +} + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.codegen.html new file mode 100644 index 0000000000..6393f9703b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.codegen.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt new file mode 100644 index 0000000000..f460329dab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [5] FunctionsBlockMinimal.cshtml) + IntermediateToken - (0:0,0 [5] FunctionsBlockMinimal.cshtml) - Html - \n\n + CSharpCode - (16:2,12 [55] FunctionsBlockMinimal.cshtml) + IntermediateToken - (16:2,12 [55] FunctionsBlockMinimal.cshtml) - CSharp - \nstring foo(string input) {\n return input + "!";\n}\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.mappings.txt new file mode 100644 index 0000000000..e09fcdf23f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (16:2,12 [55] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml) +| +string foo(string input) { + return input + "!"; +} +| +Generated Location: (824:21,15 [55] ) +| +string foo(string input) { + return input + "!"; +} +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs new file mode 100644 index 0000000000..9dd9ba4e53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.codegen.cs @@ -0,0 +1,29 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5ba3477b8f10b5207bb9f610499189ac0d50aaa0" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5ba3477b8f10b5207bb9f610499189ac0d50aaa0", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal.cshtml" + +string foo(string input) { + return input + "!"; +} + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt new file mode 100644 index 0000000000..5efffb2706 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [4] FunctionsBlockMinimal.cshtml) + IntermediateToken - (0:0,0 [4] FunctionsBlockMinimal.cshtml) - Html - \n\n + CSharpCode - (16:2,12 [55] FunctionsBlockMinimal.cshtml) + IntermediateToken - (16:2,12 [55] FunctionsBlockMinimal.cshtml) - CSharp - \nstring foo(string input) {\n return input + "!";\n}\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs new file mode 100644 index 0000000000..762e0b2a01 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" + __o = RandomInt(); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" + + Random _rand = new Random(); + private int RandomInt() { + return _rand.Next(); + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.html new file mode 100644 index 0000000000..46d84b460b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.codegen.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +Here's a random number: \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt new file mode 100644 index 0000000000..e71b8ed6a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (17:2,1 [4] FunctionsBlock.cshtml) + IntermediateToken - (17:2,1 [4] FunctionsBlock.cshtml) - Html - \n\n + HtmlContent - (138:9,1 [28] FunctionsBlock.cshtml) + IntermediateToken - (138:9,1 [28] FunctionsBlock.cshtml) - Html - \n\nHere's a random number: + CSharpExpression - (167:11,25 [11] FunctionsBlock.cshtml) + IntermediateToken - (167:11,25 [11] FunctionsBlock.cshtml) - CSharp - RandomInt() + CSharpCode - (12:0,12 [4] FunctionsBlock.cshtml) + IntermediateToken - (12:0,12 [4] FunctionsBlock.cshtml) - CSharp - \n\n + CSharpCode - (33:4,12 [104] FunctionsBlock.cshtml) + IntermediateToken - (33:4,12 [104] FunctionsBlock.cshtml) - CSharp - \n Random _rand = new Random();\n private int RandomInt() {\n return _rand.Next();\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt new file mode 100644 index 0000000000..d2d8522163 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (167:11,25 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml) +|RandomInt()| +Generated Location: (772:19,25 [11] ) +|RandomInt()| + +Source Location: (12:0,12 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml) +| + +| +Generated Location: (1006:28,12 [4] ) +| + +| + +Source Location: (33:4,12 [104] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml) +| + Random _rand = new Random(); + private int RandomInt() { + return _rand.Next(); + } +| +Generated Location: (1181:36,12 [104] ) +| + Random _rand = new Random(); + private int RandomInt() { + return _rand.Next(); + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs new file mode 100644 index 0000000000..f005acdd93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.codegen.cs @@ -0,0 +1,38 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e6a053bfeb65ba3e17885a8ae1523f28a3483258" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e6a053bfeb65ba3e17885a8ae1523f28a3483258", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\nHere\'s a random number: "); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" + Write(RandomInt()); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock.cshtml" + + Random _rand = new Random(); + private int RandomInt() { + return _rand.Next(); + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt new file mode 100644 index 0000000000..4b05dbcc3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_Runtime.ir.txt @@ -0,0 +1,16 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (19:3,0 [2] FunctionsBlock.cshtml) + IntermediateToken - (19:3,0 [2] FunctionsBlock.cshtml) - Html - \n + HtmlContent - (140:10,0 [26] FunctionsBlock.cshtml) + IntermediateToken - (140:10,0 [26] FunctionsBlock.cshtml) - Html - \nHere's a random number: + CSharpExpression - (167:11,25 [11] FunctionsBlock.cshtml) + IntermediateToken - (167:11,25 [11] FunctionsBlock.cshtml) - CSharp - RandomInt() + CSharpCode - (12:0,12 [4] FunctionsBlock.cshtml) + IntermediateToken - (12:0,12 [4] FunctionsBlock.cshtml) - CSharp - \n\n + CSharpCode - (33:4,12 [104] FunctionsBlock.cshtml) + IntermediateToken - (33:4,12 [104] FunctionsBlock.cshtml) - CSharp - \n Random _rand = new Random();\n private int RandomInt() {\n return _rand.Next();\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml new file mode 100644 index 0000000000..a6addbe97c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml @@ -0,0 +1,3 @@ +@{ + @@Da +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs new file mode 100644 index 0000000000..7e2f26e97e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.cs @@ -0,0 +1,37 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" + @Da + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.html new file mode 100644 index 0000000000..13484a1b45 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.codegen.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt new file mode 100644 index 0000000000..6c3f2a9d41 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] HiddenSpansInCode.cshtml) + IntermediateToken - (2:0,2 [6] HiddenSpansInCode.cshtml) - CSharp - \n + CSharpCode - (9:1,5 [5] HiddenSpansInCode.cshtml) + IntermediateToken - (9:1,5 [5] HiddenSpansInCode.cshtml) - CSharp - @Da\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt new file mode 100644 index 0000000000..b073a2350b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml) +| + | +Generated Location: (754:19,2 [6] ) +| + | + +Source Location: (9:1,5 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml) +|@Da +| +Generated Location: (929:27,5 [5] ) +|@Da +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs new file mode 100644 index 0000000000..a39b51584d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.codegen.cs @@ -0,0 +1,25 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9bc7458ab052e80d9c977bfce0f0c7e8aef0d80f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"9bc7458ab052e80d9c977bfce0f0c7e8aef0d80f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode.cshtml" + @Da + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt new file mode 100644 index 0000000000..92fc13fef7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] HiddenSpansInCode.cshtml) + IntermediateToken - (2:0,2 [6] HiddenSpansInCode.cshtml) - CSharp - \n + CSharpCode - (9:1,5 [5] HiddenSpansInCode.cshtml) + IntermediateToken - (9:1,5 [5] HiddenSpansInCode.cshtml) - CSharp - @Da\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml new file mode 100644 index 0000000000..6a99437910 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.codegen.cs new file mode 100644 index 0000000000..6add10d801 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.codegen.cs @@ -0,0 +1,22 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.codegen.html new file mode 100644 index 0000000000..21fdc4d316 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.codegen.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt new file mode 100644 index 0000000000..4d1b62bfcc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Double.cshtml) + IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - + IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Double.cshtml) - Html - \n + IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs new file mode 100644 index 0000000000..fb924e6327 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.codegen.cs @@ -0,0 +1,19 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "520aebbcdbdb163b131356be8f3aef0eb0809c47" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"520aebbcdbdb163b131356be8f3aef0eb0809c47", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt new file mode 100644 index 0000000000..4408836bd2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_Runtime.ir.txt @@ -0,0 +1,15 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Double.cshtml) + IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - + IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Double.cshtml) - Html - \n + IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml new file mode 100644 index 0000000000..dc1b21a546 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.codegen.cs new file mode 100644 index 0000000000..e20af5e1ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.codegen.cs @@ -0,0 +1,22 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.codegen.html new file mode 100644 index 0000000000..1c32421c7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.codegen.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt new file mode 100644 index 0000000000..4445841a71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Single.cshtml) + IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - + IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Single.cshtml) - Html - \n + IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.mappings.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs new file mode 100644 index 0000000000..1bce0936db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.codegen.cs @@ -0,0 +1,19 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2080c7f4c5de3e5e7f309c11a6be5c5e8d86e75a" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2080c7f4c5de3e5e7f309c11a6be5c5e8d86e75a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt new file mode 100644 index 0000000000..406418bcaf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_Runtime.ir.txt @@ -0,0 +1,15 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Single.cshtml) + IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - + IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Single.cshtml) - Html - \n + IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml new file mode 100644 index 0000000000..cc52b3487f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml @@ -0,0 +1,5 @@ +@implements IDisposable + +@functions { + void IDisposable.Dispose() { } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.codegen.cs new file mode 100644 index 0000000000..94eba1f89d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Implements_DesignTime : IDisposable + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml" +IDisposable __typeHelper = default!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml" + + void IDisposable.Dispose() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.codegen.html new file mode 100644 index 0000000000..d0776340e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.codegen.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.ir.txt new file mode 100644 index 0000000000..cf982456f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.ir.txt @@ -0,0 +1,16 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Implements_DesignTime - - IDisposable + DesignTimeDirective - + DirectiveToken - (12:0,12 [11] Implements.cshtml) - IDisposable + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (25:1,0 [2] Implements.cshtml) + IntermediateToken - (25:1,0 [2] Implements.cshtml) - Html - \n + CSharpCode - (39:2,12 [38] Implements.cshtml) + IntermediateToken - (39:2,12 [38] Implements.cshtml) - CSharp - \n void IDisposable.Dispose() { }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.mappings.txt new file mode 100644 index 0000000000..f9010a682e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_DesignTime.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (12:0,12 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml) +|IDisposable| +Generated Location: (498:12,0 [11] ) +|IDisposable| + +Source Location: (39:2,12 [38] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml) +| + void IDisposable.Dispose() { } +| +Generated Location: (1066:31,12 [38] ) +| + void IDisposable.Dispose() { } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_Runtime.codegen.cs new file mode 100644 index 0000000000..0cab554528 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_Runtime.codegen.cs @@ -0,0 +1,27 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "46e30222edb02ded9cda34df5c2593e760643d53" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Implements_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"46e30222edb02ded9cda34df5c2593e760643d53", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Implements_Runtime : IDisposable + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements.cshtml" + + void IDisposable.Dispose() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_Runtime.ir.txt new file mode 100644 index 0000000000..1ee182d674 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Implements_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Implements_Runtime - - IDisposable + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (25:1,0 [2] Implements.cshtml) + IntermediateToken - (25:1,0 [2] Implements.cshtml) - Html - \n + CSharpCode - (39:2,12 [38] Implements.cshtml) + IntermediateToken - (39:2,12 [38] Implements.cshtml) - CSharp - \n void IDisposable.Dispose() { }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml new file mode 100644 index 0000000000..dcce7fa572 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml @@ -0,0 +1,3 @@ +@for(int i = 1; i <= 10; i++) { +

        This is item #@i

        +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml new file mode 100644 index 0000000000..365d20e003 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml @@ -0,0 +1,3 @@ +This is markup + +@ \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.codegen.cs new file mode 100644 index 0000000000..24e9343452 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml" +__o = ; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.codegen.html new file mode 100644 index 0000000000..f1c2edafa2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.codegen.html @@ -0,0 +1,3 @@ +This is markup + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..e2a8c29095 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt new file mode 100644 index 0000000000..19598b5d7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) + IntermediateToken - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) - Html - This is markup\n\n + CSharpExpression - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml) + IntermediateToken - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.mappings.txt new file mode 100644 index 0000000000..2fb787f40e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (19:2,1 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml) +|| +Generated Location: (770:19,6 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs new file mode 100644 index 0000000000..09e806ccbc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.codegen.cs @@ -0,0 +1,26 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "94cd2b5a8281fc76002fc745485949cf3952a058" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"94cd2b5a8281fc76002fc745485949cf3952a058", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("This is markup\r\n\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml" +Write(); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt new file mode 100644 index 0000000000..e2a8c29095 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt new file mode 100644 index 0000000000..b2ac3e3520 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.ir.txt @@ -0,0 +1,10 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) + IntermediateToken - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) - Html - This is markup\n\n + CSharpExpression - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml) + IntermediateToken - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.codegen.cs new file mode 100644 index 0000000000..2f981797eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.codegen.cs @@ -0,0 +1,45 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" + for(int i = 1; i <= 10; i++) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.codegen.html new file mode 100644 index 0000000000..c3ca733a2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.codegen.html @@ -0,0 +1,3 @@ + +

        This is item #

        + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt new file mode 100644 index 0000000000..f082ae44b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (1:0,1 [36] ImplicitExpression.cshtml) + IntermediateToken - (1:0,1 [36] ImplicitExpression.cshtml) - CSharp - for(int i = 1; i <= 10; i++) {\n + HtmlContent - (37:1,4 [17] ImplicitExpression.cshtml) + IntermediateToken - (37:1,4 [2] ImplicitExpression.cshtml) - Html -

        + IntermediateToken - (40:1,7 [14] ImplicitExpression.cshtml) - Html - This is item # + CSharpExpression - (55:1,22 [1] ImplicitExpression.cshtml) + IntermediateToken - (55:1,22 [1] ImplicitExpression.cshtml) - CSharp - i + HtmlContent - (56:1,23 [4] ImplicitExpression.cshtml) + IntermediateToken - (56:1,23 [4] ImplicitExpression.cshtml) - Html -

        + CSharpCode - (60:1,27 [3] ImplicitExpression.cshtml) + IntermediateToken - (60:1,27 [3] ImplicitExpression.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.mappings.txt new file mode 100644 index 0000000000..b0b0d935f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (1:0,1 [36] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml) +|for(int i = 1; i <= 10; i++) { + | +Generated Location: (755:19,1 [36] ) +|for(int i = 1; i <= 10; i++) { + | + +Source Location: (55:1,22 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml) +|i| +Generated Location: (978:27,22 [1] ) +|i| + +Source Location: (60:1,27 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml) +| +}| +Generated Location: (1172:34,27 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs new file mode 100644 index 0000000000..1cc29a9c8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.codegen.cs @@ -0,0 +1,41 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "68460c577f1cb90794f25535a35a82ff2aa4c193" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"68460c577f1cb90794f25535a35a82ff2aa4c193", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" + for(int i = 1; i <= 10; i++) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        This is item #"); +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt new file mode 100644 index 0000000000..3804c925f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_Runtime.ir.txt @@ -0,0 +1,20 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (1:0,1 [32] ImplicitExpression.cshtml) + IntermediateToken - (1:0,1 [32] ImplicitExpression.cshtml) - CSharp - for(int i = 1; i <= 10; i++) {\n + HtmlContent - (33:1,0 [21] ImplicitExpression.cshtml) + IntermediateToken - (33:1,0 [4] ImplicitExpression.cshtml) - Html - + IntermediateToken - (37:1,4 [2] ImplicitExpression.cshtml) - Html -

        + IntermediateToken - (40:1,7 [14] ImplicitExpression.cshtml) - Html - This is item # + CSharpExpression - (55:1,22 [1] ImplicitExpression.cshtml) + IntermediateToken - (55:1,22 [1] ImplicitExpression.cshtml) - CSharp - i + HtmlContent - (56:1,23 [6] ImplicitExpression.cshtml) + IntermediateToken - (56:1,23 [4] ImplicitExpression.cshtml) - Html -

        + IntermediateToken - (60:1,27 [2] ImplicitExpression.cshtml) - Html - \n + CSharpCode - (62:2,0 [1] ImplicitExpression.cshtml) + IntermediateToken - (62:2,0 [1] ImplicitExpression.cshtml) - CSharp - } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml new file mode 100644 index 0000000000..3b56f0b173 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml @@ -0,0 +1,25 @@ +@* These test files validate that end-to-end, incomplete directives don't throw. *@ + +@addTagHelper +@addTagHelper +@addTagHelper " + +@removeTagHelper +@removeTagHelper +@removeTagHelper " + +@tagHelperPrefix +@tagHelperPrefix +@tagHelperPrefix " + +@inherits +@inherits + +@functions +@functions + +@section +@section + +@section { +@functions { \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs new file mode 100644 index 0000000000..3b83a11a6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.cs @@ -0,0 +1,139 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_DesignTime + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = ""; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = ""; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = "; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = ""; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = ""; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = "; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = ""; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = ""; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" +global::System.Object __typeHelper = "; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.html new file mode 100644 index 0000000000..b7d08f3856 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.codegen.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + { + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..c7d8d88528 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -0,0 +1,27 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt new file mode 100644 index 0000000000..f31a5b77ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.ir.txt @@ -0,0 +1,82 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_DesignTime - - + DesignTimeDirective - + DirectiveToken - (100:2,13 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (116:3,14 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (132:4,14 [1] IncompleteDirectives.cshtml) - " + DirectiveToken - (153:6,16 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (172:7,17 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (191:8,17 [1] IncompleteDirectives.cshtml) - " + DirectiveToken - (212:10,16 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (231:11,17 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (250:12,17 [1] IncompleteDirectives.cshtml) - " + DirectiveToken - (276:15,10 [0] IncompleteDirectives.cshtml) - + DirectiveToken - (326:21,9 [0] IncompleteDirectives.cshtml) - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (85:1,0 [2] IncompleteDirectives.cshtml) + IntermediateToken - (85:1,0 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (100:2,13 [0] IncompleteDirectives.cshtml) - addTagHelper + DirectiveToken - (100:2,13 [0] IncompleteDirectives.cshtml) - + HtmlContent - (100:2,13 [2] IncompleteDirectives.cshtml) + IntermediateToken - (100:2,13 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (116:3,14 [0] IncompleteDirectives.cshtml) - addTagHelper + DirectiveToken - (116:3,14 [0] IncompleteDirectives.cshtml) - + HtmlContent - (116:3,14 [2] IncompleteDirectives.cshtml) + IntermediateToken - (116:3,14 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (132:4,14 [1] IncompleteDirectives.cshtml) - addTagHelper + DirectiveToken - (132:4,14 [1] IncompleteDirectives.cshtml) - " + HtmlContent - (133:4,15 [4] IncompleteDirectives.cshtml) + IntermediateToken - (133:4,15 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (153:6,16 [0] IncompleteDirectives.cshtml) - removeTagHelper + DirectiveToken - (153:6,16 [0] IncompleteDirectives.cshtml) - + HtmlContent - (153:6,16 [2] IncompleteDirectives.cshtml) + IntermediateToken - (153:6,16 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (172:7,17 [0] IncompleteDirectives.cshtml) - removeTagHelper + DirectiveToken - (172:7,17 [0] IncompleteDirectives.cshtml) - + HtmlContent - (172:7,17 [2] IncompleteDirectives.cshtml) + IntermediateToken - (172:7,17 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (191:8,17 [1] IncompleteDirectives.cshtml) - removeTagHelper + DirectiveToken - (191:8,17 [1] IncompleteDirectives.cshtml) - " + HtmlContent - (192:8,18 [4] IncompleteDirectives.cshtml) + IntermediateToken - (192:8,18 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (212:10,16 [0] IncompleteDirectives.cshtml) - tagHelperPrefix + DirectiveToken - (212:10,16 [0] IncompleteDirectives.cshtml) - + HtmlContent - (212:10,16 [2] IncompleteDirectives.cshtml) + IntermediateToken - (212:10,16 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (231:11,17 [0] IncompleteDirectives.cshtml) - tagHelperPrefix + DirectiveToken - (231:11,17 [0] IncompleteDirectives.cshtml) - + HtmlContent - (231:11,17 [2] IncompleteDirectives.cshtml) + IntermediateToken - (231:11,17 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (250:12,17 [1] IncompleteDirectives.cshtml) - tagHelperPrefix + DirectiveToken - (250:12,17 [1] IncompleteDirectives.cshtml) - " + HtmlContent - (251:12,18 [4] IncompleteDirectives.cshtml) + IntermediateToken - (251:12,18 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (255:14,0 [9] IncompleteDirectives.cshtml) - inherits + HtmlContent - (264:14,9 [2] IncompleteDirectives.cshtml) + IntermediateToken - (264:14,9 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (266:15,0 [10] IncompleteDirectives.cshtml) - inherits + DirectiveToken - (276:15,10 [0] IncompleteDirectives.cshtml) - + HtmlContent - (276:15,10 [4] IncompleteDirectives.cshtml) + IntermediateToken - (276:15,10 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (280:17,0 [12] IncompleteDirectives.cshtml) - functions + MalformedDirective - (292:18,0 [15] IncompleteDirectives.cshtml) - functions + MalformedDirective - (307:20,0 [8] IncompleteDirectives.cshtml) - section + HtmlContent - (315:20,8 [2] IncompleteDirectives.cshtml) + IntermediateToken - (315:20,8 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (317:21,0 [9] IncompleteDirectives.cshtml) - section + DirectiveToken - (326:21,9 [0] IncompleteDirectives.cshtml) - + HtmlContent - (326:21,9 [4] IncompleteDirectives.cshtml) + IntermediateToken - (326:21,9 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (330:23,0 [9] IncompleteDirectives.cshtml) - section + HtmlContent - (339:23,9 [3] IncompleteDirectives.cshtml) + IntermediateToken - (339:23,9 [3] IncompleteDirectives.cshtml) - Html - {\n + MalformedDirective - (342:24,0 [12] IncompleteDirectives.cshtml) - functions + CSharpCode - (354:24,12 [0] IncompleteDirectives.cshtml) + IntermediateToken - (354:24,12 [0] IncompleteDirectives.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt new file mode 100644 index 0000000000..bc88dd7adf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.mappings.txt @@ -0,0 +1,60 @@ +Source Location: (100:2,13 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (542:12,38 [0] ) +|| + +Source Location: (116:3,14 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (809:22,38 [0] ) +|| + +Source Location: (132:4,14 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|"| +Generated Location: (1075:32,37 [1] ) +|"| + +Source Location: (153:6,16 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1342:42,38 [0] ) +|| + +Source Location: (172:7,17 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (1609:52,38 [0] ) +|| + +Source Location: (191:8,17 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|"| +Generated Location: (1875:62,37 [1] ) +|"| + +Source Location: (212:10,16 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (2143:72,38 [0] ) +|| + +Source Location: (231:11,17 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (2411:82,38 [0] ) +|| + +Source Location: (250:12,17 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|"| +Generated Location: (2678:92,37 [1] ) +|"| + +Source Location: (276:15,10 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (2908:102,0 [0] ) +|| + +Source Location: (326:21,9 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (3137:112,0 [0] ) +|| + +Source Location: (354:24,12 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) +|| +Generated Location: (3632:129,12 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs new file mode 100644 index 0000000000..c3973b444b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.codegen.cs @@ -0,0 +1,27 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "41721dbbbcb64df19057144a2095a3e1f7466401" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"41721dbbbcb64df19057144a2095a3e1f7466401", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n\r\n"); + WriteLiteral("\r\n"); + WriteLiteral("\r\n\r\n"); + WriteLiteral("{\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt new file mode 100644 index 0000000000..c7d8d88528 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -0,0 +1,27 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1036: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1036: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt new file mode 100644 index 0000000000..a9b01efba5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.ir.txt @@ -0,0 +1,54 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (85:1,0 [2] IncompleteDirectives.cshtml) + IntermediateToken - (85:1,0 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (100:2,13 [2] IncompleteDirectives.cshtml) - addTagHelper + DirectiveToken - (100:2,13 [2] IncompleteDirectives.cshtml) - + MalformedDirective - (116:3,14 [2] IncompleteDirectives.cshtml) - addTagHelper + DirectiveToken - (116:3,14 [2] IncompleteDirectives.cshtml) - + MalformedDirective - (132:4,14 [3] IncompleteDirectives.cshtml) - addTagHelper + DirectiveToken - (132:4,14 [3] IncompleteDirectives.cshtml) - " + HtmlContent - (135:5,0 [2] IncompleteDirectives.cshtml) + IntermediateToken - (135:5,0 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (153:6,16 [2] IncompleteDirectives.cshtml) - removeTagHelper + DirectiveToken - (153:6,16 [2] IncompleteDirectives.cshtml) - + MalformedDirective - (172:7,17 [2] IncompleteDirectives.cshtml) - removeTagHelper + DirectiveToken - (172:7,17 [2] IncompleteDirectives.cshtml) - + MalformedDirective - (191:8,17 [3] IncompleteDirectives.cshtml) - removeTagHelper + DirectiveToken - (191:8,17 [3] IncompleteDirectives.cshtml) - " + HtmlContent - (194:9,0 [2] IncompleteDirectives.cshtml) + IntermediateToken - (194:9,0 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (212:10,16 [2] IncompleteDirectives.cshtml) - tagHelperPrefix + DirectiveToken - (212:10,16 [2] IncompleteDirectives.cshtml) - + MalformedDirective - (231:11,17 [2] IncompleteDirectives.cshtml) - tagHelperPrefix + DirectiveToken - (231:11,17 [2] IncompleteDirectives.cshtml) - + MalformedDirective - (250:12,17 [3] IncompleteDirectives.cshtml) - tagHelperPrefix + DirectiveToken - (250:12,17 [3] IncompleteDirectives.cshtml) - " + HtmlContent - (253:13,0 [2] IncompleteDirectives.cshtml) + IntermediateToken - (253:13,0 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (255:14,0 [9] IncompleteDirectives.cshtml) - inherits + HtmlContent - (264:14,9 [2] IncompleteDirectives.cshtml) + IntermediateToken - (264:14,9 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (266:15,0 [10] IncompleteDirectives.cshtml) - inherits + DirectiveToken - (276:15,10 [0] IncompleteDirectives.cshtml) - + HtmlContent - (276:15,10 [4] IncompleteDirectives.cshtml) + IntermediateToken - (276:15,10 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (280:17,0 [12] IncompleteDirectives.cshtml) - functions + MalformedDirective - (292:18,0 [15] IncompleteDirectives.cshtml) - functions + MalformedDirective - (307:20,0 [8] IncompleteDirectives.cshtml) - section + HtmlContent - (315:20,8 [2] IncompleteDirectives.cshtml) + IntermediateToken - (315:20,8 [2] IncompleteDirectives.cshtml) - Html - \n + MalformedDirective - (317:21,0 [9] IncompleteDirectives.cshtml) - section + DirectiveToken - (326:21,9 [0] IncompleteDirectives.cshtml) - + HtmlContent - (326:21,9 [4] IncompleteDirectives.cshtml) + IntermediateToken - (326:21,9 [4] IncompleteDirectives.cshtml) - Html - \n\n + MalformedDirective - (330:23,0 [9] IncompleteDirectives.cshtml) - section + HtmlContent - (339:23,9 [3] IncompleteDirectives.cshtml) + IntermediateToken - (339:23,9 [3] IncompleteDirectives.cshtml) - Html - {\n + MalformedDirective - (342:24,0 [12] IncompleteDirectives.cshtml) - functions + CSharpCode - (354:24,12 [0] IncompleteDirectives.cshtml) + IntermediateToken - (354:24,12 [0] IncompleteDirectives.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml new file mode 100644 index 0000000000..022784f426 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper.cshtml @@ -0,0 +1,3 @@ +@addTagHelper "*, TestAssembly" + +

        Bar

        ; + @:Hello, World +

        Hello, World

        +} + +@while(i <= 10) { +

        Hello from C#, #@(i)

        + i += 1; +} + +@if(i == 11) { +

        We wrote 10 lines!

        +} + +@switch(i) { + case 11: +

        No really, we wrote 10 lines!

        + break; + default: +

        Actually, we didn't...

        + break; +} + +@for(int j = 1; j <= 10; j += 2) { +

        Hello again from C#, #@(j)

        +} + +@try { +

        That time, we wrote 5 lines!

        +} catch(Exception ex) { +

        Oh no! An error occurred: @(ex.Message)

        +} + +@lock(new object()) { +

        This block is locked, for your security!

        +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs new file mode 100644 index 0000000000..554c75fbc5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.cs @@ -0,0 +1,195 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + int i = 1; + var foo = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { + } + ) +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + ; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + while(i <= 10) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + i += 1; +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + if(i == 11) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + switch(i) { + case 11: + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + break; + default: + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + break; +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + for(int j = 1; j <= 10; j += 2) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + __o = j; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + try { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + +} catch(Exception ex) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + __o = ex.Message; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + lock(new object()) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.html new file mode 100644 index 0000000000..111d1f7474 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.codegen.html @@ -0,0 +1,38 @@ + + +

        Bar

        + Hello, World +

        Hello, World

        + + + +

        Hello from C#, #

        + + + + +

        We wrote 10 lines!

        + + + + +

        No really, we wrote 10 lines!

        + + +

        Actually, we didn't...

        + + + + +

        Hello again from C#, #

        + + + +

        That time, we wrote 5 lines!

        + +

        Oh no! An error occurred:

        + + + +

        This block is locked, for your security!

        + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt new file mode 100644 index 0000000000..a20621c630 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt @@ -0,0 +1,121 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [32] Instrumented.cshtml) + IntermediateToken - (2:0,2 [32] Instrumented.cshtml) - CSharp - \n int i = 1;\n var foo = + Template - (35:2,15 [10] Instrumented.cshtml) + HtmlContent - (35:2,15 [10] Instrumented.cshtml) + IntermediateToken - (35:2,15 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (38:2,18 [3] Instrumented.cshtml) - Html - Bar + IntermediateToken - (41:2,21 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (45:2,25 [7] Instrumented.cshtml) + IntermediateToken - (45:2,25 [7] Instrumented.cshtml) - CSharp - ;\n + HtmlContent - (54:3,6 [14] Instrumented.cshtml) + IntermediateToken - (54:3,6 [14] Instrumented.cshtml) - Html - Hello, World\n + CSharpCode - (68:4,0 [4] Instrumented.cshtml) + IntermediateToken - (68:4,0 [4] Instrumented.cshtml) - CSharp - + HtmlContent - (72:4,4 [19] Instrumented.cshtml) + IntermediateToken - (72:4,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (75:4,7 [12] Instrumented.cshtml) - Html - Hello, World + IntermediateToken - (87:4,19 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (91:4,23 [2] Instrumented.cshtml) + IntermediateToken - (91:4,23 [2] Instrumented.cshtml) - CSharp - \n + HtmlContent - (96:6,0 [2] Instrumented.cshtml) + IntermediateToken - (96:6,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (99:7,1 [22] Instrumented.cshtml) + IntermediateToken - (99:7,1 [22] Instrumented.cshtml) - CSharp - while(i <= 10) {\n + HtmlContent - (121:8,4 [19] Instrumented.cshtml) + IntermediateToken - (121:8,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (124:8,7 [16] Instrumented.cshtml) - Html - Hello from C#, # + CSharpExpression - (142:8,25 [1] Instrumented.cshtml) + IntermediateToken - (142:8,25 [1] Instrumented.cshtml) - CSharp - i + HtmlContent - (144:8,27 [4] Instrumented.cshtml) + IntermediateToken - (144:8,27 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (148:8,31 [16] Instrumented.cshtml) + IntermediateToken - (148:8,31 [16] Instrumented.cshtml) - CSharp - \n i += 1;\n} + HtmlContent - (164:10,1 [4] Instrumented.cshtml) + IntermediateToken - (164:10,1 [4] Instrumented.cshtml) - Html - \n\n + CSharpCode - (169:12,1 [19] Instrumented.cshtml) + IntermediateToken - (169:12,1 [19] Instrumented.cshtml) - CSharp - if(i == 11) {\n + HtmlContent - (188:13,4 [25] Instrumented.cshtml) + IntermediateToken - (188:13,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (191:13,7 [18] Instrumented.cshtml) - Html - We wrote 10 lines! + IntermediateToken - (209:13,25 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (213:13,29 [3] Instrumented.cshtml) + IntermediateToken - (213:13,29 [3] Instrumented.cshtml) - CSharp - \n} + HtmlContent - (216:14,1 [4] Instrumented.cshtml) + IntermediateToken - (216:14,1 [4] Instrumented.cshtml) - Html - \n\n + CSharpCode - (221:16,1 [35] Instrumented.cshtml) + IntermediateToken - (221:16,1 [35] Instrumented.cshtml) - CSharp - switch(i) {\n case 11:\n + HtmlContent - (256:18,8 [36] Instrumented.cshtml) + IntermediateToken - (256:18,8 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (259:18,11 [29] Instrumented.cshtml) - Html - No really, we wrote 10 lines! + IntermediateToken - (288:18,40 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (292:18,44 [40] Instrumented.cshtml) + IntermediateToken - (292:18,44 [40] Instrumented.cshtml) - CSharp - \n break;\n default:\n + HtmlContent - (332:21,8 [29] Instrumented.cshtml) + IntermediateToken - (332:21,8 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (335:21,11 [22] Instrumented.cshtml) - Html - Actually, we didn't... + IntermediateToken - (357:21,33 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (361:21,37 [19] Instrumented.cshtml) + IntermediateToken - (361:21,37 [19] Instrumented.cshtml) - CSharp - \n break;\n} + HtmlContent - (380:23,1 [4] Instrumented.cshtml) + IntermediateToken - (380:23,1 [4] Instrumented.cshtml) - Html - \n\n + CSharpCode - (385:25,1 [39] Instrumented.cshtml) + IntermediateToken - (385:25,1 [39] Instrumented.cshtml) - CSharp - for(int j = 1; j <= 10; j += 2) {\n + HtmlContent - (424:26,4 [25] Instrumented.cshtml) + IntermediateToken - (424:26,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (427:26,7 [22] Instrumented.cshtml) - Html - Hello again from C#, # + CSharpExpression - (451:26,31 [1] Instrumented.cshtml) + IntermediateToken - (451:26,31 [1] Instrumented.cshtml) - CSharp - j + HtmlContent - (453:26,33 [4] Instrumented.cshtml) + IntermediateToken - (453:26,33 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (457:26,37 [3] Instrumented.cshtml) + IntermediateToken - (457:26,37 [3] Instrumented.cshtml) - CSharp - \n} + HtmlContent - (460:27,1 [4] Instrumented.cshtml) + IntermediateToken - (460:27,1 [4] Instrumented.cshtml) - Html - \n\n + CSharpCode - (465:29,1 [11] Instrumented.cshtml) + IntermediateToken - (465:29,1 [11] Instrumented.cshtml) - CSharp - try {\n + HtmlContent - (476:30,4 [35] Instrumented.cshtml) + IntermediateToken - (476:30,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (479:30,7 [28] Instrumented.cshtml) - Html - That time, we wrote 5 lines! + IntermediateToken - (507:30,35 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (511:30,39 [31] Instrumented.cshtml) + IntermediateToken - (511:30,39 [31] Instrumented.cshtml) - CSharp - \n} catch(Exception ex) {\n + HtmlContent - (542:32,4 [29] Instrumented.cshtml) + IntermediateToken - (542:32,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (545:32,7 [26] Instrumented.cshtml) - Html - Oh no! An error occurred: + CSharpExpression - (573:32,35 [10] Instrumented.cshtml) + IntermediateToken - (573:32,35 [10] Instrumented.cshtml) - CSharp - ex.Message + HtmlContent - (584:32,46 [4] Instrumented.cshtml) + IntermediateToken - (584:32,46 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (588:32,50 [3] Instrumented.cshtml) + IntermediateToken - (588:32,50 [3] Instrumented.cshtml) - CSharp - \n} + HtmlContent - (591:33,1 [4] Instrumented.cshtml) + IntermediateToken - (591:33,1 [4] Instrumented.cshtml) - Html - \n\n + CSharpCode - (596:35,1 [26] Instrumented.cshtml) + IntermediateToken - (596:35,1 [26] Instrumented.cshtml) - CSharp - lock(new object()) {\n + HtmlContent - (622:36,4 [47] Instrumented.cshtml) + IntermediateToken - (622:36,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (625:36,7 [40] Instrumented.cshtml) - Html - This block is locked, for your security! + IntermediateToken - (665:36,47 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (669:36,51 [3] Instrumented.cshtml) + IntermediateToken - (669:36,51 [3] Instrumented.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt new file mode 100644 index 0000000000..250678a268 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.mappings.txt @@ -0,0 +1,153 @@ +Source Location: (2:0,2 [32] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| + int i = 1; + var foo = | +Generated Location: (744:19,2 [32] ) +| + int i = 1; + var foo = | + +Source Location: (45:2,25 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|; + | +Generated Location: (1060:31,25 [7] ) +|; + | + +Source Location: (68:4,0 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| | +Generated Location: (1226:39,0 [4] ) +| | + +Source Location: (91:4,23 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| +| +Generated Location: (1412:46,23 [2] ) +| +| + +Source Location: (99:7,1 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|while(i <= 10) { + | +Generated Location: (1572:53,1 [22] ) +|while(i <= 10) { + | + +Source Location: (142:8,25 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|i| +Generated Location: (1778:61,25 [1] ) +|i| + +Source Location: (148:8,31 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| + i += 1; +}| +Generated Location: (1970:68,31 [16] ) +| + i += 1; +}| + +Source Location: (169:12,1 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|if(i == 11) { + | +Generated Location: (2147:77,1 [19] ) +|if(i == 11) { + | + +Source Location: (213:13,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| +}| +Generated Location: (2355:85,29 [3] ) +| +}| + +Source Location: (221:16,1 [35] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|switch(i) { + case 11: + | +Generated Location: (2519:93,1 [35] ) +|switch(i) { + case 11: + | + +Source Location: (292:18,44 [40] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| + break; + default: + | +Generated Location: (2758:102,44 [40] ) +| + break; + default: + | + +Source Location: (361:21,37 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| + break; +}| +Generated Location: (2995:112,37 [19] ) +| + break; +}| + +Source Location: (385:25,1 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|for(int j = 1; j <= 10; j += 2) { + | +Generated Location: (3175:121,1 [39] ) +|for(int j = 1; j <= 10; j += 2) { + | + +Source Location: (451:26,31 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|j| +Generated Location: (3405:129,31 [1] ) +|j| + +Source Location: (457:26,37 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| +}| +Generated Location: (3604:136,37 [3] ) +| +}| + +Source Location: (465:29,1 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|try { + | +Generated Location: (3768:144,1 [11] ) +|try { + | + +Source Location: (511:30,39 [31] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| +} catch(Exception ex) { + | +Generated Location: (3978:152,39 [31] ) +| +} catch(Exception ex) { + | + +Source Location: (573:32,35 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|ex.Message| +Generated Location: (4204:161,35 [10] ) +|ex.Message| + +Source Location: (588:32,50 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| +}| +Generated Location: (4425:168,50 [3] ) +| +}| + +Source Location: (596:35,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +|lock(new object()) { + | +Generated Location: (4589:176,1 [26] ) +|lock(new object()) { + | + +Source Location: (669:36,51 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml) +| +}| +Generated Location: (4826:184,51 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs new file mode 100644 index 0000000000..4ece1be3bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.codegen.cs @@ -0,0 +1,182 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3d0d9c94b62eeccf0a2a106b257a1ea1e22412a9" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"3d0d9c94b62eeccf0a2a106b257a1ea1e22412a9", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + + int i = 1; + var foo = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + WriteLiteral("

        Bar

        "); + PopWriter(); + } + ) +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + ; + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + WriteLiteral("Hello, World\r\n

        Hello, World

        \r\n"); + WriteLiteral("\r\n"); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + while(i <= 10) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello from C#, #"); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + i += 1; +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + if(i == 11) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        We wrote 10 lines!

        \r\n"); +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + switch(i) { + case 11: + +#line default +#line hidden +#nullable disable + WriteLiteral("

        No really, we wrote 10 lines!

        \r\n"); +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + break; + default: + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Actually, we didn\'t...

        \r\n"); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + break; +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + for(int j = 1; j <= 10; j += 2) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello again from C#, #"); +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + Write(j); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + try { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        That time, we wrote 5 lines!

        \r\n"); +#nullable restore +#line 32 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" +} catch(Exception ex) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Oh no! An error occurred: "); +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + Write(ex.Message); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" + lock(new object()) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        This block is locked, for your security!

        \r\n"); +#nullable restore +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt new file mode 100644 index 0000000000..ac485414f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_Runtime.ir.txt @@ -0,0 +1,133 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [32] Instrumented.cshtml) + IntermediateToken - (2:0,2 [32] Instrumented.cshtml) - CSharp - \n int i = 1;\n var foo = + Template - (35:2,15 [10] Instrumented.cshtml) + HtmlContent - (35:2,15 [10] Instrumented.cshtml) + IntermediateToken - (35:2,15 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (38:2,18 [3] Instrumented.cshtml) - Html - Bar + IntermediateToken - (41:2,21 [4] Instrumented.cshtml) - Html -

        + CSharpCode - (45:2,25 [3] Instrumented.cshtml) + IntermediateToken - (45:2,25 [3] Instrumented.cshtml) - CSharp - ;\n + HtmlContent - (48:3,0 [4] Instrumented.cshtml) + IntermediateToken - (48:3,0 [4] Instrumented.cshtml) - Html - + HtmlContent - (54:3,6 [39] Instrumented.cshtml) + IntermediateToken - (54:3,6 [14] Instrumented.cshtml) - Html - Hello, World\n + IntermediateToken - (68:4,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (72:4,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (75:4,7 [12] Instrumented.cshtml) - Html - Hello, World + IntermediateToken - (87:4,19 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (91:4,23 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (93:5,0 [0] Instrumented.cshtml) + IntermediateToken - (93:5,0 [0] Instrumented.cshtml) - CSharp - + HtmlContent - (96:6,0 [2] Instrumented.cshtml) + IntermediateToken - (96:6,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (99:7,1 [18] Instrumented.cshtml) + IntermediateToken - (99:7,1 [18] Instrumented.cshtml) - CSharp - while(i <= 10) {\n + HtmlContent - (117:8,0 [23] Instrumented.cshtml) + IntermediateToken - (117:8,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (121:8,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (124:8,7 [16] Instrumented.cshtml) - Html - Hello from C#, # + CSharpExpression - (142:8,25 [1] Instrumented.cshtml) + IntermediateToken - (142:8,25 [1] Instrumented.cshtml) - CSharp - i + HtmlContent - (144:8,27 [6] Instrumented.cshtml) + IntermediateToken - (144:8,27 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (148:8,31 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (150:9,0 [16] Instrumented.cshtml) + IntermediateToken - (150:9,0 [16] Instrumented.cshtml) - CSharp - i += 1;\n}\n + HtmlContent - (166:11,0 [2] Instrumented.cshtml) + IntermediateToken - (166:11,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (169:12,1 [15] Instrumented.cshtml) + IntermediateToken - (169:12,1 [15] Instrumented.cshtml) - CSharp - if(i == 11) {\n + HtmlContent - (184:13,0 [31] Instrumented.cshtml) + IntermediateToken - (184:13,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (188:13,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (191:13,7 [18] Instrumented.cshtml) - Html - We wrote 10 lines! + IntermediateToken - (209:13,25 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (213:13,29 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (215:14,0 [3] Instrumented.cshtml) + IntermediateToken - (215:14,0 [3] Instrumented.cshtml) - CSharp - }\n + HtmlContent - (218:15,0 [2] Instrumented.cshtml) + IntermediateToken - (218:15,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (221:16,1 [27] Instrumented.cshtml) + IntermediateToken - (221:16,1 [27] Instrumented.cshtml) - CSharp - switch(i) {\n case 11:\n + HtmlContent - (248:18,0 [46] Instrumented.cshtml) + IntermediateToken - (248:18,0 [8] Instrumented.cshtml) - Html - + IntermediateToken - (256:18,8 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (259:18,11 [29] Instrumented.cshtml) - Html - No really, we wrote 10 lines! + IntermediateToken - (288:18,40 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (292:18,44 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (294:19,0 [30] Instrumented.cshtml) + IntermediateToken - (294:19,0 [30] Instrumented.cshtml) - CSharp - break;\n default:\n + HtmlContent - (324:21,0 [39] Instrumented.cshtml) + IntermediateToken - (324:21,0 [8] Instrumented.cshtml) - Html - + IntermediateToken - (332:21,8 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (335:21,11 [22] Instrumented.cshtml) - Html - Actually, we didn't... + IntermediateToken - (357:21,33 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (361:21,37 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (363:22,0 [19] Instrumented.cshtml) + IntermediateToken - (363:22,0 [19] Instrumented.cshtml) - CSharp - break;\n}\n + HtmlContent - (382:24,0 [2] Instrumented.cshtml) + IntermediateToken - (382:24,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (385:25,1 [35] Instrumented.cshtml) + IntermediateToken - (385:25,1 [35] Instrumented.cshtml) - CSharp - for(int j = 1; j <= 10; j += 2) {\n + HtmlContent - (420:26,0 [29] Instrumented.cshtml) + IntermediateToken - (420:26,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (424:26,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (427:26,7 [22] Instrumented.cshtml) - Html - Hello again from C#, # + CSharpExpression - (451:26,31 [1] Instrumented.cshtml) + IntermediateToken - (451:26,31 [1] Instrumented.cshtml) - CSharp - j + HtmlContent - (453:26,33 [6] Instrumented.cshtml) + IntermediateToken - (453:26,33 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (457:26,37 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (459:27,0 [3] Instrumented.cshtml) + IntermediateToken - (459:27,0 [3] Instrumented.cshtml) - CSharp - }\n + HtmlContent - (462:28,0 [2] Instrumented.cshtml) + IntermediateToken - (462:28,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (465:29,1 [7] Instrumented.cshtml) + IntermediateToken - (465:29,1 [7] Instrumented.cshtml) - CSharp - try {\n + HtmlContent - (472:30,0 [41] Instrumented.cshtml) + IntermediateToken - (472:30,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (476:30,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (479:30,7 [28] Instrumented.cshtml) - Html - That time, we wrote 5 lines! + IntermediateToken - (507:30,35 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (511:30,39 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (513:31,0 [25] Instrumented.cshtml) + IntermediateToken - (513:31,0 [25] Instrumented.cshtml) - CSharp - } catch(Exception ex) {\n + HtmlContent - (538:32,0 [33] Instrumented.cshtml) + IntermediateToken - (538:32,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (542:32,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (545:32,7 [26] Instrumented.cshtml) - Html - Oh no! An error occurred: + CSharpExpression - (573:32,35 [10] Instrumented.cshtml) + IntermediateToken - (573:32,35 [10] Instrumented.cshtml) - CSharp - ex.Message + HtmlContent - (584:32,46 [6] Instrumented.cshtml) + IntermediateToken - (584:32,46 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (588:32,50 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (590:33,0 [3] Instrumented.cshtml) + IntermediateToken - (590:33,0 [3] Instrumented.cshtml) - CSharp - }\n + HtmlContent - (593:34,0 [2] Instrumented.cshtml) + IntermediateToken - (593:34,0 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (596:35,1 [22] Instrumented.cshtml) + IntermediateToken - (596:35,1 [22] Instrumented.cshtml) - CSharp - lock(new object()) {\n + HtmlContent - (618:36,0 [53] Instrumented.cshtml) + IntermediateToken - (618:36,0 [4] Instrumented.cshtml) - Html - + IntermediateToken - (622:36,4 [2] Instrumented.cshtml) - Html -

        + IntermediateToken - (625:36,7 [40] Instrumented.cshtml) - Html - This block is locked, for your security! + IntermediateToken - (665:36,47 [4] Instrumented.cshtml) - Html -

        + IntermediateToken - (669:36,51 [2] Instrumented.cshtml) - Html - \n + CSharpCode - (671:37,0 [1] Instrumented.cshtml) + IntermediateToken - (671:37,0 [1] Instrumented.cshtml) - CSharp - } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml new file mode 100644 index 0000000000..712ef42848 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml @@ -0,0 +1,5 @@ +@{ + for(int i = 1; i <= 10; i++) { +

        Hello from C#, #@(i.ToString())

        + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.codegen.cs new file mode 100644 index 0000000000..cdf9ba3334 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.codegen.cs @@ -0,0 +1,46 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" + + for(int i = 1; i <= 10; i++) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" + __o = i.ToString(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" + + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.codegen.html new file mode 100644 index 0000000000..9148ce7323 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.codegen.html @@ -0,0 +1,5 @@ + + +

        Hello from C#, #

        + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt new file mode 100644 index 0000000000..1c5e460f3c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [46] MarkupInCodeBlock.cshtml) + IntermediateToken - (2:0,2 [46] MarkupInCodeBlock.cshtml) - CSharp - \n for(int i = 1; i <= 10; i++) {\n + HtmlContent - (48:2,8 [19] MarkupInCodeBlock.cshtml) + IntermediateToken - (48:2,8 [2] MarkupInCodeBlock.cshtml) - Html -

        + IntermediateToken - (51:2,11 [16] MarkupInCodeBlock.cshtml) - Html - Hello from C#, # + CSharpExpression - (69:2,29 [12] MarkupInCodeBlock.cshtml) + IntermediateToken - (69:2,29 [12] MarkupInCodeBlock.cshtml) - CSharp - i.ToString() + HtmlContent - (82:2,42 [4] MarkupInCodeBlock.cshtml) + IntermediateToken - (82:2,42 [4] MarkupInCodeBlock.cshtml) - Html -

        + CSharpCode - (86:2,46 [9] MarkupInCodeBlock.cshtml) + IntermediateToken - (86:2,46 [9] MarkupInCodeBlock.cshtml) - CSharp - \n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.mappings.txt new file mode 100644 index 0000000000..f88beb53f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.mappings.txt @@ -0,0 +1,23 @@ +Source Location: (2:0,2 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml) +| + for(int i = 1; i <= 10; i++) { + | +Generated Location: (754:19,2 [46] ) +| + for(int i = 1; i <= 10; i++) { + | + +Source Location: (69:2,29 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml) +|i.ToString()| +Generated Location: (993:28,29 [12] ) +|i.ToString()| + +Source Location: (86:2,46 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml) +| + } +| +Generated Location: (1216:35,46 [9] ) +| + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs new file mode 100644 index 0000000000..a578762a04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.codegen.cs @@ -0,0 +1,42 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "539d5763b7091d29df375085f623b9086e7f8ad6" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"539d5763b7091d29df375085f623b9086e7f8ad6", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" + + for(int i = 1; i <= 10; i++) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello from C#, #"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" + Write(i.ToString()); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock.cshtml" + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt new file mode 100644 index 0000000000..d517c6d4ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_Runtime.ir.txt @@ -0,0 +1,20 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [38] MarkupInCodeBlock.cshtml) + IntermediateToken - (2:0,2 [38] MarkupInCodeBlock.cshtml) - CSharp - \n for(int i = 1; i <= 10; i++) {\n + HtmlContent - (40:2,0 [27] MarkupInCodeBlock.cshtml) + IntermediateToken - (40:2,0 [8] MarkupInCodeBlock.cshtml) - Html - + IntermediateToken - (48:2,8 [2] MarkupInCodeBlock.cshtml) - Html -

        + IntermediateToken - (51:2,11 [16] MarkupInCodeBlock.cshtml) - Html - Hello from C#, # + CSharpExpression - (69:2,29 [12] MarkupInCodeBlock.cshtml) + IntermediateToken - (69:2,29 [12] MarkupInCodeBlock.cshtml) - CSharp - i.ToString() + HtmlContent - (82:2,42 [6] MarkupInCodeBlock.cshtml) + IntermediateToken - (82:2,42 [4] MarkupInCodeBlock.cshtml) - Html -

        + IntermediateToken - (86:2,46 [2] MarkupInCodeBlock.cshtml) - Html - \n + CSharpCode - (88:3,0 [7] MarkupInCodeBlock.cshtml) + IntermediateToken - (88:3,0 [7] MarkupInCodeBlock.cshtml) - CSharp - }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml new file mode 100644 index 0000000000..efc9795e71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml @@ -0,0 +1,45 @@ + +@{ + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, } + }; + + void PrintName(Person person) + { +
        @person.Name
        + } +} + +@{ PrintName(people[0]) } +@{ AnnounceBirthday(people[0]); } + +@functions { + void AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; +
        +

        Happy birthday @(formatted)!

        +
        + +
          + @for (var i = 0; i < person.Age / 10; i++) + { +
        • @(i) Happy birthday!
        • + } +
        + + if (person.Age < 20) + { + return; + } + +

        Secret message

        + } + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml new file mode 100644 index 0000000000..f294f34162 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml @@ -0,0 +1,47 @@ +@addTagHelper "*, TestAssembly" +@{ + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, }, + }; + + void PrintName(Person person) + { +
        @person.Name
        + } +} + +@{ PrintName(people[0]); } +@{ await AnnounceBirthday(people[0]); } + +@functions { + Task AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; +
        +

        Happy birthday @(formatted)!

        +
        + +
          + @for (var i = 0; i < person.Age / 10; i++) + { +
        • @(i) Happy birthday!
        • + } +
        + + if (person.Age < 20) + { + return Task.CompletedTask; + } + +

        Secret message

        + return Task.CompletedTask; + } + + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..ed77c73e5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.codegen.cs @@ -0,0 +1,167 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocksWithTagHelper_DesignTime + { + #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::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, }, + }; + + void PrintName(Person person) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + __o = person.Name; + +#line default +#line hidden +#nullable disable + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + PrintName(people[0]); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + await AnnounceBirthday(people[0]); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + Task AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + __o = formatted; + +#line default +#line hidden +#nullable disable + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + for (var i = 0; i < person.Age / 10; i++) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + + if (person.Age < 20) + { + return Task.CompletedTask; + } + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + return Task.CompletedTask; + } + + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..37532809ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.ir.txt @@ -0,0 +1,81 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocksWithTagHelper_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] Markup_InCodeBlocksWithTagHelper.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (31:0,31 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (35:1,2 [154] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (35:1,2 [154] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n var people = new Person[]\n {\n new Person() { Name = "Taylor", Age = 95, },\n };\n\n void PrintName(Person person)\n {\n + TagHelper - (189:9,8 [23] Markup_InCodeBlocksWithTagHelper.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpExpression - (195:9,14 [11] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (195:9,14 [11] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - person.Name + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + CSharpCode - (212:9,31 [9] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (212:9,31 [9] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n }\n + HtmlContent - (224:12,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (224:12,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (228:13,2 [23] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (228:13,2 [23] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - PrintName(people[0]); + CSharpCode - (256:14,2 [36] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (256:14,2 [36] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - await AnnounceBirthday(people[0]); + HtmlContent - (295:15,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (295:15,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (309:16,12 [106] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (309:16,12 [106] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n Task AnnounceBirthday(Person person)\n {\n var formatted = $"Mr. {person.Name}";\n + TagHelper - (415:20,8 [72] Markup_InCodeBlocksWithTagHelper.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (420:20,13 [33] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (420:20,13 [14] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + IntermediateToken - (434:21,12 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (438:21,16 [15] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - Happy birthday + CSharpExpression - (455:21,33 [9] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (455:21,33 [9] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - formatted + HtmlContent - (465:21,43 [16] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (465:21,43 [1] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - ! + IntermediateToken - (466:21,44 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (471:21,49 [10] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + CSharpCode - (487:22,14 [12] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (487:22,14 [12] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n\n + HtmlContent - (499:24,8 [14] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (499:24,8 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
          + IntermediateToken - (503:24,12 [10] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (514:25,9 [66] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (514:25,9 [66] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - for (var i = 0; i < person.Age / 10; i++)\n {\n + HtmlContent - (580:27,12 [4] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (580:27,12 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
        • + CSharpExpression - (586:27,18 [1] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (586:27,18 [1] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - i + HtmlContent - (588:27,20 [21] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (588:27,20 [16] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - Happy birthday! + IntermediateToken - (604:27,36 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
        • + CSharpCode - (609:27,41 [11] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (609:27,41 [11] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n } + HtmlContent - (620:28,9 [15] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (620:28,9 [10] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + IntermediateToken - (630:29,8 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
        + CSharpCode - (635:29,13 [106] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (635:29,13 [106] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n\n if (person.Age < 20)\n {\n return Task.CompletedTask;\n }\n\n + HtmlContent - (741:36,8 [23] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (741:36,8 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (745:36,12 [14] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - Secret message + IntermediateToken - (759:36,26 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + CSharpCode - (764:36,31 [161] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (764:36,31 [161] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n return Task.CompletedTask;\n }\n\n\n class Person\n {\n public string Name { get; set; }\n public int Age { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..d5b99f4dfa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_DesignTime.mappings.txt @@ -0,0 +1,142 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +|"*, TestAssembly"| +Generated Location: (1027:18,37 [17] ) +|"*, TestAssembly"| + +Source Location: (35:1,2 [154] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, }, + }; + + void PrintName(Person person) + { + | +Generated Location: (1540:35,2 [154] ) +| + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, }, + }; + + void PrintName(Person person) + { + | + +Source Location: (195:9,14 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +|person.Name| +Generated Location: (1888:50,14 [11] ) +|person.Name| + +Source Location: (212:9,31 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + } +| +Generated Location: (2258:59,31 [9] ) +| + } +| + +Source Location: (228:13,2 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| PrintName(people[0]); | +Generated Location: (2447:67,2 [23] ) +| PrintName(people[0]); | + +Source Location: (256:14,2 [36] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| await AnnounceBirthday(people[0]); | +Generated Location: (2652:74,2 [36] ) +| await AnnounceBirthday(people[0]); | + +Source Location: (309:16,12 [106] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + Task AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + | +Generated Location: (2929:83,12 [106] ) +| + Task AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + | + +Source Location: (455:21,33 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +|formatted| +Generated Location: (3248:94,33 [9] ) +|formatted| + +Source Location: (487:22,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + + | +Generated Location: (3591:103,14 [12] ) +| + + | + +Source Location: (514:25,9 [66] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +|for (var i = 0; i < person.Age / 10; i++) + { + | +Generated Location: (3792:112,9 [66] ) +|for (var i = 0; i < person.Age / 10; i++) + { + | + +Source Location: (586:27,18 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +|i| +Generated Location: (4056:121,18 [1] ) +|i| + +Source Location: (609:27,41 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + }| +Generated Location: (4279:128,41 [11] ) +| + }| + +Source Location: (635:29,13 [106] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + + if (person.Age < 20) + { + return Task.CompletedTask; + } + + | +Generated Location: (4483:136,13 [106] ) +| + + if (person.Age < 20) + { + return Task.CompletedTask; + } + + | + +Source Location: (764:36,31 [161] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml) +| + return Task.CompletedTask; + } + + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } +| +Generated Location: (4800:150,31 [161] ) +| + return Task.CompletedTask; + } + + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..6f01cf5fcb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_Runtime.codegen.cs @@ -0,0 +1,184 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ffae7582d6e0ce50a5fa046a92205df5abc84d6e" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocksWithTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"ffae7582d6e0ce50a5fa046a92205df5abc84d6e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocksWithTagHelper_Runtime + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, }, + }; + + void PrintName(Person person) + { + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + Write(person.Name); + +#line default +#line hidden +#nullable disable + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + PrintName(people[0]); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + await AnnounceBirthday(people[0]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + Task AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + +#line default +#line hidden +#nullable disable + WriteLiteral(" "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n

        Happy birthday "); +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + Write(formatted); + +#line default +#line hidden +#nullable disable + WriteLiteral("!

        \r\n "); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + WriteLiteral("
          \r\n"); +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + for (var i = 0; i < person.Age / 10; i++) + { + +#line default +#line hidden +#nullable disable + WriteLiteral("
        • "); +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral(" Happy birthday!
        • \r\n"); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral("
        \r\n"); +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + + if (person.Age < 20) + { + return Task.CompletedTask; + } + + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Secret message

        \r\n"); +#nullable restore +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper.cshtml" + return Task.CompletedTask; + } + + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..4263327a2e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocksWithTagHelper_Runtime.ir.txt @@ -0,0 +1,89 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocksWithTagHelper_Runtime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (35:1,2 [146] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (35:1,2 [146] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n var people = new Person[]\n {\n new Person() { Name = "Taylor", Age = 95, },\n };\n\n void PrintName(Person person)\n {\n + HtmlContent - (181:9,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (181:9,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - + TagHelper - (189:9,8 [23] Markup_InCodeBlocksWithTagHelper.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + CSharpExpression - (195:9,14 [11] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (195:9,14 [11] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - person.Name + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + HtmlContent - (212:9,31 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (212:9,31 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (214:10,0 [7] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (214:10,0 [7] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - }\n + HtmlContent - (224:12,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (224:12,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (228:13,2 [23] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (228:13,2 [23] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - PrintName(people[0]); + CSharpCode - (256:14,2 [36] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (256:14,2 [36] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - await AnnounceBirthday(people[0]); + HtmlContent - (295:15,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (295:15,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (309:16,12 [98] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (309:16,12 [98] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n Task AnnounceBirthday(Person person)\n {\n var formatted = $"Mr. {person.Name}";\n + HtmlContent - (407:20,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (407:20,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - + TagHelper - (415:20,8 [72] Markup_InCodeBlocksWithTagHelper.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (420:20,13 [33] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (420:20,13 [14] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + IntermediateToken - (434:21,12 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (438:21,16 [15] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - Happy birthday + CSharpExpression - (455:21,33 [9] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (455:21,33 [9] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - formatted + HtmlContent - (465:21,43 [16] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (465:21,43 [1] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - ! + IntermediateToken - (466:21,44 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (471:21,49 [10] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + HtmlContent - (487:22,14 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (487:22,14 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (489:23,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (489:23,0 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n + HtmlContent - (491:24,0 [14] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (491:24,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - + IntermediateToken - (499:24,8 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
          + IntermediateToken - (503:24,12 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (505:25,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (505:25,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - + CSharpCode - (514:25,9 [54] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (514:25,9 [54] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - for (var i = 0; i < person.Age / 10; i++)\n {\n + HtmlContent - (568:27,0 [16] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (568:27,0 [12] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - + IntermediateToken - (580:27,12 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
        • + CSharpExpression - (586:27,18 [1] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (586:27,18 [1] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - i + HtmlContent - (588:27,20 [23] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (588:27,20 [16] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - Happy birthday! + IntermediateToken - (604:27,36 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
        • + IntermediateToken - (609:27,41 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (611:28,0 [11] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (611:28,0 [11] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - }\n + HtmlContent - (622:29,0 [15] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (622:29,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - + IntermediateToken - (630:29,8 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -
        + IntermediateToken - (635:29,13 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (637:30,0 [96] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (637:30,0 [96] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - \n if (person.Age < 20)\n {\n return Task.CompletedTask;\n }\n\n + HtmlContent - (733:36,0 [33] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (733:36,0 [8] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - + IntermediateToken - (741:36,8 [3] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (745:36,12 [14] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - Secret message + IntermediateToken - (759:36,26 [5] Markup_InCodeBlocksWithTagHelper.cshtml) - Html -

        + IntermediateToken - (764:36,31 [2] Markup_InCodeBlocksWithTagHelper.cshtml) - Html - \n + CSharpCode - (766:37,0 [159] Markup_InCodeBlocksWithTagHelper.cshtml) + IntermediateToken - (766:37,0 [159] Markup_InCodeBlocksWithTagHelper.cshtml) - CSharp - return Task.CompletedTask;\n }\n\n\n class Person\n {\n public string Name { get; set; }\n public int Age { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.codegen.cs new file mode 100644 index 0000000000..1c7c4784f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.codegen.cs @@ -0,0 +1,145 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocks_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, } + }; + + void PrintName(Person person) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + __o = person.Name; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + PrintName(people[0]) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + AnnounceBirthday(people[0]); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + void AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + __o = formatted; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + for (var i = 0; i < person.Age / 10; i++) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + + if (person.Age < 20) + { + return; + } + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + } + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.codegen.html new file mode 100644 index 0000000000..4b346c914a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.codegen.html @@ -0,0 +1,45 @@ + + + + + + + + + +
        + + + + + + + + + + +
        +

        Happy birthday !

        +
        + +
          + + +
        • Happy birthday!
        • + +
        + + + + + + +

        Secret message

        + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.ir.txt new file mode 100644 index 0000000000..5307e83bb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.ir.txt @@ -0,0 +1,78 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocks_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (0:0,0 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (4:1,2 [153] Markup_InCodeBlocks.cshtml) + IntermediateToken - (4:1,2 [153] Markup_InCodeBlocks.cshtml) - CSharp - \n var people = new Person[]\n {\n new Person() { Name = "Taylor", Age = 95, }\n };\n\n void PrintName(Person person)\n {\n + HtmlContent - (157:9,8 [5] Markup_InCodeBlocks.cshtml) + IntermediateToken - (157:9,8 [4] Markup_InCodeBlocks.cshtml) - Html -
        + CSharpExpression - (163:9,14 [11] Markup_InCodeBlocks.cshtml) + IntermediateToken - (163:9,14 [11] Markup_InCodeBlocks.cshtml) - CSharp - person.Name + HtmlContent - (174:9,25 [6] Markup_InCodeBlocks.cshtml) + IntermediateToken - (174:9,25 [6] Markup_InCodeBlocks.cshtml) - Html -
        + CSharpCode - (180:9,31 [9] Markup_InCodeBlocks.cshtml) + IntermediateToken - (180:9,31 [9] Markup_InCodeBlocks.cshtml) - CSharp - \n }\n + HtmlContent - (192:12,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (192:12,0 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (196:13,2 [22] Markup_InCodeBlocks.cshtml) + IntermediateToken - (196:13,2 [22] Markup_InCodeBlocks.cshtml) - CSharp - PrintName(people[0]) + CSharpCode - (223:14,2 [30] Markup_InCodeBlocks.cshtml) + IntermediateToken - (223:14,2 [30] Markup_InCodeBlocks.cshtml) - CSharp - AnnounceBirthday(people[0]); + HtmlContent - (256:15,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (256:15,0 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (270:16,12 [106] Markup_InCodeBlocks.cshtml) + IntermediateToken - (270:16,12 [106] Markup_InCodeBlocks.cshtml) - CSharp - \n void AnnounceBirthday(Person person)\n {\n var formatted = $"Mr. {person.Name}";\n + HtmlContent - (376:20,8 [38] Markup_InCodeBlocks.cshtml) + IntermediateToken - (376:20,8 [4] Markup_InCodeBlocks.cshtml) - Html -
        + IntermediateToken - (381:20,13 [14] Markup_InCodeBlocks.cshtml) - Html - \n + IntermediateToken - (395:21,12 [3] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (399:21,16 [15] Markup_InCodeBlocks.cshtml) - Html - Happy birthday + CSharpExpression - (416:21,33 [9] Markup_InCodeBlocks.cshtml) + IntermediateToken - (416:21,33 [9] Markup_InCodeBlocks.cshtml) - CSharp - formatted + HtmlContent - (426:21,43 [22] Markup_InCodeBlocks.cshtml) + IntermediateToken - (426:21,43 [1] Markup_InCodeBlocks.cshtml) - Html - ! + IntermediateToken - (427:21,44 [5] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (432:21,49 [10] Markup_InCodeBlocks.cshtml) - Html - \n + IntermediateToken - (442:22,8 [6] Markup_InCodeBlocks.cshtml) - Html -
        + CSharpCode - (448:22,14 [12] Markup_InCodeBlocks.cshtml) + IntermediateToken - (448:22,14 [12] Markup_InCodeBlocks.cshtml) - CSharp - \n\n + HtmlContent - (460:24,8 [14] Markup_InCodeBlocks.cshtml) + IntermediateToken - (460:24,8 [3] Markup_InCodeBlocks.cshtml) - Html -
          + IntermediateToken - (464:24,12 [10] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (475:25,9 [66] Markup_InCodeBlocks.cshtml) + IntermediateToken - (475:25,9 [66] Markup_InCodeBlocks.cshtml) - CSharp - for (var i = 0; i < person.Age / 10; i++)\n {\n + HtmlContent - (541:27,12 [4] Markup_InCodeBlocks.cshtml) + IntermediateToken - (541:27,12 [3] Markup_InCodeBlocks.cshtml) - Html -
        • + CSharpExpression - (547:27,18 [1] Markup_InCodeBlocks.cshtml) + IntermediateToken - (547:27,18 [1] Markup_InCodeBlocks.cshtml) - CSharp - i + HtmlContent - (549:27,20 [21] Markup_InCodeBlocks.cshtml) + IntermediateToken - (549:27,20 [16] Markup_InCodeBlocks.cshtml) - Html - Happy birthday! + IntermediateToken - (565:27,36 [5] Markup_InCodeBlocks.cshtml) - Html -
        • + CSharpCode - (570:27,41 [11] Markup_InCodeBlocks.cshtml) + IntermediateToken - (570:27,41 [11] Markup_InCodeBlocks.cshtml) - CSharp - \n } + HtmlContent - (581:28,9 [15] Markup_InCodeBlocks.cshtml) + IntermediateToken - (581:28,9 [10] Markup_InCodeBlocks.cshtml) - Html - \n + IntermediateToken - (591:29,8 [5] Markup_InCodeBlocks.cshtml) - Html -
        + CSharpCode - (596:29,13 [87] Markup_InCodeBlocks.cshtml) + IntermediateToken - (596:29,13 [87] Markup_InCodeBlocks.cshtml) - CSharp - \n\n if (person.Age < 20)\n {\n return;\n }\n\n + HtmlContent - (683:36,8 [23] Markup_InCodeBlocks.cshtml) + IntermediateToken - (683:36,8 [3] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (687:36,12 [14] Markup_InCodeBlocks.cshtml) - Html - Secret message + IntermediateToken - (701:36,26 [5] Markup_InCodeBlocks.cshtml) - Html -

        + CSharpCode - (706:36,31 [123] Markup_InCodeBlocks.cshtml) + IntermediateToken - (706:36,31 [123] Markup_InCodeBlocks.cshtml) - CSharp - \n }\n\n class Person\n {\n public string Name { get; set; }\n public int Age { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.mappings.txt new file mode 100644 index 0000000000..de5fb0e1d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_DesignTime.mappings.txt @@ -0,0 +1,133 @@ +Source Location: (4:1,2 [153] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, } + }; + + void PrintName(Person person) + { + | +Generated Location: (758:19,2 [153] ) +| + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, } + }; + + void PrintName(Person person) + { + | + +Source Location: (163:9,14 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +|person.Name| +Generated Location: (1092:34,14 [11] ) +|person.Name| + +Source Location: (180:9,31 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + } +| +Generated Location: (1302:41,31 [9] ) +| + } +| + +Source Location: (196:13,2 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| PrintName(people[0]) | +Generated Location: (1478:49,2 [22] ) +| PrintName(people[0]) | + +Source Location: (223:14,2 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| AnnounceBirthday(people[0]); | +Generated Location: (1669:56,2 [30] ) +| AnnounceBirthday(people[0]); | + +Source Location: (270:16,12 [106] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + void AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + | +Generated Location: (1927:65,12 [106] ) +| + void AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + | + +Source Location: (416:21,33 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +|formatted| +Generated Location: (2233:76,33 [9] ) +|formatted| + +Source Location: (448:22,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + + | +Generated Location: (2424:83,14 [12] ) +| + + | + +Source Location: (475:25,9 [66] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +|for (var i = 0; i < person.Age / 10; i++) + { + | +Generated Location: (2612:92,9 [66] ) +|for (var i = 0; i < person.Age / 10; i++) + { + | + +Source Location: (547:27,18 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +|i| +Generated Location: (2863:101,18 [1] ) +|i| + +Source Location: (570:27,41 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + }| +Generated Location: (3073:108,41 [11] ) +| + }| + +Source Location: (596:29,13 [87] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + + if (person.Age < 20) + { + return; + } + + | +Generated Location: (3264:116,13 [87] ) +| + + if (person.Age < 20) + { + return; + } + + | + +Source Location: (706:36,31 [123] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml) +| + } + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } +| +Generated Location: (3549:130,31 [123] ) +| + } + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_Runtime.codegen.cs new file mode 100644 index 0000000000..bf58bbc6f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_Runtime.codegen.cs @@ -0,0 +1,136 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2320e63391918e8389308263bcd1e9ae3cc8cc46" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2320e63391918e8389308263bcd1e9ae3cc8cc46", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocks_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + var people = new Person[] + { + new Person() { Name = "Taylor", Age = 95, } + }; + + void PrintName(Person person) + { + +#line default +#line hidden +#nullable disable + WriteLiteral("
        "); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + Write(person.Name); + +#line default +#line hidden +#nullable disable + WriteLiteral("
        \r\n"); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + PrintName(people[0]) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + AnnounceBirthday(people[0]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + void AnnounceBirthday(Person person) + { + var formatted = $"Mr. {person.Name}"; + +#line default +#line hidden +#nullable disable + WriteLiteral("
        \r\n

        Happy birthday "); +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + Write(formatted); + +#line default +#line hidden +#nullable disable + WriteLiteral("!

        \r\n
        \r\n"); + WriteLiteral("
          \r\n"); +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + for (var i = 0; i < person.Age / 10; i++) + { + +#line default +#line hidden +#nullable disable + WriteLiteral("
        • "); +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral(" Happy birthday!
        • \r\n"); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral("
        \r\n"); +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + + if (person.Age < 20) + { + return; + } + + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Secret message

        \r\n"); +#nullable restore +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks.cshtml" + } + + class Person + { + public string Name { get; set; } + public int Age { get; set; } + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_Runtime.ir.txt new file mode 100644 index 0000000000..841e57a19a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Markup_InCodeBlocks_Runtime.ir.txt @@ -0,0 +1,85 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Markup_InCodeBlocks_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (0:0,0 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (4:1,2 [145] Markup_InCodeBlocks.cshtml) + IntermediateToken - (4:1,2 [145] Markup_InCodeBlocks.cshtml) - CSharp - \n var people = new Person[]\n {\n new Person() { Name = "Taylor", Age = 95, }\n };\n\n void PrintName(Person person)\n {\n + HtmlContent - (149:9,0 [13] Markup_InCodeBlocks.cshtml) + IntermediateToken - (149:9,0 [8] Markup_InCodeBlocks.cshtml) - Html - + IntermediateToken - (157:9,8 [4] Markup_InCodeBlocks.cshtml) - Html -
        + CSharpExpression - (163:9,14 [11] Markup_InCodeBlocks.cshtml) + IntermediateToken - (163:9,14 [11] Markup_InCodeBlocks.cshtml) - CSharp - person.Name + HtmlContent - (174:9,25 [8] Markup_InCodeBlocks.cshtml) + IntermediateToken - (174:9,25 [6] Markup_InCodeBlocks.cshtml) - Html -
        + IntermediateToken - (180:9,31 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (182:10,0 [7] Markup_InCodeBlocks.cshtml) + IntermediateToken - (182:10,0 [7] Markup_InCodeBlocks.cshtml) - CSharp - }\n + HtmlContent - (192:12,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (192:12,0 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (196:13,2 [22] Markup_InCodeBlocks.cshtml) + IntermediateToken - (196:13,2 [22] Markup_InCodeBlocks.cshtml) - CSharp - PrintName(people[0]) + CSharpCode - (223:14,2 [30] Markup_InCodeBlocks.cshtml) + IntermediateToken - (223:14,2 [30] Markup_InCodeBlocks.cshtml) - CSharp - AnnounceBirthday(people[0]); + HtmlContent - (256:15,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (256:15,0 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (270:16,12 [98] Markup_InCodeBlocks.cshtml) + IntermediateToken - (270:16,12 [98] Markup_InCodeBlocks.cshtml) - CSharp - \n void AnnounceBirthday(Person person)\n {\n var formatted = $"Mr. {person.Name}";\n + HtmlContent - (368:20,0 [46] Markup_InCodeBlocks.cshtml) + IntermediateToken - (368:20,0 [8] Markup_InCodeBlocks.cshtml) - Html - + IntermediateToken - (376:20,8 [4] Markup_InCodeBlocks.cshtml) - Html -
        + IntermediateToken - (381:20,13 [14] Markup_InCodeBlocks.cshtml) - Html - \n + IntermediateToken - (395:21,12 [3] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (399:21,16 [15] Markup_InCodeBlocks.cshtml) - Html - Happy birthday + CSharpExpression - (416:21,33 [9] Markup_InCodeBlocks.cshtml) + IntermediateToken - (416:21,33 [9] Markup_InCodeBlocks.cshtml) - CSharp - formatted + HtmlContent - (426:21,43 [24] Markup_InCodeBlocks.cshtml) + IntermediateToken - (426:21,43 [1] Markup_InCodeBlocks.cshtml) - Html - ! + IntermediateToken - (427:21,44 [5] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (432:21,49 [10] Markup_InCodeBlocks.cshtml) - Html - \n + IntermediateToken - (442:22,8 [6] Markup_InCodeBlocks.cshtml) - Html -
        + IntermediateToken - (448:22,14 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (450:23,0 [2] Markup_InCodeBlocks.cshtml) + IntermediateToken - (450:23,0 [2] Markup_InCodeBlocks.cshtml) - CSharp - \n + HtmlContent - (452:24,0 [14] Markup_InCodeBlocks.cshtml) + IntermediateToken - (452:24,0 [8] Markup_InCodeBlocks.cshtml) - Html - + IntermediateToken - (460:24,8 [3] Markup_InCodeBlocks.cshtml) - Html -
          + IntermediateToken - (464:24,12 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (466:25,0 [8] Markup_InCodeBlocks.cshtml) + IntermediateToken - (466:25,0 [8] Markup_InCodeBlocks.cshtml) - CSharp - + CSharpCode - (475:25,9 [54] Markup_InCodeBlocks.cshtml) + IntermediateToken - (475:25,9 [54] Markup_InCodeBlocks.cshtml) - CSharp - for (var i = 0; i < person.Age / 10; i++)\n {\n + HtmlContent - (529:27,0 [16] Markup_InCodeBlocks.cshtml) + IntermediateToken - (529:27,0 [12] Markup_InCodeBlocks.cshtml) - Html - + IntermediateToken - (541:27,12 [3] Markup_InCodeBlocks.cshtml) - Html -
        • + CSharpExpression - (547:27,18 [1] Markup_InCodeBlocks.cshtml) + IntermediateToken - (547:27,18 [1] Markup_InCodeBlocks.cshtml) - CSharp - i + HtmlContent - (549:27,20 [23] Markup_InCodeBlocks.cshtml) + IntermediateToken - (549:27,20 [16] Markup_InCodeBlocks.cshtml) - Html - Happy birthday! + IntermediateToken - (565:27,36 [5] Markup_InCodeBlocks.cshtml) - Html -
        • + IntermediateToken - (570:27,41 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (572:28,0 [11] Markup_InCodeBlocks.cshtml) + IntermediateToken - (572:28,0 [11] Markup_InCodeBlocks.cshtml) - CSharp - }\n + HtmlContent - (583:29,0 [15] Markup_InCodeBlocks.cshtml) + IntermediateToken - (583:29,0 [8] Markup_InCodeBlocks.cshtml) - Html - + IntermediateToken - (591:29,8 [5] Markup_InCodeBlocks.cshtml) - Html -
        + IntermediateToken - (596:29,13 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (598:30,0 [77] Markup_InCodeBlocks.cshtml) + IntermediateToken - (598:30,0 [77] Markup_InCodeBlocks.cshtml) - CSharp - \n if (person.Age < 20)\n {\n return;\n }\n\n + HtmlContent - (675:36,0 [33] Markup_InCodeBlocks.cshtml) + IntermediateToken - (675:36,0 [8] Markup_InCodeBlocks.cshtml) - Html - + IntermediateToken - (683:36,8 [3] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (687:36,12 [14] Markup_InCodeBlocks.cshtml) - Html - Secret message + IntermediateToken - (701:36,26 [5] Markup_InCodeBlocks.cshtml) - Html -

        + IntermediateToken - (706:36,31 [2] Markup_InCodeBlocks.cshtml) - Html - \n + CSharpCode - (708:37,0 [121] Markup_InCodeBlocks.cshtml) + IntermediateToken - (708:37,0 [121] Markup_InCodeBlocks.cshtml) - CSharp - }\n\n class Person\n {\n public string Name { get; set; }\n public int Age { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml new file mode 100644 index 0000000000..c001d4945d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml @@ -0,0 +1,20 @@ +@addTagHelper "*, TestAssembly" + +

        + + + + + +

        +
        Tag helper with unmatched bound boolean attributes.
        +

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..c2534fd226 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,63 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_DesignTime + { + #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::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper.BoundRequiredString = "hello"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper.BoundRequiredString = "world"; + __TestNamespace_InputTagHelper.BoundRequiredString = "hello2"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper.BoundRequiredString = "world"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + __DivTagHelper.BoundBoolProp = true; + __DivTagHelper.BoolDictProp["key"] = true; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..38941da8af --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt @@ -0,0 +1,109 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] MinimizedTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] MinimizedTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] MinimizedTagHelpers.cshtml) - Html - \n\n + TagHelper - (35:2,0 [762] MinimizedTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (64:2,29 [34] MinimizedTagHelpers.cshtml) + IntermediateToken - (64:2,29 [6] MinimizedTagHelpers.cshtml) - Html - \n + IntermediateToken - (70:3,4 [6] MinimizedTagHelpers.cshtml) - Html - + IntermediateToken - (92:3,26 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (98:4,4 [59] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (112:4,18 [3] MinimizedTagHelpers.cshtml) + IntermediateToken - (112:4,18 [3] MinimizedTagHelpers.cshtml) - Html - btn + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (157:5,39 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (157:5,39 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (163:6,4 [119] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (190:7,18 [3] MinimizedTagHelpers.cshtml) + IntermediateToken - (190:7,18 [3] MinimizedTagHelpers.cshtml) - Html - btn + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperHtmlAttribute - - input-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (273:7,101 [5] MinimizedTagHelpers.cshtml) - input-bound-required-string - string TestNamespace.InputTagHelper.BoundRequiredString - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (273:7,101 [5] MinimizedTagHelpers.cshtml) + IntermediateToken - (273:7,101 [5] MinimizedTagHelpers.cshtml) - Html - hello + DefaultTagHelperExecute - + HtmlContent - (282:7,110 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (282:7,110 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (288:8,4 [176] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (315:9,18 [3] MinimizedTagHelpers.cshtml) + IntermediateToken - (315:9,18 [3] MinimizedTagHelpers.cshtml) - Html - btn + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperHtmlAttribute - - input-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (418:11,57 [5] MinimizedTagHelpers.cshtml) - catchall-bound-string - string TestNamespace.CatchAllTagHelper.BoundRequiredString - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (418:11,57 [5] MinimizedTagHelpers.cshtml) + IntermediateToken - (418:11,57 [5] MinimizedTagHelpers.cshtml) - Html - world + DefaultTagHelperProperty - (454:11,93 [6] MinimizedTagHelpers.cshtml) - input-bound-required-string - string TestNamespace.InputTagHelper.BoundRequiredString - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (454:11,93 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (454:11,93 [6] MinimizedTagHelpers.cshtml) - Html - hello2 + DefaultTagHelperExecute - + HtmlContent - (464:11,103 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (464:11,103 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (470:12,4 [206] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (484:12,18 [3] MinimizedTagHelpers.cshtml) + IntermediateToken - (484:12,18 [3] MinimizedTagHelpers.cshtml) - Html - btn + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (529:13,38 [5] MinimizedTagHelpers.cshtml) + IntermediateToken - (529:13,38 [5] MinimizedTagHelpers.cshtml) - Html - hello + DefaultTagHelperHtmlAttribute - - input-unbound-required - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (578:14,40 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (578:14,40 [6] MinimizedTagHelpers.cshtml) - Html - hello2 + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (667:16,40 [5] MinimizedTagHelpers.cshtml) - input-bound-required-string - string TestNamespace.InputTagHelper.BoundRequiredString - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (667:16,40 [5] MinimizedTagHelpers.cshtml) + IntermediateToken - (667:16,40 [5] MinimizedTagHelpers.cshtml) - Html - world + DefaultTagHelperExecute - + HtmlContent - (676:16,49 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (676:16,49 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (682:17,4 [41] MinimizedTagHelpers.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperProperty - - boundbool - bool DivTagHelper.BoundBoolProp - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - - booldict-prefix-key - System.Collections.Generic.IDictionary DivTagHelper.BoolDictProp - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (723:17,45 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (723:17,45 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (729:18,4 [62] MinimizedTagHelpers.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (734:18,9 [51] MinimizedTagHelpers.cshtml) + IntermediateToken - (734:18,9 [51] MinimizedTagHelpers.cshtml) - Html - Tag helper with unmatched bound boolean attributes. + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + HtmlContent - (791:18,66 [2] MinimizedTagHelpers.cshtml) + IntermediateToken - (791:18,66 [2] MinimizedTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..42530b4c60 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1179:20,37 [17] ) +|"*, TestAssembly"| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..22d33b83e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.codegen.cs @@ -0,0 +1,190 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "29c9ea0bc587afb2f919c7ed7192d6687b534753" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"29c9ea0bc587afb2f919c7ed7192d6687b534753", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("btn"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("input-bound-required-string", "hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("catchall-bound-string", "world", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("input-bound-required-string", "hello2", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("catchall-unbound-required", new global::Microsoft.AspNetCore.Html.HtmlString("hello"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("input-unbound-required", new global::Microsoft.AspNetCore.Html.HtmlString("hello2"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_6 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("input-bound-required-string", "world", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("catchall-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("catchall-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("input-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + __TestNamespace_InputTagHelper.BoundRequiredString = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("catchall-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("input-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + __TestNamespace_CatchAllTagHelper.BoundRequiredString = (string)__tagHelperAttribute_2.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2); + __TestNamespace_InputTagHelper.BoundRequiredString = (string)__tagHelperAttribute_3.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("catchall-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + __TestNamespace_InputTagHelper.BoundRequiredString = (string)__tagHelperAttribute_6.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __DivTagHelper.BoundBoolProp = true; + __tagHelperExecutionContext.AddTagHelperAttribute("boundbool", __DivTagHelper.BoundBoolProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + if (__DivTagHelper.BoolDictProp == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("booldict-prefix-key", "DivTagHelper", "BoolDictProp")); + } + __DivTagHelper.BoolDictProp["key"] = true; + __tagHelperExecutionContext.AddTagHelperAttribute("booldict-prefix-key", __DivTagHelper.BoolDictProp["key"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Tag helper with unmatched bound boolean attributes."); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("catchall-unbound-required", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..0f51578f51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_Runtime.ir.txt @@ -0,0 +1,90 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - btn - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - input-bound-required-string - hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_2 - catchall-bound-string - world - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_3 - input-bound-required-string - hello2 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_4 - catchall-unbound-required - hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_5 - input-unbound-required - hello2 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_6 - input-bound-required-string - world - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] MinimizedTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (35:2,0 [762] MinimizedTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (64:2,29 [34] MinimizedTagHelpers.cshtml) + IntermediateToken - (64:2,29 [6] MinimizedTagHelpers.cshtml) - Html - \n + IntermediateToken - (70:3,4 [6] MinimizedTagHelpers.cshtml) - Html - + IntermediateToken - (92:3,26 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (98:4,4 [59] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (157:5,39 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (157:5,39 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (163:6,4 [119] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperHtmlAttribute - - input-unbound-required - HtmlAttributeValueStyle.Minimized + PreallocatedTagHelperProperty - (273:7,101 [5] MinimizedTagHelpers.cshtml) - __tagHelperAttribute_1 - input-bound-required-string - BoundRequiredString + DefaultTagHelperExecute - + HtmlContent - (282:7,110 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (282:7,110 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (288:8,4 [176] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperHtmlAttribute - - input-unbound-required - HtmlAttributeValueStyle.Minimized + PreallocatedTagHelperProperty - (418:11,57 [5] MinimizedTagHelpers.cshtml) - __tagHelperAttribute_2 - catchall-bound-string - BoundRequiredString + PreallocatedTagHelperProperty - (454:11,93 [6] MinimizedTagHelpers.cshtml) - __tagHelperAttribute_3 - input-bound-required-string - BoundRequiredString + DefaultTagHelperExecute - + HtmlContent - (464:11,103 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (464:11,103 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (470:12,4 [206] MinimizedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_4 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + PreallocatedTagHelperProperty - (667:16,40 [5] MinimizedTagHelpers.cshtml) - __tagHelperAttribute_6 - input-bound-required-string - BoundRequiredString + DefaultTagHelperExecute - + HtmlContent - (676:16,49 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (676:16,49 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (682:17,4 [41] MinimizedTagHelpers.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperProperty - - boundbool - bool DivTagHelper.BoundBoolProp - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - - booldict-prefix-key - System.Collections.Generic.IDictionary DivTagHelper.BoolDictProp - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (723:17,45 [6] MinimizedTagHelpers.cshtml) + IntermediateToken - (723:17,45 [6] MinimizedTagHelpers.cshtml) - Html - \n + TagHelper - (729:18,4 [62] MinimizedTagHelpers.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (734:18,9 [51] MinimizedTagHelpers.cshtml) + IntermediateToken - (734:18,9 [51] MinimizedTagHelpers.cshtml) - Html - Tag helper with unmatched bound boolean attributes. + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + HtmlContent - (791:18,66 [2] MinimizedTagHelpers.cshtml) + IntermediateToken - (791:18,66 [2] MinimizedTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - catchall-unbound-required - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml new file mode 100644 index 0000000000..8387e8a28a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml @@ -0,0 +1,8 @@ +@{ + @foreach (var result in (dynamic)Url) + { +
        + @result.SomeValue. +
        + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs new file mode 100644 index 0000000000..1b08e1e505 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.cs @@ -0,0 +1,61 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + foreach (var result in (dynamic)Url) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + __o = result.SomeValue; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.html new file mode 100644 index 0000000000..c1b9240ee0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.codegen.html @@ -0,0 +1,8 @@ + + + +
        + . +
        + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt new file mode 100644 index 0000000000..4644024352 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] NestedCSharp.cshtml) + IntermediateToken - (2:0,2 [6] NestedCSharp.cshtml) - CSharp - \n + CSharpCode - (9:1,5 [53] NestedCSharp.cshtml) + IntermediateToken - (9:1,5 [53] NestedCSharp.cshtml) - CSharp - foreach (var result in (dynamic)Url)\n {\n + HtmlContent - (62:3,8 [19] NestedCSharp.cshtml) + IntermediateToken - (62:3,8 [4] NestedCSharp.cshtml) - Html -
        + IntermediateToken - (67:3,13 [14] NestedCSharp.cshtml) - Html - \n + CSharpExpression - (82:4,13 [16] NestedCSharp.cshtml) + IntermediateToken - (82:4,13 [16] NestedCSharp.cshtml) - CSharp - result.SomeValue + HtmlContent - (98:4,29 [17] NestedCSharp.cshtml) + IntermediateToken - (98:4,29 [11] NestedCSharp.cshtml) - Html - .\n + IntermediateToken - (109:5,8 [6] NestedCSharp.cshtml) - Html -
        + CSharpCode - (115:5,14 [7] NestedCSharp.cshtml) + IntermediateToken - (115:5,14 [7] NestedCSharp.cshtml) - CSharp - \n } + CSharpCode - (122:6,5 [2] NestedCSharp.cshtml) + IntermediateToken - (122:6,5 [2] NestedCSharp.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt new file mode 100644 index 0000000000..b58d527b04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.mappings.txt @@ -0,0 +1,35 @@ +Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) +| + | +Generated Location: (744:19,2 [6] ) +| + | + +Source Location: (9:1,5 [53] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) +|foreach (var result in (dynamic)Url) + { + | +Generated Location: (914:27,5 [53] ) +|foreach (var result in (dynamic)Url) + { + | + +Source Location: (82:4,13 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) +|result.SomeValue| +Generated Location: (1139:36,13 [16] ) +|result.SomeValue| + +Source Location: (115:5,14 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) +| + }| +Generated Location: (1329:43,14 [7] ) +| + }| + +Source Location: (122:6,5 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml) +| +| +Generated Location: (1500:51,5 [2] ) +| +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs new file mode 100644 index 0000000000..26ba12432c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.codegen.cs @@ -0,0 +1,42 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "6be69a1b80bfb35325fef427f0709232182e96a8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"6be69a1b80bfb35325fef427f0709232182e96a8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + foreach (var result in (dynamic)Url) + { + +#line default +#line hidden +#nullable disable + WriteLiteral("
        \r\n "); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + Write(result.SomeValue); + +#line default +#line hidden +#nullable disable + WriteLiteral(".\r\n
        \r\n"); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp.cshtml" + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt new file mode 100644 index 0000000000..79a60d3403 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_Runtime.ir.txt @@ -0,0 +1,26 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] NestedCSharp.cshtml) + IntermediateToken - (2:0,2 [6] NestedCSharp.cshtml) - CSharp - \n + CSharpCode - (9:1,5 [45] NestedCSharp.cshtml) + IntermediateToken - (9:1,5 [45] NestedCSharp.cshtml) - CSharp - foreach (var result in (dynamic)Url)\n {\n + HtmlContent - (54:3,0 [27] NestedCSharp.cshtml) + IntermediateToken - (54:3,0 [8] NestedCSharp.cshtml) - Html - + IntermediateToken - (62:3,8 [4] NestedCSharp.cshtml) - Html -
        + IntermediateToken - (67:3,13 [2] NestedCSharp.cshtml) - Html - \n + IntermediateToken - (69:4,0 [12] NestedCSharp.cshtml) - Html - + CSharpExpression - (82:4,13 [16] NestedCSharp.cshtml) + IntermediateToken - (82:4,13 [16] NestedCSharp.cshtml) - CSharp - result.SomeValue + HtmlContent - (98:4,29 [19] NestedCSharp.cshtml) + IntermediateToken - (98:4,29 [11] NestedCSharp.cshtml) - Html - .\n + IntermediateToken - (109:5,8 [6] NestedCSharp.cshtml) - Html -
        + IntermediateToken - (115:5,14 [2] NestedCSharp.cshtml) - Html - \n + CSharpCode - (117:6,0 [5] NestedCSharp.cshtml) + IntermediateToken - (117:6,0 [5] NestedCSharp.cshtml) - CSharp - } + CSharpCode - (122:6,5 [2] NestedCSharp.cshtml) + IntermediateToken - (122:6,5 [2] NestedCSharp.cshtml) - CSharp - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml new file mode 100644 index 0000000000..070875f5fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml @@ -0,0 +1,4 @@ +@if(foo) { + @if(bar) { + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.codegen.cs new file mode 100644 index 0000000000..59b64e3682 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.codegen.cs @@ -0,0 +1,46 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" + if(foo) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" + if(bar) { + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.codegen.html new file mode 100644 index 0000000000..c56380dfcb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.codegen.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt new file mode 100644 index 0000000000..7522731b78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (1:0,1 [15] NestedCodeBlocks.cshtml) + IntermediateToken - (1:0,1 [15] NestedCodeBlocks.cshtml) - CSharp - if(foo) {\n + CSharpCode - (17:1,5 [16] NestedCodeBlocks.cshtml) + IntermediateToken - (17:1,5 [16] NestedCodeBlocks.cshtml) - CSharp - if(bar) {\n } + CSharpCode - (33:2,5 [3] NestedCodeBlocks.cshtml) + IntermediateToken - (33:2,5 [3] NestedCodeBlocks.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.mappings.txt new file mode 100644 index 0000000000..55d683f4e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (1:0,1 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml) +|if(foo) { + | +Generated Location: (751:19,1 [15] ) +|if(foo) { + | + +Source Location: (17:1,5 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml) +|if(bar) { + }| +Generated Location: (934:27,5 [16] ) +|if(bar) { + }| + +Source Location: (33:2,5 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml) +| +}| +Generated Location: (1118:35,5 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs new file mode 100644 index 0000000000..af6d6d502b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.codegen.cs @@ -0,0 +1,42 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d83923f86f1c84f081916ef7308513ab80a65675" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d83923f86f1c84f081916ef7308513ab80a65675", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" + if(foo) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" + if(bar) { + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt new file mode 100644 index 0000000000..2c0030ec65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_Runtime.ir.txt @@ -0,0 +1,12 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (1:0,1 [15] NestedCodeBlocks.cshtml) + IntermediateToken - (1:0,1 [15] NestedCodeBlocks.cshtml) - CSharp - if(foo) {\n + CSharpCode - (17:1,5 [16] NestedCodeBlocks.cshtml) + IntermediateToken - (17:1,5 [16] NestedCodeBlocks.cshtml) - CSharp - if(bar) {\n } + CSharpCode - (33:2,5 [3] NestedCodeBlocks.cshtml) + IntermediateToken - (33:2,5 [3] NestedCodeBlocks.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml new file mode 100644 index 0000000000..b5fac5a502 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml @@ -0,0 +1,16 @@ +@addTagHelper "*, TestAssembly" + + + } + +

        +
        + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..b59604d45f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" + for(var i = 0; i < 5; i++) { + + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" + __o = ViewBag.DefaultInterval; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper.Type = "text"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" + __TestNamespace_InputTagHelper2.Checked = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" + + } + +#line default +#line hidden +#nullable disable + __TestNamespace_PTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..cf49fba267 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt @@ -0,0 +1,87 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] NestedScriptTagTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [108] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] NestedScriptTagTagHelpers.cshtml) - Html - \n\n + IntermediateToken - (35:2,0 [7] NestedScriptTagTagHelpers.cshtml) - Html - + CSharpCode - (422:8,25 [15] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (422:8,25 [15] NestedScriptTagTagHelpers.cshtml) - CSharp - \n } + HtmlContent - (437:9,13 [131] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (437:9,13 [14] NestedScriptTagTagHelpers.cshtml) - Html - \n + IntermediateToken - (451:10,12 [7] NestedScriptTagTagHelpers.cshtml) - Html - + IntermediateToken - (558:12,21 [10] NestedScriptTagTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (149:4,18 [11] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (149:4,18 [11] NestedScriptTagTagHelpers.cshtml) - Html - Hello World + DefaultTagHelperHtmlAttribute - - data-delay - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (174:4,43 [4] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (174:4,43 [4] NestedScriptTagTagHelpers.cshtml) - Html - 1000 + DefaultTagHelperExecute - + HtmlContent - (572:13,12 [23] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (572:13,12 [6] NestedScriptTagTagHelpers.cshtml) - Html - \n + IntermediateToken - (578:14,4 [6] NestedScriptTagTagHelpers.cshtml) - Html -
        + IntermediateToken - (584:14,10 [2] NestedScriptTagTagHelpers.cshtml) - Html - \n + IntermediateToken - (586:15,0 [9] NestedScriptTagTagHelpers.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..aa83001579 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1211:20,37 [17] ) +|"*, TestAssembly"| + +Source Location: (195:5,13 [46] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml) +|for(var i = 0; i < 5; i++) { + | +Generated Location: (1728:37,13 [46] ) +|for(var i = 0; i < 5; i++) { + | + +Source Location: (339:7,50 [23] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml) +|ViewBag.DefaultInterval| +Generated Location: (2204:47,50 [23] ) +|ViewBag.DefaultInterval| + +Source Location: (389:7,100 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml) +|true| +Generated Location: (2648:56,100 [4] ) +|true| + +Source Location: (422:8,25 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml) +| + }| +Generated Location: (2926:64,25 [15] ) +| + }| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..6080615b18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.codegen.cs @@ -0,0 +1,116 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "958c6fc042a8f49499906b46c11bf4b15446c89d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"958c6fc042a8f49499906b46c11bf4b15446c89d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-delay", new global::Microsoft.AspNetCore.Html.HtmlString("1000"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n\r\n"); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers.cshtml" + } + +#line default +#line hidden +#nullable disable + WriteLiteral(" \r\n "); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        \r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..7041d3c6fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_Runtime.ir.txt @@ -0,0 +1,80 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - data-delay - 1000 - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [106] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] NestedScriptTagTagHelpers.cshtml) - Html - \n + IntermediateToken - (35:2,0 [7] NestedScriptTagTagHelpers.cshtml) - Html - + IntermediateToken - (422:8,25 [2] NestedScriptTagTagHelpers.cshtml) - Html - \n + CSharpCode - (424:9,0 [15] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (424:9,0 [15] NestedScriptTagTagHelpers.cshtml) - CSharp - }\n + HtmlContent - (439:10,0 [129] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (439:10,0 [12] NestedScriptTagTagHelpers.cshtml) - Html - + IntermediateToken - (451:10,12 [7] NestedScriptTagTagHelpers.cshtml) - Html - + IntermediateToken - (558:12,21 [10] NestedScriptTagTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (572:13,12 [23] NestedScriptTagTagHelpers.cshtml) + IntermediateToken - (572:13,12 [6] NestedScriptTagTagHelpers.cshtml) - Html - \n + IntermediateToken - (578:14,4 [6] NestedScriptTagTagHelpers.cshtml) - Html -
        + IntermediateToken - (584:14,10 [2] NestedScriptTagTagHelpers.cshtml) - Html - \n + IntermediateToken - (586:15,0 [9] NestedScriptTagTagHelpers.cshtml) - Html - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml new file mode 100644 index 0000000000..e6637b03fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, TestAssembly +Hola +
        + +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..bb5e833228 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_DesignTime + { + #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::SpanTagHelper __SpanTagHelper; + private global::DivTagHelper __DivTagHelper; + private global::InputTagHelper __InputTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __SpanTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __InputTagHelper = CreateTagHelper(); + __InputTagHelper.FooProp = "Hello"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..4a4b5e257d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt @@ -0,0 +1,48 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::SpanTagHelper - __SpanTagHelper + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] NestedTagHelpers.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [2] NestedTagHelpers.cshtml) + IntermediateToken - (29:0,29 [2] NestedTagHelpers.cshtml) - Html - \n + TagHelper - (31:1,0 [26] NestedTagHelpers.cshtml) - span - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (46:1,15 [4] NestedTagHelpers.cshtml) + IntermediateToken - (46:1,15 [4] NestedTagHelpers.cshtml) - Html - Hola + DefaultTagHelperCreate - - SpanTagHelper + DefaultTagHelperHtmlAttribute - - someattr - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (57:1,26 [2] NestedTagHelpers.cshtml) + IntermediateToken - (57:1,26 [2] NestedTagHelpers.cshtml) - Html - \n + TagHelper - (59:2,0 [66] NestedTagHelpers.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (78:2,19 [6] NestedTagHelpers.cshtml) + IntermediateToken - (78:2,19 [6] NestedTagHelpers.cshtml) - Html - \n + TagHelper - (84:3,4 [33] NestedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (97:3,17 [5] NestedTagHelpers.cshtml) - value - string InputTagHelper.FooProp - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (97:3,17 [5] NestedTagHelpers.cshtml) + IntermediateToken - (97:3,17 [5] NestedTagHelpers.cshtml) - Html - Hello + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (109:3,29 [4] NestedTagHelpers.cshtml) + IntermediateToken - (109:3,29 [4] NestedTagHelpers.cshtml) - Html - text + DefaultTagHelperExecute - + HtmlContent - (117:3,37 [2] NestedTagHelpers.cshtml) + IntermediateToken - (117:3,37 [2] NestedTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - unbound - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (73:2,14 [3] NestedTagHelpers.cshtml) + IntermediateToken - (73:2,14 [3] NestedTagHelpers.cshtml) - Html - foo + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..2d0933aae5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml) +|*, TestAssembly| +Generated Location: (1110:20,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..5022ab7a5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.codegen.cs @@ -0,0 +1,91 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5e63d5fe37100e65dfcf39dd1c542eb697b624db" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5e63d5fe37100e65dfcf39dd1c542eb697b624db", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("unbound", new global::Microsoft.AspNetCore.Html.HtmlString("foo"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::SpanTagHelper __SpanTagHelper; + private global::DivTagHelper __DivTagHelper; + private global::InputTagHelper __InputTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("span", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Hola"); + } + ); + __SpanTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__SpanTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("someattr", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.FooProp = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..f4c6001b80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_Runtime.ir.txt @@ -0,0 +1,37 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - unbound - foo - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::SpanTagHelper - __SpanTagHelper + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + TagHelper - (31:1,0 [26] NestedTagHelpers.cshtml) - span - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (46:1,15 [4] NestedTagHelpers.cshtml) + IntermediateToken - (46:1,15 [4] NestedTagHelpers.cshtml) - Html - Hola + DefaultTagHelperCreate - - SpanTagHelper + DefaultTagHelperHtmlAttribute - - someattr - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (57:1,26 [2] NestedTagHelpers.cshtml) + IntermediateToken - (57:1,26 [2] NestedTagHelpers.cshtml) - Html - \n + TagHelper - (59:2,0 [66] NestedTagHelpers.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (78:2,19 [6] NestedTagHelpers.cshtml) + IntermediateToken - (78:2,19 [6] NestedTagHelpers.cshtml) - Html - \n + TagHelper - (84:3,4 [33] NestedTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + PreallocatedTagHelperProperty - (97:3,17 [5] NestedTagHelpers.cshtml) - __tagHelperAttribute_0 - value - FooProp + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (117:3,37 [2] NestedTagHelpers.cshtml) + IntermediateToken - (117:3,37 [2] NestedTagHelpers.cshtml) - Html - \n + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml new file mode 100644 index 0000000000..36e96c46b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml @@ -0,0 +1,38 @@ +@{ + int i = 1; +} + +@while(i <= 10) { +

        Hello from C#, #@(i)

        + i += 1; +} + +@if(i == 11) { +

        We wrote 10 lines!

        +} + +@switch(i) { + case 11: +

        No really, we wrote 10 lines!

        + break; + default: +

        Actually, we didn't...

        + break; +} + +@for(int j = 1; j <= 10; j += 2) { +

        Hello again from C#, #@(j)

        +} + +@try { +

        That time, we wrote 5 lines!

        +} catch(Exception ex) { +

        Oh no! An error occurred: @(ex.Message)

        +} + +@* With has no equivalent in C# *@ +

        i is now @i

        + +@lock(new object()) { +

        This block is locked, for your security!

        +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs new file mode 100644 index 0000000000..b1d0ce4074 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.cs @@ -0,0 +1,184 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + int i = 1; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + while(i <= 10) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + i += 1; +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + if(i == 11) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + switch(i) { + case 11: + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + break; + default: + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + break; +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + for(int j = 1; j <= 10; j += 2) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + __o = j; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + +} + +#line default +#line hidden +#nullable disable +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + try { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + +} catch(Exception ex) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + __o = ex.Message; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + +} + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + __o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + lock(new object()) { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.html new file mode 100644 index 0000000000..b7c02278c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.codegen.html @@ -0,0 +1,38 @@ + + + + + +

        Hello from C#, #

        + + + + +

        We wrote 10 lines!

        + + + + +

        No really, we wrote 10 lines!

        + + +

        Actually, we didn't...

        + + + + +

        Hello again from C#, #

        + + + +

        That time, we wrote 5 lines!

        + +

        Oh no! An error occurred:

        + + + +

        i is now

        + + +

        This block is locked, for your security!

        + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt new file mode 100644 index 0000000000..c5215cb143 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt @@ -0,0 +1,112 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [18] NoLinePragmas.cshtml) + IntermediateToken - (2:0,2 [18] NoLinePragmas.cshtml) - CSharp - \n int i = 1;\n + HtmlContent - (23:3,0 [2] NoLinePragmas.cshtml) + IntermediateToken - (23:3,0 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (26:4,1 [22] NoLinePragmas.cshtml) + IntermediateToken - (26:4,1 [22] NoLinePragmas.cshtml) - CSharp - while(i <= 10) {\n + HtmlContent - (48:5,4 [19] NoLinePragmas.cshtml) + IntermediateToken - (48:5,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (51:5,7 [16] NoLinePragmas.cshtml) - Html - Hello from C#, # + CSharpExpression - (69:5,25 [1] NoLinePragmas.cshtml) + IntermediateToken - (69:5,25 [1] NoLinePragmas.cshtml) - CSharp - i + HtmlContent - (71:5,27 [4] NoLinePragmas.cshtml) + IntermediateToken - (71:5,27 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (75:5,31 [16] NoLinePragmas.cshtml) + IntermediateToken - (75:5,31 [16] NoLinePragmas.cshtml) - CSharp - \n i += 1;\n} + HtmlContent - (91:7,1 [4] NoLinePragmas.cshtml) + IntermediateToken - (91:7,1 [4] NoLinePragmas.cshtml) - Html - \n\n + CSharpCode - (96:9,1 [19] NoLinePragmas.cshtml) + IntermediateToken - (96:9,1 [19] NoLinePragmas.cshtml) - CSharp - if(i == 11) {\n + HtmlContent - (115:10,4 [25] NoLinePragmas.cshtml) + IntermediateToken - (115:10,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (118:10,7 [18] NoLinePragmas.cshtml) - Html - We wrote 10 lines! + IntermediateToken - (136:10,25 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (140:10,29 [3] NoLinePragmas.cshtml) + IntermediateToken - (140:10,29 [3] NoLinePragmas.cshtml) - CSharp - \n} + HtmlContent - (143:11,1 [4] NoLinePragmas.cshtml) + IntermediateToken - (143:11,1 [4] NoLinePragmas.cshtml) - Html - \n\n + CSharpCode - (148:13,1 [35] NoLinePragmas.cshtml) + IntermediateToken - (148:13,1 [35] NoLinePragmas.cshtml) - CSharp - switch(i) {\n case 11:\n + HtmlContent - (183:15,8 [36] NoLinePragmas.cshtml) + IntermediateToken - (183:15,8 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (186:15,11 [29] NoLinePragmas.cshtml) - Html - No really, we wrote 10 lines! + IntermediateToken - (215:15,40 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (219:15,44 [40] NoLinePragmas.cshtml) + IntermediateToken - (219:15,44 [40] NoLinePragmas.cshtml) - CSharp - \n break;\n default:\n + HtmlContent - (259:18,8 [29] NoLinePragmas.cshtml) + IntermediateToken - (259:18,8 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (262:18,11 [22] NoLinePragmas.cshtml) - Html - Actually, we didn't... + IntermediateToken - (284:18,33 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (288:18,37 [19] NoLinePragmas.cshtml) + IntermediateToken - (288:18,37 [19] NoLinePragmas.cshtml) - CSharp - \n break;\n} + HtmlContent - (307:20,1 [4] NoLinePragmas.cshtml) + IntermediateToken - (307:20,1 [4] NoLinePragmas.cshtml) - Html - \n\n + CSharpCode - (312:22,1 [39] NoLinePragmas.cshtml) + IntermediateToken - (312:22,1 [39] NoLinePragmas.cshtml) - CSharp - for(int j = 1; j <= 10; j += 2) {\n + HtmlContent - (351:23,4 [25] NoLinePragmas.cshtml) + IntermediateToken - (351:23,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (354:23,7 [22] NoLinePragmas.cshtml) - Html - Hello again from C#, # + CSharpExpression - (378:23,31 [1] NoLinePragmas.cshtml) + IntermediateToken - (378:23,31 [1] NoLinePragmas.cshtml) - CSharp - j + HtmlContent - (380:23,33 [4] NoLinePragmas.cshtml) + IntermediateToken - (380:23,33 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (384:23,37 [3] NoLinePragmas.cshtml) + IntermediateToken - (384:23,37 [3] NoLinePragmas.cshtml) - CSharp - \n} + HtmlContent - (387:24,1 [4] NoLinePragmas.cshtml) + IntermediateToken - (387:24,1 [4] NoLinePragmas.cshtml) - Html - \n\n + CSharpCode - (392:26,1 [11] NoLinePragmas.cshtml) + IntermediateToken - (392:26,1 [11] NoLinePragmas.cshtml) - CSharp - try {\n + HtmlContent - (403:27,4 [35] NoLinePragmas.cshtml) + IntermediateToken - (403:27,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (406:27,7 [28] NoLinePragmas.cshtml) - Html - That time, we wrote 5 lines! + IntermediateToken - (434:27,35 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (438:27,39 [31] NoLinePragmas.cshtml) + IntermediateToken - (438:27,39 [31] NoLinePragmas.cshtml) - CSharp - \n} catch(Exception ex) {\n + HtmlContent - (469:29,4 [29] NoLinePragmas.cshtml) + IntermediateToken - (469:29,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (472:29,7 [26] NoLinePragmas.cshtml) - Html - Oh no! An error occurred: + CSharpExpression - (500:29,35 [10] NoLinePragmas.cshtml) + IntermediateToken - (500:29,35 [10] NoLinePragmas.cshtml) - CSharp - ex.Message + HtmlContent - (511:29,46 [4] NoLinePragmas.cshtml) + IntermediateToken - (511:29,46 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (515:29,50 [7] NoLinePragmas.cshtml) + IntermediateToken - (515:29,50 [7] NoLinePragmas.cshtml) - CSharp - \n}\n\n + CSharpCode - (556:32,34 [0] NoLinePragmas.cshtml) + IntermediateToken - (556:32,34 [0] NoLinePragmas.cshtml) - CSharp - + HtmlContent - (556:32,34 [14] NoLinePragmas.cshtml) + IntermediateToken - (556:32,34 [2] NoLinePragmas.cshtml) - Html - \n + IntermediateToken - (558:33,0 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (561:33,3 [9] NoLinePragmas.cshtml) - Html - i is now + CSharpExpression - (571:33,13 [1] NoLinePragmas.cshtml) + IntermediateToken - (571:33,13 [1] NoLinePragmas.cshtml) - CSharp - i + HtmlContent - (572:33,14 [8] NoLinePragmas.cshtml) + IntermediateToken - (572:33,14 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (576:33,18 [4] NoLinePragmas.cshtml) - Html - \n\n + CSharpCode - (581:35,1 [26] NoLinePragmas.cshtml) + IntermediateToken - (581:35,1 [26] NoLinePragmas.cshtml) - CSharp - lock(new object()) {\n + HtmlContent - (607:36,4 [47] NoLinePragmas.cshtml) + IntermediateToken - (607:36,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (610:36,7 [40] NoLinePragmas.cshtml) - Html - This block is locked, for your security! + IntermediateToken - (650:36,47 [4] NoLinePragmas.cshtml) - Html -

        + CSharpCode - (654:36,51 [3] NoLinePragmas.cshtml) + IntermediateToken - (654:36,51 [3] NoLinePragmas.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt new file mode 100644 index 0000000000..1ba876db62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.mappings.txt @@ -0,0 +1,148 @@ +Source Location: (2:0,2 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| + int i = 1; +| +Generated Location: (746:19,2 [18] ) +| + int i = 1; +| + +Source Location: (26:4,1 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|while(i <= 10) { + | +Generated Location: (923:27,1 [22] ) +|while(i <= 10) { + | + +Source Location: (69:5,25 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|i| +Generated Location: (1130:35,25 [1] ) +|i| + +Source Location: (75:5,31 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| + i += 1; +}| +Generated Location: (1323:42,31 [16] ) +| + i += 1; +}| + +Source Location: (96:9,1 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|if(i == 11) { + | +Generated Location: (1501:51,1 [19] ) +|if(i == 11) { + | + +Source Location: (140:10,29 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| +}| +Generated Location: (1710:59,29 [3] ) +| +}| + +Source Location: (148:13,1 [35] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|switch(i) { + case 11: + | +Generated Location: (1875:67,1 [35] ) +|switch(i) { + case 11: + | + +Source Location: (219:15,44 [40] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| + break; + default: + | +Generated Location: (2115:76,44 [40] ) +| + break; + default: + | + +Source Location: (288:18,37 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| + break; +}| +Generated Location: (2353:86,37 [19] ) +| + break; +}| + +Source Location: (312:22,1 [39] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|for(int j = 1; j <= 10; j += 2) { + | +Generated Location: (2534:95,1 [39] ) +|for(int j = 1; j <= 10; j += 2) { + | + +Source Location: (378:23,31 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|j| +Generated Location: (2765:103,31 [1] ) +|j| + +Source Location: (384:23,37 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| +}| +Generated Location: (2965:110,37 [3] ) +| +}| + +Source Location: (392:26,1 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|try { + | +Generated Location: (3130:118,1 [11] ) +|try { + | + +Source Location: (438:27,39 [31] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| +} catch(Exception ex) { + | +Generated Location: (3341:126,39 [31] ) +| +} catch(Exception ex) { + | + +Source Location: (500:29,35 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|ex.Message| +Generated Location: (3568:135,35 [10] ) +|ex.Message| + +Source Location: (515:29,50 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| +} + +| +Generated Location: (3790:142,50 [7] ) +| +} + +| + +Source Location: (556:32,34 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|| +Generated Location: (3990:151,34 [0] ) +|| + +Source Location: (571:33,13 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|i| +Generated Location: (4164:158,13 [1] ) +|i| + +Source Location: (581:35,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +|lock(new object()) { + | +Generated Location: (4328:165,1 [26] ) +|lock(new object()) { + | + +Source Location: (654:36,51 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml) +| +}| +Generated Location: (4566:173,51 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs new file mode 100644 index 0000000000..c923c0ece8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.codegen.cs @@ -0,0 +1,175 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c6fa3992fa56644768995c97941d682d90f6d8ec" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c6fa3992fa56644768995c97941d682d90f6d8ec", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + + int i = 1; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + while(i <= 10) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello from C#, #"); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + i += 1; +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + if(i == 11) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        We wrote 10 lines!

        \r\n"); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + switch(i) { + case 11: + +#line default +#line hidden +#nullable disable + WriteLiteral("

        No really, we wrote 10 lines!

        \r\n"); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + break; + default: + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Actually, we didn\'t...

        \r\n"); +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + break; +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 23 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + for(int j = 1; j <= 10; j += 2) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello again from C#, #"); +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + Write(j); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 25 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" +} + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + try { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        That time, we wrote 5 lines!

        \r\n"); +#nullable restore +#line 29 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" +} catch(Exception ex) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Oh no! An error occurred: "); +#nullable restore +#line 30 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + Write(ex.Message); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" +} + + +#line default +#line hidden +#nullable disable + WriteLiteral("

        i is now "); +#nullable restore +#line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n\r\n"); +#nullable restore +#line 36 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" + lock(new object()) { + +#line default +#line hidden +#nullable disable + WriteLiteral("

        This block is locked, for your security!

        \r\n"); +#nullable restore +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt new file mode 100644 index 0000000000..1b8d2a8073 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_Runtime.ir.txt @@ -0,0 +1,122 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [18] NoLinePragmas.cshtml) + IntermediateToken - (2:0,2 [18] NoLinePragmas.cshtml) - CSharp - \n int i = 1;\n + HtmlContent - (23:3,0 [2] NoLinePragmas.cshtml) + IntermediateToken - (23:3,0 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (26:4,1 [18] NoLinePragmas.cshtml) + IntermediateToken - (26:4,1 [18] NoLinePragmas.cshtml) - CSharp - while(i <= 10) {\n + HtmlContent - (44:5,0 [23] NoLinePragmas.cshtml) + IntermediateToken - (44:5,0 [4] NoLinePragmas.cshtml) - Html - + IntermediateToken - (48:5,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (51:5,7 [16] NoLinePragmas.cshtml) - Html - Hello from C#, # + CSharpExpression - (69:5,25 [1] NoLinePragmas.cshtml) + IntermediateToken - (69:5,25 [1] NoLinePragmas.cshtml) - CSharp - i + HtmlContent - (71:5,27 [6] NoLinePragmas.cshtml) + IntermediateToken - (71:5,27 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (75:5,31 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (77:6,0 [16] NoLinePragmas.cshtml) + IntermediateToken - (77:6,0 [16] NoLinePragmas.cshtml) - CSharp - i += 1;\n}\n + HtmlContent - (93:8,0 [2] NoLinePragmas.cshtml) + IntermediateToken - (93:8,0 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (96:9,1 [15] NoLinePragmas.cshtml) + IntermediateToken - (96:9,1 [15] NoLinePragmas.cshtml) - CSharp - if(i == 11) {\n + HtmlContent - (111:10,0 [31] NoLinePragmas.cshtml) + IntermediateToken - (111:10,0 [4] NoLinePragmas.cshtml) - Html - + IntermediateToken - (115:10,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (118:10,7 [18] NoLinePragmas.cshtml) - Html - We wrote 10 lines! + IntermediateToken - (136:10,25 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (140:10,29 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (142:11,0 [3] NoLinePragmas.cshtml) + IntermediateToken - (142:11,0 [3] NoLinePragmas.cshtml) - CSharp - }\n + HtmlContent - (145:12,0 [2] NoLinePragmas.cshtml) + IntermediateToken - (145:12,0 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (148:13,1 [27] NoLinePragmas.cshtml) + IntermediateToken - (148:13,1 [27] NoLinePragmas.cshtml) - CSharp - switch(i) {\n case 11:\n + HtmlContent - (175:15,0 [46] NoLinePragmas.cshtml) + IntermediateToken - (175:15,0 [8] NoLinePragmas.cshtml) - Html - + IntermediateToken - (183:15,8 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (186:15,11 [29] NoLinePragmas.cshtml) - Html - No really, we wrote 10 lines! + IntermediateToken - (215:15,40 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (219:15,44 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (221:16,0 [30] NoLinePragmas.cshtml) + IntermediateToken - (221:16,0 [30] NoLinePragmas.cshtml) - CSharp - break;\n default:\n + HtmlContent - (251:18,0 [39] NoLinePragmas.cshtml) + IntermediateToken - (251:18,0 [8] NoLinePragmas.cshtml) - Html - + IntermediateToken - (259:18,8 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (262:18,11 [22] NoLinePragmas.cshtml) - Html - Actually, we didn't... + IntermediateToken - (284:18,33 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (288:18,37 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (290:19,0 [19] NoLinePragmas.cshtml) + IntermediateToken - (290:19,0 [19] NoLinePragmas.cshtml) - CSharp - break;\n}\n + HtmlContent - (309:21,0 [2] NoLinePragmas.cshtml) + IntermediateToken - (309:21,0 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (312:22,1 [35] NoLinePragmas.cshtml) + IntermediateToken - (312:22,1 [35] NoLinePragmas.cshtml) - CSharp - for(int j = 1; j <= 10; j += 2) {\n + HtmlContent - (347:23,0 [29] NoLinePragmas.cshtml) + IntermediateToken - (347:23,0 [4] NoLinePragmas.cshtml) - Html - + IntermediateToken - (351:23,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (354:23,7 [22] NoLinePragmas.cshtml) - Html - Hello again from C#, # + CSharpExpression - (378:23,31 [1] NoLinePragmas.cshtml) + IntermediateToken - (378:23,31 [1] NoLinePragmas.cshtml) - CSharp - j + HtmlContent - (380:23,33 [6] NoLinePragmas.cshtml) + IntermediateToken - (380:23,33 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (384:23,37 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (386:24,0 [3] NoLinePragmas.cshtml) + IntermediateToken - (386:24,0 [3] NoLinePragmas.cshtml) - CSharp - }\n + HtmlContent - (389:25,0 [2] NoLinePragmas.cshtml) + IntermediateToken - (389:25,0 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (392:26,1 [7] NoLinePragmas.cshtml) + IntermediateToken - (392:26,1 [7] NoLinePragmas.cshtml) - CSharp - try {\n + HtmlContent - (399:27,0 [41] NoLinePragmas.cshtml) + IntermediateToken - (399:27,0 [4] NoLinePragmas.cshtml) - Html - + IntermediateToken - (403:27,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (406:27,7 [28] NoLinePragmas.cshtml) - Html - That time, we wrote 5 lines! + IntermediateToken - (434:27,35 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (438:27,39 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (440:28,0 [25] NoLinePragmas.cshtml) + IntermediateToken - (440:28,0 [25] NoLinePragmas.cshtml) - CSharp - } catch(Exception ex) {\n + HtmlContent - (465:29,0 [33] NoLinePragmas.cshtml) + IntermediateToken - (465:29,0 [4] NoLinePragmas.cshtml) - Html - + IntermediateToken - (469:29,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (472:29,7 [26] NoLinePragmas.cshtml) - Html - Oh no! An error occurred: + CSharpExpression - (500:29,35 [10] NoLinePragmas.cshtml) + IntermediateToken - (500:29,35 [10] NoLinePragmas.cshtml) - CSharp - ex.Message + HtmlContent - (511:29,46 [6] NoLinePragmas.cshtml) + IntermediateToken - (511:29,46 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (515:29,50 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (517:30,0 [5] NoLinePragmas.cshtml) + IntermediateToken - (517:30,0 [5] NoLinePragmas.cshtml) - CSharp - }\n\n + CSharpCode - (556:32,34 [2] NoLinePragmas.cshtml) + IntermediateToken - (556:32,34 [2] NoLinePragmas.cshtml) - CSharp - \n + HtmlContent - (558:33,0 [12] NoLinePragmas.cshtml) + IntermediateToken - (558:33,0 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (561:33,3 [9] NoLinePragmas.cshtml) - Html - i is now + CSharpExpression - (571:33,13 [1] NoLinePragmas.cshtml) + IntermediateToken - (571:33,13 [1] NoLinePragmas.cshtml) - CSharp - i + HtmlContent - (572:33,14 [8] NoLinePragmas.cshtml) + IntermediateToken - (572:33,14 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (576:33,18 [4] NoLinePragmas.cshtml) - Html - \n\n + CSharpCode - (581:35,1 [22] NoLinePragmas.cshtml) + IntermediateToken - (581:35,1 [22] NoLinePragmas.cshtml) - CSharp - lock(new object()) {\n + HtmlContent - (603:36,0 [53] NoLinePragmas.cshtml) + IntermediateToken - (603:36,0 [4] NoLinePragmas.cshtml) - Html - + IntermediateToken - (607:36,4 [2] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (610:36,7 [40] NoLinePragmas.cshtml) - Html - This block is locked, for your security! + IntermediateToken - (650:36,47 [4] NoLinePragmas.cshtml) - Html -

        + IntermediateToken - (654:36,51 [2] NoLinePragmas.cshtml) - Html - \n + CSharpCode - (656:37,0 [1] NoLinePragmas.cshtml) + IntermediateToken - (656:37,0 [1] NoLinePragmas.cshtml) - CSharp - } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml new file mode 100644 index 0000000000..fa87620317 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml @@ -0,0 +1,11 @@ +@{ + @ViewBag?.Data + @ViewBag.IntIndexer?[0] + @ViewBag.StrIndexer?["key"] + @ViewBag?.Method(Value?[23]?.More)?["key"] +} + +@ViewBag?.Data +@ViewBag.IntIndexer?[0] +@ViewBag.StrIndexer?["key"] +@ViewBag?.Method(Value?[23]?.More)?["key"] \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs new file mode 100644 index 0000000000..d12445b465 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.cs @@ -0,0 +1,117 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag?.Data; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag.IntIndexer?[0]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag.StrIndexer?["key"]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag?.Method(Value?[23]?.More)?["key"]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag?.Data; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag.IntIndexer?[0]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag.StrIndexer?["key"]; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +__o = ViewBag?.Method(Value?[23]?.More)?["key"]; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.html new file mode 100644 index 0000000000..7ad423b1f2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.codegen.html @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt new file mode 100644 index 0000000000..58e35883ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt @@ -0,0 +1,45 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (2:0,2 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (9:1,5 [13] NullConditionalExpressions.cshtml) + IntermediateToken - (9:1,5 [13] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Data + CSharpCode - (22:1,18 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (22:1,18 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (29:2,5 [22] NullConditionalExpressions.cshtml) + IntermediateToken - (29:2,5 [22] NullConditionalExpressions.cshtml) - CSharp - ViewBag.IntIndexer?[0] + CSharpCode - (51:2,27 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (51:2,27 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (58:3,5 [26] NullConditionalExpressions.cshtml) + IntermediateToken - (58:3,5 [26] NullConditionalExpressions.cshtml) - CSharp - ViewBag.StrIndexer?["key"] + CSharpCode - (84:3,31 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (84:3,31 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (91:4,5 [41] NullConditionalExpressions.cshtml) + IntermediateToken - (91:4,5 [41] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Method(Value?[23]?.More)?["key"] + CSharpCode - (132:4,46 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (132:4,46 [2] NullConditionalExpressions.cshtml) - CSharp - \n + HtmlContent - (137:6,0 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (137:6,0 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (140:7,1 [13] NullConditionalExpressions.cshtml) + IntermediateToken - (140:7,1 [13] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Data + HtmlContent - (153:7,14 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (153:7,14 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (156:8,1 [22] NullConditionalExpressions.cshtml) + IntermediateToken - (156:8,1 [22] NullConditionalExpressions.cshtml) - CSharp - ViewBag.IntIndexer?[0] + HtmlContent - (178:8,23 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (178:8,23 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (181:9,1 [26] NullConditionalExpressions.cshtml) + IntermediateToken - (181:9,1 [26] NullConditionalExpressions.cshtml) - CSharp - ViewBag.StrIndexer?["key"] + HtmlContent - (207:9,27 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (207:9,27 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (210:10,1 [41] NullConditionalExpressions.cshtml) + IntermediateToken - (210:10,1 [41] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Method(Value?[23]?.More)?["key"] diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt new file mode 100644 index 0000000000..c71bc3fa1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.mappings.txt @@ -0,0 +1,75 @@ +Source Location: (2:0,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +| + | +Generated Location: (772:19,2 [6] ) +| + | + +Source Location: (9:1,5 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag?.Data| +Generated Location: (957:27,6 [13] ) +|ViewBag?.Data| + +Source Location: (22:1,18 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +| + | +Generated Location: (1162:34,18 [6] ) +| + | + +Source Location: (29:2,5 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag.IntIndexer?[0]| +Generated Location: (1347:42,6 [22] ) +|ViewBag.IntIndexer?[0]| + +Source Location: (51:2,27 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +| + | +Generated Location: (1570:49,27 [6] ) +| + | + +Source Location: (58:3,5 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag.StrIndexer?["key"]| +Generated Location: (1755:57,6 [26] ) +|ViewBag.StrIndexer?["key"]| + +Source Location: (84:3,31 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +| + | +Generated Location: (1986:64,31 [6] ) +| + | + +Source Location: (91:4,5 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag?.Method(Value?[23]?.More)?["key"]| +Generated Location: (2171:72,6 [41] ) +|ViewBag?.Method(Value?[23]?.More)?["key"]| + +Source Location: (132:4,46 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +| +| +Generated Location: (2432:79,46 [2] ) +| +| + +Source Location: (140:7,1 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag?.Data| +Generated Location: (2611:86,6 [13] ) +|ViewBag?.Data| + +Source Location: (156:8,1 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag.IntIndexer?[0]| +Generated Location: (2804:93,6 [22] ) +|ViewBag.IntIndexer?[0]| + +Source Location: (181:9,1 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag.StrIndexer?["key"]| +Generated Location: (3007:100,6 [26] ) +|ViewBag.StrIndexer?["key"]| + +Source Location: (210:10,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml) +|ViewBag?.Method(Value?[23]?.More)?["key"]| +Generated Location: (3214:107,6 [41] ) +|ViewBag?.Method(Value?[23]?.More)?["key"]| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs new file mode 100644 index 0000000000..5ed8813cb2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.codegen.cs @@ -0,0 +1,78 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c76f9ddb44b2830babd64c0afeaa96aba6a6ae27" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"c76f9ddb44b2830babd64c0afeaa96aba6a6ae27", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag?.Data); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag.IntIndexer?[0]); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag.StrIndexer?["key"]); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag?.Method(Value?[23]?.More)?["key"]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag?.Data); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag.IntIndexer?[0]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 10 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag.StrIndexer?["key"]); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions.cshtml" +Write(ViewBag?.Method(Value?[23]?.More)?["key"]); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt new file mode 100644 index 0000000000..8fd7d3dc26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_Runtime.ir.txt @@ -0,0 +1,40 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (2:0,2 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (9:1,5 [13] NullConditionalExpressions.cshtml) + IntermediateToken - (9:1,5 [13] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Data + CSharpCode - (22:1,18 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (22:1,18 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (29:2,5 [22] NullConditionalExpressions.cshtml) + IntermediateToken - (29:2,5 [22] NullConditionalExpressions.cshtml) - CSharp - ViewBag.IntIndexer?[0] + CSharpCode - (51:2,27 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (51:2,27 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (58:3,5 [26] NullConditionalExpressions.cshtml) + IntermediateToken - (58:3,5 [26] NullConditionalExpressions.cshtml) - CSharp - ViewBag.StrIndexer?["key"] + CSharpCode - (84:3,31 [6] NullConditionalExpressions.cshtml) + IntermediateToken - (84:3,31 [6] NullConditionalExpressions.cshtml) - CSharp - \n + CSharpExpression - (91:4,5 [41] NullConditionalExpressions.cshtml) + IntermediateToken - (91:4,5 [41] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Method(Value?[23]?.More)?["key"] + CSharpCode - (132:4,46 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (132:4,46 [2] NullConditionalExpressions.cshtml) - CSharp - \n + HtmlContent - (137:6,0 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (137:6,0 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (140:7,1 [13] NullConditionalExpressions.cshtml) + IntermediateToken - (140:7,1 [13] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Data + HtmlContent - (153:7,14 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (153:7,14 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (156:8,1 [22] NullConditionalExpressions.cshtml) + IntermediateToken - (156:8,1 [22] NullConditionalExpressions.cshtml) - CSharp - ViewBag.IntIndexer?[0] + HtmlContent - (178:8,23 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (178:8,23 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (181:9,1 [26] NullConditionalExpressions.cshtml) + IntermediateToken - (181:9,1 [26] NullConditionalExpressions.cshtml) - CSharp - ViewBag.StrIndexer?["key"] + HtmlContent - (207:9,27 [2] NullConditionalExpressions.cshtml) + IntermediateToken - (207:9,27 [2] NullConditionalExpressions.cshtml) - Html - \n + CSharpExpression - (210:10,1 [41] NullConditionalExpressions.cshtml) + IntermediateToken - (210:10,1 [41] NullConditionalExpressions.cshtml) - CSharp - ViewBag?.Method(Value?[23]?.More)?["key"] diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml new file mode 100644 index 0000000000..33162eb90b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml @@ -0,0 +1,5 @@ + + +@if (true) { + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs new file mode 100644 index 0000000000..9049386386 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.html new file mode 100644 index 0000000000..1675f64383 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.codegen.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..681454769b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt @@ -0,0 +1,3 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt new file mode 100644 index 0000000000..16ff60d4df --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [16] OpenedIf.cshtml) + IntermediateToken - (0:0,0 [5] OpenedIf.cshtml) - Html - + IntermediateToken - (6:0,6 [2] OpenedIf.cshtml) - Html - \n + IntermediateToken - (8:1,0 [5] OpenedIf.cshtml) - Html - + IntermediateToken - (14:1,6 [2] OpenedIf.cshtml) - Html - \n + CSharpCode - (17:2,1 [14] OpenedIf.cshtml) + IntermediateToken - (17:2,1 [14] OpenedIf.cshtml) - CSharp - if (true) { \n + HtmlContent - (31:3,0 [7] OpenedIf.cshtml) + IntermediateToken - (31:3,0 [7] OpenedIf.cshtml) - Html - + CSharpCode - (38:3,7 [2] OpenedIf.cshtml) + IntermediateToken - (38:3,7 [2] OpenedIf.cshtml) - CSharp - \n + HtmlContent - (40:4,0 [7] OpenedIf.cshtml) + IntermediateToken - (40:4,0 [7] OpenedIf.cshtml) - Html - + CSharpCode - (47:4,7 [0] OpenedIf.cshtml) + IntermediateToken - (47:4,7 [0] OpenedIf.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt new file mode 100644 index 0000000000..bf39975d37 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (17:2,1 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml) +|if (true) { +| +Generated Location: (735:19,1 [14] ) +|if (true) { +| + +Source Location: (38:3,7 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml) +| +| +Generated Location: (909:26,7 [2] ) +| +| + +Source Location: (47:4,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml) +|| +Generated Location: (1071:33,7 [0] ) +|| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs new file mode 100644 index 0000000000..5b6c2d401d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.codegen.cs @@ -0,0 +1,27 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "afefc9ccf10183402eae0b9e4175393b3797a27b" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"afefc9ccf10183402eae0b9e4175393b3797a27b", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml" + if (true) { + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt new file mode 100644 index 0000000000..681454769b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt @@ -0,0 +1,3 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt new file mode 100644 index 0000000000..4aa0558ca0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.ir.txt @@ -0,0 +1,21 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [16] OpenedIf.cshtml) + IntermediateToken - (0:0,0 [5] OpenedIf.cshtml) - Html - + IntermediateToken - (6:0,6 [2] OpenedIf.cshtml) - Html - \n + IntermediateToken - (8:1,0 [5] OpenedIf.cshtml) - Html - + IntermediateToken - (14:1,6 [2] OpenedIf.cshtml) - Html - \n + CSharpCode - (17:2,1 [14] OpenedIf.cshtml) + IntermediateToken - (17:2,1 [14] OpenedIf.cshtml) - CSharp - if (true) { \n + HtmlContent - (31:3,0 [16] OpenedIf.cshtml) + IntermediateToken - (31:3,0 [7] OpenedIf.cshtml) - Html - + IntermediateToken - (38:3,7 [2] OpenedIf.cshtml) - Html - \n + IntermediateToken - (40:4,0 [7] OpenedIf.cshtml) - Html - + CSharpCode - (47:4,7 [0] OpenedIf.cshtml) + IntermediateToken - (47:4,7 [0] OpenedIf.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml new file mode 100644 index 0000000000..ab30e853fd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml @@ -0,0 +1,5 @@ +@{ +/* +int i =10; +int j =20; +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.codegen.cs new file mode 100644 index 0000000000..e6b9eddd15 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml" + +/* +int i =10; +int j =20; +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.codegen.html new file mode 100644 index 0000000000..d007646328 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.codegen.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..23ff3e26b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt new file mode 100644 index 0000000000..42fae7cec7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [31] ParserError.cshtml) + IntermediateToken - (2:0,2 [31] ParserError.cshtml) - CSharp - \n/*\nint i =10;\nint j =20;\n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.mappings.txt new file mode 100644 index 0000000000..c3a898b88e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (2:0,2 [31] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml) +| +/* +int i =10; +int j =20; +}| +Generated Location: (742:19,2 [31] ) +| +/* +int i =10; +int j =20; +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs new file mode 100644 index 0000000000..27528c0e76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.codegen.cs @@ -0,0 +1,29 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a94df714867cbb0e2369fe24157b5d04e2e7a9cf" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a94df714867cbb0e2369fe24157b5d04e2e7a9cf", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml" + +/* +int i =10; +int j =20; +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt new file mode 100644 index 0000000000..23ff3e26b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt new file mode 100644 index 0000000000..8f60e461b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.ir.txt @@ -0,0 +1,8 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [31] ParserError.cshtml) + IntermediateToken - (2:0,2 [31] ParserError.cshtml) - CSharp - \n/*\nint i =10;\nint j =20;\n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml new file mode 100644 index 0000000000..797a828688 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml @@ -0,0 +1,23 @@ +@addTagHelper "*, TestAssembly" + +@{ + var literate = "or illiterate"; + var intDictionary = new Dictionary + { + { "three", 3 }, + }; + var stringDictionary = new SortedDictionary + { + { "name", "value" }, + }; +} + +
        + + + + +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..18c7aff3dd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,154 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_DesignTime + { + #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::TestNamespace.InputTagHelper1 __TestNamespace_InputTagHelper1; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + + var literate = "or illiterate"; + var intDictionary = new Dictionary + { + { "three", 3 }, + }; + var stringDictionary = new SortedDictionary + { + { "name", "value" }, + }; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty = intDictionary; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty = __TestNamespace_InputTagHelper1.IntDictionaryProperty; +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + __TestNamespace_InputTagHelper1.StringDictionaryProperty = stringDictionary; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.StringDictionaryProperty = __TestNamespace_InputTagHelper1.StringDictionaryProperty; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty = intDictionary; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty = __TestNamespace_InputTagHelper1.IntDictionaryProperty; +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + __TestNamespace_InputTagHelper1.IntDictionaryProperty["garlic"] = 37; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty["garlic"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["garlic"]; +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + __TestNamespace_InputTagHelper1.IntProperty = 42; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty["grabber"] = __TestNamespace_InputTagHelper1.IntProperty; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntProperty = 42; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty["grabber"] = __TestNamespace_InputTagHelper1.IntProperty; +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty["salt"] = 37; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty["salt"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["salt"]; +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + __TestNamespace_InputTagHelper1.IntDictionaryProperty["pepper"] = 98; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty["pepper"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["pepper"]; + __TestNamespace_InputTagHelper1.StringProperty = "string"; + __TestNamespace_InputTagHelper2.StringDictionaryProperty["grabber"] = __TestNamespace_InputTagHelper1.StringProperty; + __TestNamespace_InputTagHelper1.StringDictionaryProperty["paprika"] = "another string"; + __TestNamespace_InputTagHelper2.StringDictionaryProperty["paprika"] = __TestNamespace_InputTagHelper1.StringDictionaryProperty["paprika"]; +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + __o = literate; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper1.StringDictionaryProperty["cumin"] = string.Empty; + __TestNamespace_InputTagHelper2.StringDictionaryProperty["cumin"] = __TestNamespace_InputTagHelper1.StringDictionaryProperty["cumin"]; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty["value"] = 37; + +#line default +#line hidden +#nullable disable + __TestNamespace_InputTagHelper2.IntDictionaryProperty["value"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["value"]; + __TestNamespace_InputTagHelper1.StringDictionaryProperty["thyme"] = "string"; + __TestNamespace_InputTagHelper2.StringDictionaryProperty["thyme"] = __TestNamespace_InputTagHelper1.StringDictionaryProperty["thyme"]; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..add0db7eff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt @@ -0,0 +1,136 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper1 - __TestNamespace_InputTagHelper1 + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] PrefixedAttributeTagHelpers.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (31:0,31 [4] PrefixedAttributeTagHelpers.cshtml) - Html - \n\n + CSharpCode - (37:2,2 [242] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (37:2,2 [242] PrefixedAttributeTagHelpers.cshtml) - CSharp - \n var literate = "or illiterate";\n var intDictionary = new Dictionary\n {\n { "three", 3 },\n };\n var stringDictionary = new SortedDictionary\n {\n { "name", "value" },\n };\n + HtmlContent - (282:13,0 [49] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (282:13,0 [2] PrefixedAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (284:14,0 [4] PrefixedAttributeTagHelpers.cshtml) - Html -
        + IntermediateToken - (325:14,41 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (331:15,4 [92] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (344:15,17 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (344:15,17 [8] PrefixedAttributeTagHelpers.cshtml) - Html - checkbox + DefaultTagHelperProperty - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - string-dictionary - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper1.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - CSharp - stringDictionary + DefaultTagHelperProperty - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - string-dictionary - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - CSharp - stringDictionary + DefaultTagHelperExecute - + HtmlContent - (423:15,96 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (423:15,96 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (429:16,4 [103] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (442:16,17 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (442:16,17 [8] PrefixedAttributeTagHelpers.cshtml) - Html - password + DefaultTagHelperProperty - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-garlic - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-garlic - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper1.IntProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperProperty - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperExecute - + HtmlContent - (532:16,107 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (532:16,107 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (538:17,4 [257] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (551:17,17 [5] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (551:17,17 [5] PrefixedAttributeTagHelpers.cshtml) - Html - radio + DefaultTagHelperProperty - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper1.IntProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperProperty - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperProperty - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-salt - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-salt - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-pepper - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 98 + DefaultTagHelperProperty - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-pepper - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 98 + DefaultTagHelperHtmlAttribute - - int-prefix-salt - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (655:18,96 [1] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (655:18,96 [1] PrefixedAttributeTagHelpers.cshtml) - Html - 8 + DefaultTagHelperProperty - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) - string-prefix-grabber - string TestNamespace.InputTagHelper1.StringProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) - Html - string + DefaultTagHelperProperty - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) - string-prefix-grabber - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) - Html - string + DefaultTagHelperProperty - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) - string-prefix-paprika - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper1.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) - Html - another string + DefaultTagHelperProperty - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) - string-prefix-paprika - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) - Html - another string + DefaultTagHelperProperty - (773:20,32 [19] PrefixedAttributeTagHelpers.cshtml) - string-prefix-cumin - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper1.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (773:20,32 [9] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (773:20,32 [8] PrefixedAttributeTagHelpers.cshtml) - Html - literate + IntermediateToken - (781:20,40 [1] PrefixedAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) - CSharp - literate + HtmlContent - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) - Html - ? + DefaultTagHelperProperty - (773:20,32 [19] PrefixedAttributeTagHelpers.cshtml) - string-prefix-cumin - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (773:20,32 [9] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (773:20,32 [8] PrefixedAttributeTagHelpers.cshtml) - Html - literate + IntermediateToken - (781:20,40 [1] PrefixedAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) - CSharp - literate + HtmlContent - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) - Html - ? + DefaultTagHelperExecute - + HtmlContent - (795:20,54 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (795:20,54 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (801:21,4 [60] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-value - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-value - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) - string-prefix-thyme - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper1.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) - Html - string + DefaultTagHelperProperty - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) - string-prefix-thyme - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) - Html - string + DefaultTagHelperExecute - + HtmlContent - (861:21,64 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (861:21,64 [2] PrefixedAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (863:22,0 [6] PrefixedAttributeTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..ca03f84581 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,80 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|"*, TestAssembly"| +Generated Location: (1139:19,37 [17] ) +|"*, TestAssembly"| + +Source Location: (37:2,2 [242] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +| + var literate = "or illiterate"; + var intDictionary = new Dictionary + { + { "three", 3 }, + }; + var stringDictionary = new SortedDictionary + { + { "name", "value" }, + }; +| +Generated Location: (1647:36,2 [242] ) +| + var literate = "or illiterate"; + var intDictionary = new Dictionary + { + { "three", 3 }, + }; + var stringDictionary = new SortedDictionary + { + { "name", "value" }, + }; +| + +Source Location: (370:15,43 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|intDictionary| +Generated Location: (2328:54,56 [13] ) +|intDictionary| + +Source Location: (404:15,77 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|stringDictionary| +Generated Location: (2718:62,77 [16] ) +|stringDictionary| + +Source Location: (468:16,43 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|intDictionary| +Generated Location: (3382:73,56 [13] ) +|intDictionary| + +Source Location: (502:16,77 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|37| +Generated Location: (3772:81,77 [2] ) +|37| + +Source Location: (526:16,101 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|42| +Generated Location: (4195:89,101 [2] ) +|42| + +Source Location: (590:18,31 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|42| +Generated Location: (4830:100,46 [2] ) +|42| + +Source Location: (611:18,52 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|37| +Generated Location: (5197:108,64 [2] ) +|37| + +Source Location: (634:18,75 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|98| +Generated Location: (5590:116,75 [2] ) +|98| + +Source Location: (783:20,42 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|literate| +Generated Location: (6410:128,42 [8] ) +|literate| + +Source Location: (826:21,29 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml) +|37| +Generated Location: (7188:140,65 [2] ) +|37| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..c89db0cc65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.codegen.cs @@ -0,0 +1,284 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "fc1a85ca24bc6ae7170b67e2d8371cede965879e" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"fc1a85ca24bc6ae7170b67e2d8371cede965879e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("password"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("radio"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("int-prefix-salt", new global::Microsoft.AspNetCore.Html.HtmlString("8"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("string-prefix-grabber", "string", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("string-prefix-paprika", "another string", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_6 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("string-prefix-thyme", "string", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.InputTagHelper1 __TestNamespace_InputTagHelper1; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + + var literate = "or illiterate"; + var intDictionary = new Dictionary + { + { "three", 3 }, + }; + var stringDictionary = new SortedDictionary + { + { "name", "value" }, + }; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n
        \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper1); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty = intDictionary; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-dictionary", __TestNamespace_InputTagHelper1.IntDictionaryProperty, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.IntDictionaryProperty = __TestNamespace_InputTagHelper1.IntDictionaryProperty; +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.StringDictionaryProperty = stringDictionary; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("string-dictionary", __TestNamespace_InputTagHelper1.StringDictionaryProperty, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.StringDictionaryProperty = __TestNamespace_InputTagHelper1.StringDictionaryProperty; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper1); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty = intDictionary; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-dictionary", __TestNamespace_InputTagHelper1.IntDictionaryProperty, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.IntDictionaryProperty = __TestNamespace_InputTagHelper1.IntDictionaryProperty; + if (__TestNamespace_InputTagHelper1.IntDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("int-prefix-garlic", "TestNamespace.InputTagHelper1", "IntDictionaryProperty")); + } +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty["garlic"] = 37; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-prefix-garlic", __TestNamespace_InputTagHelper1.IntDictionaryProperty["garlic"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + if (__TestNamespace_InputTagHelper2.IntDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("int-prefix-garlic", "TestNamespace.InputTagHelper2", "IntDictionaryProperty")); + } + __TestNamespace_InputTagHelper2.IntDictionaryProperty["garlic"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["garlic"]; +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntProperty = 42; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-prefix-grabber", __TestNamespace_InputTagHelper1.IntProperty, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.IntDictionaryProperty["grabber"] = __TestNamespace_InputTagHelper1.IntProperty; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper1); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntProperty = 42; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-prefix-grabber", __TestNamespace_InputTagHelper1.IntProperty, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + if (__TestNamespace_InputTagHelper2.IntDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("int-prefix-grabber", "TestNamespace.InputTagHelper2", "IntDictionaryProperty")); + } + __TestNamespace_InputTagHelper2.IntDictionaryProperty["grabber"] = __TestNamespace_InputTagHelper1.IntProperty; + if (__TestNamespace_InputTagHelper1.IntDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("int-prefix-salt", "TestNamespace.InputTagHelper1", "IntDictionaryProperty")); + } +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty["salt"] = 37; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-prefix-salt", __TestNamespace_InputTagHelper1.IntDictionaryProperty["salt"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.IntDictionaryProperty["salt"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["salt"]; +#nullable restore +#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty["pepper"] = 98; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-prefix-pepper", __TestNamespace_InputTagHelper1.IntDictionaryProperty["pepper"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __TestNamespace_InputTagHelper2.IntDictionaryProperty["pepper"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["pepper"]; + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + __TestNamespace_InputTagHelper1.StringProperty = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + if (__TestNamespace_InputTagHelper2.StringDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("string-prefix-grabber", "TestNamespace.InputTagHelper2", "StringDictionaryProperty")); + } + __TestNamespace_InputTagHelper2.StringDictionaryProperty["grabber"] = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + if (__TestNamespace_InputTagHelper1.StringDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("string-prefix-paprika", "TestNamespace.InputTagHelper1", "StringDictionaryProperty")); + } + __TestNamespace_InputTagHelper1.StringDictionaryProperty["paprika"] = (string)__tagHelperAttribute_5.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5); + __TestNamespace_InputTagHelper2.StringDictionaryProperty["paprika"] = (string)__tagHelperAttribute_5.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5); + if (__TestNamespace_InputTagHelper1.StringDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("string-prefix-cumin", "TestNamespace.InputTagHelper1", "StringDictionaryProperty")); + } + BeginWriteTagHelperAttribute(); + WriteLiteral("literate "); +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" + WriteLiteral(literate); + +#line default +#line hidden +#nullable disable + WriteLiteral("?"); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_InputTagHelper1.StringDictionaryProperty["cumin"] = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("string-prefix-cumin", __TestNamespace_InputTagHelper1.StringDictionaryProperty["cumin"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + if (__TestNamespace_InputTagHelper2.StringDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("string-prefix-cumin", "TestNamespace.InputTagHelper2", "StringDictionaryProperty")); + } + __TestNamespace_InputTagHelper2.StringDictionaryProperty["cumin"] = __TestNamespace_InputTagHelper1.StringDictionaryProperty["cumin"]; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper1 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper1); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + if (__TestNamespace_InputTagHelper1.IntDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("int-prefix-value", "TestNamespace.InputTagHelper1", "IntDictionaryProperty")); + } +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers.cshtml" +__TestNamespace_InputTagHelper1.IntDictionaryProperty["value"] = 37; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("int-prefix-value", __TestNamespace_InputTagHelper1.IntDictionaryProperty["value"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + if (__TestNamespace_InputTagHelper2.IntDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("int-prefix-value", "TestNamespace.InputTagHelper2", "IntDictionaryProperty")); + } + __TestNamespace_InputTagHelper2.IntDictionaryProperty["value"] = __TestNamespace_InputTagHelper1.IntDictionaryProperty["value"]; + if (__TestNamespace_InputTagHelper1.StringDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("string-prefix-thyme", "TestNamespace.InputTagHelper1", "StringDictionaryProperty")); + } + __TestNamespace_InputTagHelper1.StringDictionaryProperty["thyme"] = (string)__tagHelperAttribute_6.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6); + if (__TestNamespace_InputTagHelper2.StringDictionaryProperty == null) + { + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("string-prefix-thyme", "TestNamespace.InputTagHelper2", "StringDictionaryProperty")); + } + __TestNamespace_InputTagHelper2.StringDictionaryProperty["thyme"] = (string)__tagHelperAttribute_6.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
        "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..892245a292 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_Runtime.ir.txt @@ -0,0 +1,117 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - password - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - type - radio - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - int-prefix-salt - 8 - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_4 - string-prefix-grabber - string - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_5 - string-prefix-paprika - another string - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_6 - string-prefix-thyme - string - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.InputTagHelper1 - __TestNamespace_InputTagHelper1 + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (33:1,0 [2] PrefixedAttributeTagHelpers.cshtml) - Html - \n + CSharpCode - (37:2,2 [242] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (37:2,2 [242] PrefixedAttributeTagHelpers.cshtml) - CSharp - \n var literate = "or illiterate";\n var intDictionary = new Dictionary\n {\n { "three", 3 },\n };\n var stringDictionary = new SortedDictionary\n {\n { "name", "value" },\n };\n + HtmlContent - (282:13,0 [49] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (282:13,0 [2] PrefixedAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (284:14,0 [4] PrefixedAttributeTagHelpers.cshtml) - Html -
        + IntermediateToken - (325:14,41 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (331:15,4 [92] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperProperty - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (370:15,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - string-dictionary - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper1.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - CSharp - stringDictionary + DefaultTagHelperProperty - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - string-dictionary - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (404:15,77 [16] PrefixedAttributeTagHelpers.cshtml) - CSharp - stringDictionary + DefaultTagHelperExecute - + HtmlContent - (423:15,96 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (423:15,96 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (429:16,4 [103] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperProperty - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - int-dictionary - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (468:16,43 [13] PrefixedAttributeTagHelpers.cshtml) - CSharp - intDictionary + DefaultTagHelperProperty - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-garlic - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-garlic - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (502:16,77 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper1.IntProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperProperty - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (526:16,101 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperExecute - + HtmlContent - (532:16,107 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (532:16,107 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (538:17,4 [257] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperProperty - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper1.IntProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperProperty - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-grabber - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (590:18,31 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 42 + DefaultTagHelperProperty - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-salt - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-salt - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (611:18,52 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-pepper - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 98 + DefaultTagHelperProperty - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-pepper - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (634:18,75 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 98 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + PreallocatedTagHelperProperty - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) - __tagHelperAttribute_4 - string-prefix-grabber - StringProperty + PreallocatedTagHelperProperty - (693:19,34 [6] PrefixedAttributeTagHelpers.cshtml) - __tagHelperAttribute_4 - string-prefix-grabber - StringDictionaryProperty + PreallocatedTagHelperProperty - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) - __tagHelperAttribute_5 - string-prefix-paprika - StringDictionaryProperty + PreallocatedTagHelperProperty - (724:19,65 [14] PrefixedAttributeTagHelpers.cshtml) - __tagHelperAttribute_5 - string-prefix-paprika - StringDictionaryProperty + DefaultTagHelperProperty - (773:20,32 [19] PrefixedAttributeTagHelpers.cshtml) - string-prefix-cumin - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper1.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (773:20,32 [9] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (773:20,32 [8] PrefixedAttributeTagHelpers.cshtml) - Html - literate + IntermediateToken - (781:20,40 [1] PrefixedAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) - CSharp - literate + HtmlContent - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) - Html - ? + DefaultTagHelperProperty - (773:20,32 [19] PrefixedAttributeTagHelpers.cshtml) - string-prefix-cumin - Namespace.DictionaryWithoutParameterlessConstructor TestNamespace.InputTagHelper2.StringDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (773:20,32 [9] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (773:20,32 [8] PrefixedAttributeTagHelpers.cshtml) - Html - literate + IntermediateToken - (781:20,40 [1] PrefixedAttributeTagHelpers.cshtml) - Html - + CSharpExpression - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (783:20,42 [8] PrefixedAttributeTagHelpers.cshtml) - CSharp - literate + HtmlContent - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (791:20,50 [1] PrefixedAttributeTagHelpers.cshtml) - Html - ? + DefaultTagHelperExecute - + HtmlContent - (795:20,54 [6] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (795:20,54 [6] PrefixedAttributeTagHelpers.cshtml) - Html - \n + TagHelper - (801:21,4 [60] PrefixedAttributeTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper1 + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-value - System.Collections.Generic.IDictionary TestNamespace.InputTagHelper1.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + DefaultTagHelperProperty - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - int-prefix-value - int TestNamespace.InputTagHelper2.IntDictionaryProperty - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (826:21,29 [2] PrefixedAttributeTagHelpers.cshtml) - CSharp - 37 + PreallocatedTagHelperProperty - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) - __tagHelperAttribute_6 - string-prefix-thyme - StringDictionaryProperty + PreallocatedTagHelperProperty - (851:21,54 [6] PrefixedAttributeTagHelpers.cshtml) - __tagHelperAttribute_6 - string-prefix-thyme - StringDictionaryProperty + DefaultTagHelperExecute - + HtmlContent - (861:21,64 [8] PrefixedAttributeTagHelpers.cshtml) + IntermediateToken - (861:21,64 [2] PrefixedAttributeTagHelpers.cshtml) - Html - \n + IntermediateToken - (863:22,0 [6] PrefixedAttributeTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml new file mode 100644 index 0000000000..1edd2fcc49 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml @@ -0,0 +1,18 @@ +@*This is not going to be rendered*@ +

        This should @* not *@ be shown

        + +@{ + @* throw new Exception("Oh no!") *@ + Exception foo = @* new Exception("Oh no!") *@ null; + if(foo != null) { + throw foo; + } +} + +@{ var bar = "@* bar *@"; } +

        But this should show the comment syntax: @bar

        + +@(a@**@b) + + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs new file mode 100644 index 0000000000..d4fb4049ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.cs @@ -0,0 +1,69 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + + Exception foo = + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + null; + if(foo != null) { + throw foo; + } + +#line default +#line hidden +#nullable disable +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + var bar = "@* bar *@"; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + __o = bar; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" +__o = ab; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.html new file mode 100644 index 0000000000..f851e2e597 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.codegen.html @@ -0,0 +1,18 @@ + +

        This should be shown

        + + + + + + + + + + +

        But this should show the comment syntax:

        + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt new file mode 100644 index 0000000000..20961d3dc2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt @@ -0,0 +1,55 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (38:1,0 [15] RazorComments.cshtml) + IntermediateToken - (38:1,0 [2] RazorComments.cshtml) - Html -

        + IntermediateToken - (41:1,3 [12] RazorComments.cshtml) - Html - This should + HtmlContent - (62:1,24 [17] RazorComments.cshtml) + IntermediateToken - (62:1,24 [9] RazorComments.cshtml) - Html - be shown + IntermediateToken - (71:1,33 [4] RazorComments.cshtml) - Html -

        + IntermediateToken - (75:1,37 [4] RazorComments.cshtml) - Html - \n\n + CSharpCode - (81:3,2 [6] RazorComments.cshtml) + IntermediateToken - (81:3,2 [6] RazorComments.cshtml) - CSharp - \n + CSharpCode - (122:4,39 [22] RazorComments.cshtml) + IntermediateToken - (122:4,39 [22] RazorComments.cshtml) - CSharp - \n Exception foo = + CSharpCode - (173:5,49 [58] RazorComments.cshtml) + IntermediateToken - (173:5,49 [58] RazorComments.cshtml) - CSharp - null;\n if(foo != null) {\n throw foo;\n }\n + HtmlContent - (234:10,0 [2] RazorComments.cshtml) + IntermediateToken - (234:10,0 [2] RazorComments.cshtml) - Html - \n + CSharpCode - (238:11,2 [24] RazorComments.cshtml) + IntermediateToken - (238:11,2 [24] RazorComments.cshtml) - CSharp - var bar = "@* bar *@"; + HtmlContent - (265:12,0 [44] RazorComments.cshtml) + IntermediateToken - (265:12,0 [2] RazorComments.cshtml) - Html -

        + IntermediateToken - (268:12,3 [41] RazorComments.cshtml) - Html - But this should show the comment syntax: + CSharpExpression - (310:12,45 [3] RazorComments.cshtml) + IntermediateToken - (310:12,45 [3] RazorComments.cshtml) - CSharp - bar + HtmlContent - (313:12,48 [8] RazorComments.cshtml) + IntermediateToken - (313:12,48 [4] RazorComments.cshtml) - Html -

        + IntermediateToken - (317:12,52 [4] RazorComments.cshtml) - Html - \n\n + CSharpExpression - (323:14,2 [2] RazorComments.cshtml) + IntermediateToken - (323:14,2 [1] RazorComments.cshtml) - CSharp - a + IntermediateToken - (328:14,7 [1] RazorComments.cshtml) - CSharp - b + HtmlContent - (330:14,9 [85] RazorComments.cshtml) + IntermediateToken - (330:14,9 [4] RazorComments.cshtml) - Html - \n\n + IntermediateToken - (334:16,0 [6] RazorComments.cshtml) - Html - + IntermediateToken - (406:16,72 [2] RazorComments.cshtml) - Html - \n + IntermediateToken - (408:17,0 [6] RazorComments.cshtml) - Html - + IntermediateToken - (473:17,65 [2] RazorComments.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt new file mode 100644 index 0000000000..3ad7eb8bbd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.mappings.txt @@ -0,0 +1,47 @@ +Source Location: (81:3,2 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +| + | +Generated Location: (746:19,2 [6] ) +| + | + +Source Location: (122:4,39 [22] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +| + Exception foo = | +Generated Location: (951:27,39 [22] ) +| + Exception foo = | + +Source Location: (173:5,49 [58] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +| null; + if(foo != null) { + throw foo; + } +| +Generated Location: (1182:35,49 [58] ) +| null; + if(foo != null) { + throw foo; + } +| + +Source Location: (238:11,2 [24] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +| var bar = "@* bar *@"; | +Generated Location: (1401:45,2 [24] ) +| var bar = "@* bar *@"; | + +Source Location: (310:12,45 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +|bar| +Generated Location: (1631:52,45 [3] ) +|bar| + +Source Location: (323:14,2 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +|a| +Generated Location: (1802:59,6 [1] ) +|a| + +Source Location: (328:14,7 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml) +|b| +Generated Location: (1803:59,7 [1] ) +|b| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs new file mode 100644 index 0000000000..b833277cf4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.codegen.cs @@ -0,0 +1,64 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4d553281e07fafc67ca0139b27ee95724a37f162" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4d553281e07fafc67ca0139b27ee95724a37f162", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("

        This should "); + WriteLiteral(" be shown

        \r\n\r\n"); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + + Exception foo = + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + null; + if(foo != null) { + throw foo; + } + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + var bar = "@* bar *@"; + +#line default +#line hidden +#nullable disable + WriteLiteral("

        But this should show the comment syntax: "); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" + Write(bar); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n\r\n"); +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments.cshtml" +Write(ab); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n\r\n\r\n\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt new file mode 100644 index 0000000000..1229ef836f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_Runtime.ir.txt @@ -0,0 +1,50 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (38:1,0 [15] RazorComments.cshtml) + IntermediateToken - (38:1,0 [2] RazorComments.cshtml) - Html -

        + IntermediateToken - (41:1,3 [12] RazorComments.cshtml) - Html - This should + HtmlContent - (62:1,24 [17] RazorComments.cshtml) + IntermediateToken - (62:1,24 [9] RazorComments.cshtml) - Html - be shown + IntermediateToken - (71:1,33 [4] RazorComments.cshtml) - Html -

        + IntermediateToken - (75:1,37 [4] RazorComments.cshtml) - Html - \n\n + CSharpCode - (81:3,2 [6] RazorComments.cshtml) + IntermediateToken - (81:3,2 [6] RazorComments.cshtml) - CSharp - \n + CSharpCode - (122:4,39 [22] RazorComments.cshtml) + IntermediateToken - (122:4,39 [22] RazorComments.cshtml) - CSharp - \n Exception foo = + CSharpCode - (173:5,49 [58] RazorComments.cshtml) + IntermediateToken - (173:5,49 [58] RazorComments.cshtml) - CSharp - null;\n if(foo != null) {\n throw foo;\n }\n + HtmlContent - (234:10,0 [2] RazorComments.cshtml) + IntermediateToken - (234:10,0 [2] RazorComments.cshtml) - Html - \n + CSharpCode - (238:11,2 [24] RazorComments.cshtml) + IntermediateToken - (238:11,2 [24] RazorComments.cshtml) - CSharp - var bar = "@* bar *@"; + HtmlContent - (265:12,0 [44] RazorComments.cshtml) + IntermediateToken - (265:12,0 [2] RazorComments.cshtml) - Html -

        + IntermediateToken - (268:12,3 [41] RazorComments.cshtml) - Html - But this should show the comment syntax: + CSharpExpression - (310:12,45 [3] RazorComments.cshtml) + IntermediateToken - (310:12,45 [3] RazorComments.cshtml) - CSharp - bar + HtmlContent - (313:12,48 [8] RazorComments.cshtml) + IntermediateToken - (313:12,48 [4] RazorComments.cshtml) - Html -

        + IntermediateToken - (317:12,52 [4] RazorComments.cshtml) - Html - \n\n + CSharpExpression - (323:14,2 [2] RazorComments.cshtml) + IntermediateToken - (323:14,2 [1] RazorComments.cshtml) - CSharp - a + IntermediateToken - (328:14,7 [1] RazorComments.cshtml) - CSharp - b + HtmlContent - (330:14,9 [85] RazorComments.cshtml) + IntermediateToken - (330:14,9 [4] RazorComments.cshtml) - Html - \n\n + IntermediateToken - (334:16,0 [6] RazorComments.cshtml) - Html - + IntermediateToken - (406:16,72 [2] RazorComments.cshtml) - Html - \n + IntermediateToken - (408:17,0 [6] RazorComments.cshtml) - Html - + IntermediateToken - (473:17,65 [2] RazorComments.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective.cshtml new file mode 100644 index 0000000000..a8cd525a3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective.cshtml @@ -0,0 +1 @@ +@removeTagHelper *, TestAssembly diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.codegen.cs new file mode 100644 index 0000000000..8a96ffc840 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RemoveTagHelperDirective_DesignTime + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.codegen.html new file mode 100644 index 0000000000..77def406f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.codegen.html @@ -0,0 +1 @@ + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt new file mode 100644 index 0000000000..8a37436277 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt @@ -0,0 +1,14 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RemoveTagHelperDirective_DesignTime - - + DesignTimeDirective - + DirectiveToken - (17:0,17 [15] RemoveTagHelperDirective.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (32:0,32 [2] RemoveTagHelperDirective.cshtml) + IntermediateToken - (32:0,32 [2] RemoveTagHelperDirective.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.mappings.txt new file mode 100644 index 0000000000..a607226eb2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (17:0,17 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective.cshtml) +|*, TestAssembly| +Generated Location: (550:12,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml new file mode 100644 index 0000000000..952461002f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml @@ -0,0 +1,17 @@ +@{ + Layout = "_SectionTestLayout.cshtml" +} + +
        This is in the Body> + +@section Section2 { +
        This is in Section 2
        +} + +@section Section1 { +
        This is in Section 1
        +} + +@section NestedDelegates { + @{ Func f = @@item; } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs new file mode 100644 index 0000000000..2817001c87 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.cs @@ -0,0 +1,100 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_DesignTime + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object Section2 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object Section1 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" +global::System.Object NestedDelegates = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml" + +#line default +#line hidden +#nullable disable + DefineSection("Section2", async(__razor_section_writer) => { +#nullable restore +#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + __o = thing; + +#line default +#line hidden +#nullable disable + } + ); + DefineSection("Section1", async(__razor_section_writer) => { + } + ); + DefineSection("NestedDelegates", async(__razor_section_writer) => { +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + Func f = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable + } + ) +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + ; + +#line default +#line hidden +#nullable disable + } + ); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.html new file mode 100644 index 0000000000..72ff37f26c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.codegen.html @@ -0,0 +1,17 @@ + + + + +
        This is in the Body> + + +
        This is in Section 2
        + + + +
        This is in Section 1
        + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt new file mode 100644 index 0000000000..13ef74e9ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -0,0 +1,62 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_DesignTime - - + DesignTimeDirective - + DirectiveToken - (89:6,9 [8] Sections.cshtml) - Section2 + DirectiveToken - (172:10,9 [8] Sections.cshtml) - Section1 + DirectiveToken - (235:14,9 [15] Sections.cshtml) - NestedDelegates + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [44] Sections.cshtml) + IntermediateToken - (2:0,2 [44] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml"\n + HtmlContent - (49:3,0 [31] Sections.cshtml) + IntermediateToken - (49:3,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (51:4,0 [4] Sections.cshtml) - Html -
        + IntermediateToken - (56:4,5 [24] Sections.cshtml) - Html - This is in the Body>\n\n + Section - - Section2 + HtmlContent - (99:6,19 [10] Sections.cshtml) + IntermediateToken - (99:6,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (105:7,4 [4] Sections.cshtml) - Html -
        + IntermediateToken - (130:7,29 [20] Sections.cshtml) - Html - This is in Section 2 + IntermediateToken - (150:7,49 [6] Sections.cshtml) - Html -
        + IntermediateToken - (156:7,55 [2] Sections.cshtml) - Html - \n + HtmlContent - (159:8,1 [4] Sections.cshtml) + IntermediateToken - (159:8,1 [4] Sections.cshtml) - Html - \n\n + Section - - Section1 + HtmlContent - (182:10,19 [39] Sections.cshtml) + IntermediateToken - (182:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (188:11,4 [4] Sections.cshtml) - Html -
        + IntermediateToken - (193:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (213:11,29 [6] Sections.cshtml) - Html -
        + IntermediateToken - (219:11,35 [2] Sections.cshtml) - Html - \n + HtmlContent - (222:12,1 [4] Sections.cshtml) + IntermediateToken - (222:12,1 [4] Sections.cshtml) - Html - \n\n + Section - - NestedDelegates + HtmlContent - (252:14,26 [6] Sections.cshtml) + IntermediateToken - (252:14,26 [6] Sections.cshtml) - Html - \n + CSharpCode - (260:15,6 [27] Sections.cshtml) + IntermediateToken - (260:15,6 [27] Sections.cshtml) - CSharp - Func f = + Template - (288:15,34 [17] Sections.cshtml) + HtmlContent - (288:15,34 [6] Sections.cshtml) + IntermediateToken - (288:15,34 [5] Sections.cshtml) - Html - + CSharpExpression - (295:15,41 [4] Sections.cshtml) + IntermediateToken - (295:15,41 [4] Sections.cshtml) - CSharp - item + HtmlContent - (299:15,45 [7] Sections.cshtml) + IntermediateToken - (299:15,45 [7] Sections.cshtml) - Html - + CSharpCode - (306:15,52 [2] Sections.cshtml) + IntermediateToken - (306:15,52 [2] Sections.cshtml) - CSharp - ; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt new file mode 100644 index 0000000000..863fba22d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.mappings.txt @@ -0,0 +1,44 @@ +Source Location: (89:6,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Section2| +Generated Location: (502:12,22 [8] ) +|Section2| + +Source Location: (172:10,9 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|Section1| +Generated Location: (757:22,22 [8] ) +|Section1| + +Source Location: (235:14,9 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|NestedDelegates| +Generated Location: (1012:32,22 [15] ) +|NestedDelegates| + +Source Location: (2:0,2 [44] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +| + Layout = "_SectionTestLayout.cshtml" +| +Generated Location: (1507:49,2 [44] ) +| + Layout = "_SectionTestLayout.cshtml" +| + +Source Location: (123:7,22 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|thing| +Generated Location: (1800:58,22 [5] ) +|thing| + +Source Location: (260:15,6 [27] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +| Func f = | +Generated Location: (2185:71,6 [27] ) +| Func f = | + +Source Location: (295:15,41 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|item| +Generated Location: (2483:79,41 [4] ) +|item| + +Source Location: (306:15,52 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml) +|; | +Generated Location: (2734:88,52 [2] ) +|; | + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs new file mode 100644 index 0000000000..f73b2141c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.codegen.cs @@ -0,0 +1,80 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2c1cd9bdf77c65fcccd7f5b86be5746c1381be0e" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"2c1cd9bdf77c65fcccd7f5b86be5746c1381be0e", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + + Layout = "_SectionTestLayout.cshtml" + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n
        This is in the Body>\r\n\r\n"); + DefineSection("Section2", async() => { + WriteLiteral("\r\n
        \r\n"); + } + ); + WriteLiteral("\r\n"); + DefineSection("Section1", async() => { + WriteLiteral("\r\n
        This is in Section 1
        \r\n"); + } + ); + WriteLiteral("\r\n"); + DefineSection("NestedDelegates", async() => { + WriteLiteral("\r\n"); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + Func f = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + WriteLiteral(""); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + Write(item); + +#line default +#line hidden +#nullable disable + WriteLiteral(""); + PopWriter(); + } + ) +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml" + ; + +#line default +#line hidden +#nullable disable + } + ); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt new file mode 100644 index 0000000000..94f5bec0b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_Runtime.ir.txt @@ -0,0 +1,56 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [44] Sections.cshtml) + IntermediateToken - (2:0,2 [44] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml"\n + HtmlContent - (49:3,0 [31] Sections.cshtml) + IntermediateToken - (49:3,0 [2] Sections.cshtml) - Html - \n + IntermediateToken - (51:4,0 [4] Sections.cshtml) - Html -
        + IntermediateToken - (56:4,5 [24] Sections.cshtml) - Html - This is in the Body>\n\n + Section - - Section2 + HtmlContent - (99:6,19 [10] Sections.cshtml) + IntermediateToken - (99:6,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (105:7,4 [4] Sections.cshtml) - Html -
        + IntermediateToken - (130:7,29 [20] Sections.cshtml) - Html - This is in Section 2 + IntermediateToken - (150:7,49 [6] Sections.cshtml) - Html -
        + IntermediateToken - (156:7,55 [2] Sections.cshtml) - Html - \n + HtmlContent - (161:9,0 [2] Sections.cshtml) + IntermediateToken - (161:9,0 [2] Sections.cshtml) - Html - \n + Section - - Section1 + HtmlContent - (182:10,19 [39] Sections.cshtml) + IntermediateToken - (182:10,19 [6] Sections.cshtml) - Html - \n + IntermediateToken - (188:11,4 [4] Sections.cshtml) - Html -
        + IntermediateToken - (193:11,9 [20] Sections.cshtml) - Html - This is in Section 1 + IntermediateToken - (213:11,29 [6] Sections.cshtml) - Html -
        + IntermediateToken - (219:11,35 [2] Sections.cshtml) - Html - \n + HtmlContent - (224:13,0 [2] Sections.cshtml) + IntermediateToken - (224:13,0 [2] Sections.cshtml) - Html - \n + Section - - NestedDelegates + HtmlContent - (252:14,26 [2] Sections.cshtml) + IntermediateToken - (252:14,26 [2] Sections.cshtml) - Html - \n + CSharpCode - (254:15,0 [4] Sections.cshtml) + IntermediateToken - (254:15,0 [4] Sections.cshtml) - CSharp - + CSharpCode - (260:15,6 [27] Sections.cshtml) + IntermediateToken - (260:15,6 [27] Sections.cshtml) - CSharp - Func f = + Template - (288:15,34 [17] Sections.cshtml) + HtmlContent - (288:15,34 [6] Sections.cshtml) + IntermediateToken - (288:15,34 [5] Sections.cshtml) - Html - + CSharpExpression - (295:15,41 [4] Sections.cshtml) + IntermediateToken - (295:15,41 [4] Sections.cshtml) - CSharp - item + HtmlContent - (299:15,45 [7] Sections.cshtml) + IntermediateToken - (299:15,45 [7] Sections.cshtml) - Html - + CSharpCode - (306:15,52 [2] Sections.cshtml) + IntermediateToken - (306:15,52 [2] Sections.cshtml) - CSharp - ; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml new file mode 100644 index 0000000000..bd4ce8107a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, TestAssembly +

        Hola

        +
        + +
        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.codegen.cs new file mode 100644 index 0000000000..87b3afd5e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_DesignTime + { + #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::InputTagHelper __InputTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __InputTagHelper = CreateTagHelper(); + __InputTagHelper.FooProp = "Hello"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt new file mode 100644 index 0000000000..061f7507f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] SimpleTagHelpers.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [27] SimpleTagHelpers.cshtml) + IntermediateToken - (29:0,29 [2] SimpleTagHelpers.cshtml) - Html - \n + IntermediateToken - (31:1,0 [2] SimpleTagHelpers.cshtml) - Html -

        + IntermediateToken - (34:1,3 [4] SimpleTagHelpers.cshtml) - Html - Hola + IntermediateToken - (38:1,7 [4] SimpleTagHelpers.cshtml) - Html -

        + IntermediateToken - (42:1,11 [2] SimpleTagHelpers.cshtml) - Html - \n + IntermediateToken - (44:2,0 [5] SimpleTagHelpers.cshtml) - Html -
        + IntermediateToken - (50:2,6 [6] SimpleTagHelpers.cshtml) - Html - \n + TagHelper - (56:3,4 [35] SimpleTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (70:3,18 [5] SimpleTagHelpers.cshtml) - value - string InputTagHelper.FooProp - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (70:3,18 [5] SimpleTagHelpers.cshtml) + IntermediateToken - (70:3,18 [5] SimpleTagHelpers.cshtml) - Html - Hello + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (83:3,31 [4] SimpleTagHelpers.cshtml) + IntermediateToken - (83:3,31 [4] SimpleTagHelpers.cshtml) - Html - text + DefaultTagHelperExecute - + HtmlContent - (91:3,39 [9] SimpleTagHelpers.cshtml) + IntermediateToken - (91:3,39 [2] SimpleTagHelpers.cshtml) - Html - \n + IntermediateToken - (93:4,0 [7] SimpleTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.mappings.txt new file mode 100644 index 0000000000..7e793d4e74 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml) +|*, TestAssembly| +Generated Location: (1000:18,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs new file mode 100644 index 0000000000..19acd28d61 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.codegen.cs @@ -0,0 +1,58 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e2cfd373c979f0844c2fd0ff78d289027202a932" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"e2cfd373c979f0844c2fd0ff78d289027202a932", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::InputTagHelper __InputTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("

        Hola

        \r\n
        \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.FooProp = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt new file mode 100644 index 0000000000..ac2e930b2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_Runtime.ir.txt @@ -0,0 +1,28 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_Runtime - - + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:1,0 [25] SimpleTagHelpers.cshtml) + IntermediateToken - (31:1,0 [2] SimpleTagHelpers.cshtml) - Html -

        + IntermediateToken - (34:1,3 [4] SimpleTagHelpers.cshtml) - Html - Hola + IntermediateToken - (38:1,7 [4] SimpleTagHelpers.cshtml) - Html -

        + IntermediateToken - (42:1,11 [2] SimpleTagHelpers.cshtml) - Html - \n + IntermediateToken - (44:2,0 [5] SimpleTagHelpers.cshtml) - Html -
        + IntermediateToken - (50:2,6 [6] SimpleTagHelpers.cshtml) - Html - \n + TagHelper - (56:3,4 [35] SimpleTagHelpers.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + PreallocatedTagHelperProperty - (70:3,18 [5] SimpleTagHelpers.cshtml) - __tagHelperAttribute_0 - value - FooProp + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (91:3,39 [9] SimpleTagHelpers.cshtml) + IntermediateToken - (91:3,39 [2] SimpleTagHelpers.cshtml) - Html - \n + IntermediateToken - (93:4,0 [7] SimpleTagHelpers.cshtml) - Html -
        diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml new file mode 100644 index 0000000000..27f2750eb2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml @@ -0,0 +1,4 @@ +@if (true) +{ +
        +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.codegen.cs new file mode 100644 index 0000000000..6f0947cdd6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.codegen.cs @@ -0,0 +1,39 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" + if (true) +{ + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.codegen.html new file mode 100644 index 0000000000..11a63ced54 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.codegen.html @@ -0,0 +1,4 @@ + + +
        + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt new file mode 100644 index 0000000000..597e0809e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (1:0,1 [15] SimpleUnspacedIf.cshtml) + IntermediateToken - (1:0,1 [15] SimpleUnspacedIf.cshtml) - CSharp - if (true)\n{\n + HtmlContent - (16:2,1 [11] SimpleUnspacedIf.cshtml) + IntermediateToken - (16:2,1 [4] SimpleUnspacedIf.cshtml) - Html -
        + IntermediateToken - (21:2,6 [6] SimpleUnspacedIf.cshtml) - Html -
        + CSharpCode - (27:2,12 [3] SimpleUnspacedIf.cshtml) + IntermediateToken - (27:2,12 [3] SimpleUnspacedIf.cshtml) - CSharp - \n} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.mappings.txt new file mode 100644 index 0000000000..b49f243de1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (1:0,1 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml) +|if (true) +{ + | +Generated Location: (751:19,1 [15] ) +|if (true) +{ + | + +Source Location: (27:2,12 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml) +| +}| +Generated Location: (944:28,15 [3] ) +| +}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs new file mode 100644 index 0000000000..d9a4109355 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.codegen.cs @@ -0,0 +1,34 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "57877348e222dad68a66bed082fa64c96f925772" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"57877348e222dad68a66bed082fa64c96f925772", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" + if (true) +{ + +#line default +#line hidden +#nullable disable + WriteLiteral("\t
        \r\n"); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt new file mode 100644 index 0000000000..ad4a325577 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_Runtime.ir.txt @@ -0,0 +1,16 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (1:0,1 [14] SimpleUnspacedIf.cshtml) + IntermediateToken - (1:0,1 [14] SimpleUnspacedIf.cshtml) - CSharp - if (true)\n{\n + HtmlContent - (15:2,0 [14] SimpleUnspacedIf.cshtml) + IntermediateToken - (15:2,0 [1] SimpleUnspacedIf.cshtml) - Html - + IntermediateToken - (16:2,1 [4] SimpleUnspacedIf.cshtml) - Html -
        + IntermediateToken - (21:2,6 [6] SimpleUnspacedIf.cshtml) - Html -
        + IntermediateToken - (27:2,12 [2] SimpleUnspacedIf.cshtml) - Html - \n + CSharpCode - (29:3,0 [1] SimpleUnspacedIf.cshtml) + IntermediateToken - (29:3,0 [1] SimpleUnspacedIf.cshtml) - CSharp - } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml new file mode 100644 index 0000000000..9d6ae22f9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml @@ -0,0 +1,102 @@ +

        Before Text

        + +@{ + if (DateTime.Now.ToBinary() % 2 == 0) @("Current time is divisible by 2") else @DateTime.Now + + object Bar() + { + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else if (DateTime.Now.ToBinary() % 3 == 0) + return "Current time is divisible by 3"; + else + return DateTime.Now; + } + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + @foreach (var item in new[] {"hello"}) + @item + + do + @currentCount + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + @reader.ReadToEnd() + + @lock (this) + currentCount++; +} + +@functions { + public string Foo() + { + var x = ""; + + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else + return "It isn't divisible by two"; + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + foreach (var item in new[] {"hello"}) + @item + + do + @currentCount + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + @reader.ReadToEnd() + + lock (this) + currentCount++; + } + + int currentCount = 0; + + public void IncrementCount() + { + if (true) currentCount++; + } + +} + +@for (var i = 0; i < 10; i++) + @i + +@foreach (var item in new[] {"hello"}) + @item + +@do + @currentCount +while (--currentCount >= 0); + +@while (--currentCount <= 10) + currentCount++; + +@using (var reader = new System.IO.StreamReader("/something")) + // Reading the entire file + @reader.ReadToEnd() + +@lock (this) + currentCount++; + +@if (true) @@GitHubUserName

        Hello!

        + +@if (true) + @:

        The time is @DateTime.Now

        + +

        After Text

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.cs new file mode 100644 index 0000000000..3ecf283882 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.cs @@ -0,0 +1,385 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + if (DateTime.Now.ToBinary() % 2 == 0) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = "Current time is divisible by 2"; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + else + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + object Bar() + { + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else if (DateTime.Now.ToBinary() % 3 == 0) + return "Current time is divisible by 3"; + else + return DateTime.Now; + } + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + foreach (var item in new[] {"hello"}) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + do + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = currentCount; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = reader.ReadToEnd(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + lock (this) + currentCount++; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 77 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + for (var i = 0; i < 10; i++) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 78 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +__o = i; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 78 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 80 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + foreach (var item in new[] {"hello"}) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 81 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +__o = item; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 81 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 83 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + do + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +__o = currentCount; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + +while (--currentCount >= 0); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 87 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + while (--currentCount <= 10) + currentCount++; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 90 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + using (var reader = new System.IO.StreamReader("/something")) + // Reading the entire file + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 92 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +__o = reader.ReadToEnd(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 92 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 94 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + lock (this) + currentCount++; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + if (true) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + @GitHubUserName + +#line default +#line hidden +#nullable disable +#nullable restore +#line 99 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + if (true) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 100 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 101 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + public string Foo() + { + var x = ""; + + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else + return "It isn't divisible by two"; + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + foreach (var item in new[] {"hello"}) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + do + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = currentCount; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + __o = reader.ReadToEnd(); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + lock (this) + currentCount++; + } + + int currentCount = 0; + + public void IncrementCount() + { + if (true) currentCount++; + } + + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.html new file mode 100644 index 0000000000..3d06dc8b90 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.codegen.html @@ -0,0 +1,102 @@ +

        Before Text

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

        Hello!

        + + +

        The time is

        + +

        After Text

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..1078a21cf6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(97,12): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(100,5): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.ir.txt new file mode 100644 index 0000000000..b277c3528a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.ir.txt @@ -0,0 +1,131 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [22] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (0:0,0 [2] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (3:0,3 [11] SingleLineControlFlowStatements.cshtml) - Html - Before Text + IntermediateToken - (14:0,14 [4] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (18:0,18 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (24:2,2 [44] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (24:2,2 [44] SingleLineControlFlowStatements.cshtml) - CSharp - \n if (DateTime.Now.ToBinary() % 2 == 0) + CSharpExpression - (70:3,44 [32] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (70:3,44 [32] SingleLineControlFlowStatements.cshtml) - CSharp - "Current time is divisible by 2" + CSharpCode - (103:3,77 [6] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (103:3,77 [6] SingleLineControlFlowStatements.cshtml) - CSharp - else + CSharpExpression - (110:3,84 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (110:3,84 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now + CSharpCode - (122:3,96 [381] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (122:3,96 [381] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n object Bar()\n {\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else if (DateTime.Now.ToBinary() % 3 == 0)\n return "Current time is divisible by 3";\n else\n return DateTime.Now;\n }\n\n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n + CSharpCode - (504:19,5 [47] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (504:19,5 [47] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n + CSharpExpression - (552:20,9 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (552:20,9 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item + CSharpCode - (556:20,13 [0] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (556:20,13 [0] SingleLineControlFlowStatements.cshtml) - CSharp - + CSharpCode - (556:20,13 [20] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (556:20,13 [20] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n + CSharpExpression - (577:23,9 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (577:23,9 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount + CSharpCode - (589:23,21 [174] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (589:23,21 [174] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n + CSharpExpression - (764:30,9 [18] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (764:30,9 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd() + CSharpCode - (782:30,27 [8] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (782:30,27 [8] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n + CSharpCode - (791:32,5 [36] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (791:32,5 [36] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++; + CSharpCode - (827:33,23 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (827:33,23 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n + HtmlContent - (832:35,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (832:35,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + HtmlContent - (1669:74,1 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1669:74,1 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml) - CSharp - for (var i = 0; i < 10; i++)\n + CSharpExpression - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml) - CSharp - i + CSharpCode - (1710:77,6 [0] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1710:77,6 [0] SingleLineControlFlowStatements.cshtml) - CSharp - + HtmlContent - (1710:77,6 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1710:77,6 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n + CSharpExpression - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item + CSharpCode - (1763:80,9 [0] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1763:80,9 [0] SingleLineControlFlowStatements.cshtml) - CSharp - + HtmlContent - (1763:80,9 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1763:80,9 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml) - CSharp - do\n + CSharpExpression - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount + CSharpCode - (1789:83,17 [30] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1789:83,17 [30] SingleLineControlFlowStatements.cshtml) - CSharp - \nwhile (--currentCount >= 0); + HtmlContent - (1819:84,28 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1819:84,28 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (1824:86,1 [49] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1824:86,1 [49] SingleLineControlFlowStatements.cshtml) - CSharp - while (--currentCount <= 10)\n currentCount++; + HtmlContent - (1873:87,19 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1873:87,19 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml) - CSharp - using (var reader = new System.IO.StreamReader("/something"))\n // Reading the entire file\n + CSharpExpression - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd() + CSharpCode - (1996:91,23 [0] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1996:91,23 [0] SingleLineControlFlowStatements.cshtml) - CSharp - + HtmlContent - (1996:91,23 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1996:91,23 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (2001:93,1 [32] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2001:93,1 [32] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++; + HtmlContent - (2033:94,19 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2033:94,19 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml) - CSharp - if (true) + CSharpCode - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml) - CSharp - @GitHubUserName + HtmlContent - (2065:96,28 [17] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2065:96,28 [2] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (2068:96,31 [6] SingleLineControlFlowStatements.cshtml) - Html - Hello! + IntermediateToken - (2074:96,37 [4] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (2078:96,41 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml) - CSharp - if (true) \n + HtmlContent - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml) - Html -

        The time is + CSharpExpression - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now + HtmlContent - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml) - Html -

        \n + CSharpCode - (2136:100,0 [0] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2136:100,0 [0] SingleLineControlFlowStatements.cshtml) - CSharp - + HtmlContent - (2136:100,0 [19] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2136:100,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + IntermediateToken - (2138:101,0 [2] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (2141:101,3 [10] SingleLineControlFlowStatements.cshtml) - Html - After Text + IntermediateToken - (2151:101,13 [4] SingleLineControlFlowStatements.cshtml) - Html -

        + CSharpCode - (846:36,12 [386] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (846:36,12 [386] SingleLineControlFlowStatements.cshtml) - CSharp - \n public string Foo()\n {\n var x = "";\n\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else\n return "It isn't divisible by two";\n \n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n foreach (var item in new[] {"hello"})\n + CSharpExpression - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item + CSharpCode - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n + CSharpExpression - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount + CSharpCode - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n + CSharpExpression - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd() + CSharpCode - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n lock (this)\n currentCount++;\n }\n\n int currentCount = 0;\n\n public void IncrementCount()\n {\n if (true) currentCount++;\n }\n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.mappings.txt new file mode 100644 index 0000000000..046e1006f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_DesignTime.mappings.txt @@ -0,0 +1,363 @@ +Source Location: (24:2,2 [44] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + if (DateTime.Now.ToBinary() % 2 == 0) | +Generated Location: (782:19,2 [44] ) +| + if (DateTime.Now.ToBinary() % 2 == 0) | + +Source Location: (70:3,44 [32] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|"Current time is divisible by 2"| +Generated Location: (1048:27,44 [32] ) +|"Current time is divisible by 2"| + +Source Location: (103:3,77 [6] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| else | +Generated Location: (1336:34,77 [6] ) +| else | + +Source Location: (110:3,84 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|DateTime.Now| +Generated Location: (1604:41,84 [12] ) +|DateTime.Now| + +Source Location: (122:3,96 [381] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + + object Bar() + { + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else if (DateTime.Now.ToBinary() % 3 == 0) + return "Current time is divisible by 3"; + else + return DateTime.Now; + } + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + | +Generated Location: (1891:48,96 [381] ) +| + + object Bar() + { + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else if (DateTime.Now.ToBinary() % 3 == 0) + return "Current time is divisible by 3"; + else + return DateTime.Now; + } + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + | + +Source Location: (504:19,5 [47] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|foreach (var item in new[] {"hello"}) + | +Generated Location: (2456:71,5 [47] ) +|foreach (var item in new[] {"hello"}) + | + +Source Location: (552:20,9 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|item| +Generated Location: (2691:79,9 [4] ) +|item| + +Source Location: (556:20,13 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|| +Generated Location: (2888:86,13 [0] ) +|| + +Source Location: (556:20,13 [20] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + + do + | +Generated Location: (3080:93,13 [20] ) +| + + do + | + +Source Location: (577:23,9 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|currentCount| +Generated Location: (3288:103,9 [12] ) +|currentCount| + +Source Location: (589:23,21 [174] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + | +Generated Location: (3501:110,21 [174] ) +| + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + | + +Source Location: (764:30,9 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|reader.ReadToEnd()| +Generated Location: (3863:124,9 [18] ) +|reader.ReadToEnd()| + +Source Location: (782:30,27 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + + | +Generated Location: (4088:131,27 [8] ) +| + + | + +Source Location: (791:32,5 [36] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|lock (this) + currentCount++;| +Generated Location: (4280:140,5 [36] ) +|lock (this) + currentCount++;| + +Source Location: (827:33,23 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| +| +Generated Location: (4518:148,23 [2] ) +| +| + +Source Location: (1674:76,1 [34] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|for (var i = 0; i < 10; i++) + | +Generated Location: (4698:155,1 [34] ) +|for (var i = 0; i < 10; i++) + | + +Source Location: (1709:77,5 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|i| +Generated Location: (4917:163,6 [1] ) +|i| + +Source Location: (1710:77,6 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|| +Generated Location: (5104:170,6 [0] ) +|| + +Source Location: (1715:79,1 [43] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|foreach (var item in new[] {"hello"}) + | +Generated Location: (5284:177,1 [43] ) +|foreach (var item in new[] {"hello"}) + | + +Source Location: (1759:80,5 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|item| +Generated Location: (5512:185,6 [4] ) +|item| + +Source Location: (1763:80,9 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|| +Generated Location: (5705:192,9 [0] ) +|| + +Source Location: (1768:82,1 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|do + | +Generated Location: (5885:199,1 [8] ) +|do + | + +Source Location: (1777:83,5 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|currentCount| +Generated Location: (6078:207,6 [12] ) +|currentCount| + +Source Location: (1789:83,17 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| +while (--currentCount >= 0);| +Generated Location: (6287:214,17 [30] ) +| +while (--currentCount >= 0);| + +Source Location: (1824:86,1 [49] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|while (--currentCount <= 10) + currentCount++;| +Generated Location: (6497:222,1 [49] ) +|while (--currentCount <= 10) + currentCount++;| + +Source Location: (1878:89,1 [99] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|using (var reader = new System.IO.StreamReader("/something")) + // Reading the entire file + | +Generated Location: (6726:230,1 [99] ) +|using (var reader = new System.IO.StreamReader("/something")) + // Reading the entire file + | + +Source Location: (1978:91,5 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|reader.ReadToEnd()| +Generated Location: (7010:239,6 [18] ) +|reader.ReadToEnd()| + +Source Location: (1996:91,23 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|| +Generated Location: (7231:246,23 [0] ) +|| + +Source Location: (2001:93,1 [32] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|lock (this) + currentCount++;| +Generated Location: (7411:253,1 [32] ) +|lock (this) + currentCount++;| + +Source Location: (2038:96,1 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|if (true) | +Generated Location: (7623:261,1 [10] ) +|if (true) | + +Source Location: (2049:96,12 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|@GitHubUserName | +Generated Location: (7824:268,12 [16] ) +|@GitHubUserName | + +Source Location: (2083:98,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|if (true) + | +Generated Location: (8020:275,1 [16] ) +|if (true) + | + +Source Location: (2118:99,23 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|DateTime.Now| +Generated Location: (8239:283,23 [12] ) +|DateTime.Now| + +Source Location: (2136:100,0 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|| +Generated Location: (8432:290,0 [0] ) +|| + +Source Location: (846:36,12 [386] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + public string Foo() + { + var x = ""; + + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else + return "It isn't divisible by two"; + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + foreach (var item in new[] {"hello"}) + | +Generated Location: (8670:298,12 [386] ) +| + public string Foo() + { + var x = ""; + + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else + return "It isn't divisible by two"; + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + foreach (var item in new[] {"hello"}) + | + +Source Location: (1233:51,13 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|item| +Generated Location: (9248:320,13 [4] ) +|item| + +Source Location: (1237:51,17 [28] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + + do + | +Generated Location: (9449:327,17 [28] ) +| + + do + | + +Source Location: (1266:54,13 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|currentCount| +Generated Location: (9669:337,13 [12] ) +|currentCount| + +Source Location: (1278:54,25 [194] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + | +Generated Location: (9886:344,25 [194] ) +| + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + | + +Source Location: (1473:61,13 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +|reader.ReadToEnd()| +Generated Location: (10272:358,13 [18] ) +|reader.ReadToEnd()| + +Source Location: (1491:61,31 [177] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml) +| + + lock (this) + currentCount++; + } + + int currentCount = 0; + + public void IncrementCount() + { + if (true) currentCount++; + } + +| +Generated Location: (10501:365,31 [177] ) +| + + lock (this) + currentCount++; + } + + int currentCount = 0; + + public void IncrementCount() + { + if (true) currentCount++; + } + +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs new file mode 100644 index 0000000000..8f808b9826 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.codegen.cs @@ -0,0 +1,344 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a057512a2be3416c0f48286af45a4e9855e06f55" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a057512a2be3416c0f48286af45a4e9855e06f55", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("

        Before Text

        \r\n\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + if (DateTime.Now.ToBinary() % 2 == 0) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write("Current time is divisible by 2"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + else + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(DateTime.Now); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + object Bar() + { + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else if (DateTime.Now.ToBinary() % 3 == 0) + return "Current time is divisible by 3"; + else + return DateTime.Now; + } + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 20 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + foreach (var item in new[] {"hello"}) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(item); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + do + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(currentCount); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 24 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 31 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(reader.ReadToEnd()); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + lock (this) + currentCount++; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); +#nullable restore +#line 77 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + for (var i = 0; i < 10; i++) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 78 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +Write(i); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 80 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + foreach (var item in new[] {"hello"}) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 81 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +Write(item); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 83 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + do + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +Write(currentCount); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 84 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + +while (--currentCount >= 0); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 87 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + while (--currentCount <= 10) + currentCount++; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 90 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + using (var reader = new System.IO.StreamReader("/something")) + // Reading the entire file + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 92 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" +Write(reader.ReadToEnd()); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 94 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + lock (this) + currentCount++; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + if (true) + +#line default +#line hidden +#nullable disable +#nullable restore +#line 97 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + @GitHubUserName + +#line default +#line hidden +#nullable disable + WriteLiteral("

        Hello!

        \r\n\r\n"); +#nullable restore +#line 99 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + if (true) + + +#line default +#line hidden +#nullable disable + WriteLiteral("

        The time is "); +#nullable restore +#line 100 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(DateTime.Now); + +#line default +#line hidden +#nullable disable + WriteLiteral("

        \r\n"); + WriteLiteral("

        After Text

        "); + } + #pragma warning restore 1998 +#nullable restore +#line 37 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + public string Foo() + { + var x = ""; + + if (DateTime.Now.ToBinary() % 2 == 0) + return "Current time is divisible by 2"; + else + return "It isn't divisible by two"; + + for (var i = 0; i < 10; i++) + // Incrementing a number + i--; + + foreach (var item in new[] {"hello"}) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(item); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 52 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + do + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(currentCount); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 55 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + while (--currentCount >= 0); + + while (--currentCount <= 10) + currentCount++; + + using (var reader = new System.IO.StreamReader("/something")) + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + Write(reader.ReadToEnd()); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 62 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml" + + + lock (this) + currentCount++; + } + + int currentCount = 0; + + public void IncrementCount() + { + if (true) currentCount++; + } + + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.diagnostics.txt new file mode 100644 index 0000000000..1078a21cf6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.diagnostics.txt @@ -0,0 +1,2 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(97,12): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements.cshtml(100,5): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.ir.txt new file mode 100644 index 0000000000..0447aaa746 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleLineControlFlowStatements_Runtime.ir.txt @@ -0,0 +1,125 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleLineControlFlowStatements_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [22] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (0:0,0 [2] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (3:0,3 [11] SingleLineControlFlowStatements.cshtml) - Html - Before Text + IntermediateToken - (14:0,14 [4] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (18:0,18 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (24:2,2 [44] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (24:2,2 [44] SingleLineControlFlowStatements.cshtml) - CSharp - \n if (DateTime.Now.ToBinary() % 2 == 0) + CSharpExpression - (70:3,44 [32] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (70:3,44 [32] SingleLineControlFlowStatements.cshtml) - CSharp - "Current time is divisible by 2" + CSharpCode - (103:3,77 [6] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (103:3,77 [6] SingleLineControlFlowStatements.cshtml) - CSharp - else + CSharpExpression - (110:3,84 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (110:3,84 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now + CSharpCode - (122:3,96 [381] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (122:3,96 [381] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n object Bar()\n {\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else if (DateTime.Now.ToBinary() % 3 == 0)\n return "Current time is divisible by 3";\n else\n return DateTime.Now;\n }\n\n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n + CSharpCode - (504:19,5 [47] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (504:19,5 [47] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n + CSharpExpression - (552:20,9 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (552:20,9 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item + CSharpCode - (556:20,13 [0] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (556:20,13 [0] SingleLineControlFlowStatements.cshtml) - CSharp - + CSharpCode - (556:20,13 [20] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (556:20,13 [20] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n + CSharpExpression - (577:23,9 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (577:23,9 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount + CSharpCode - (589:23,21 [174] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (589:23,21 [174] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n + CSharpExpression - (764:30,9 [18] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (764:30,9 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd() + CSharpCode - (782:30,27 [8] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (782:30,27 [8] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n + CSharpCode - (791:32,5 [36] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (791:32,5 [36] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++; + CSharpCode - (827:33,23 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (827:33,23 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n + HtmlContent - (832:35,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (832:35,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + HtmlContent - (1671:75,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1671:75,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1674:76,1 [34] SingleLineControlFlowStatements.cshtml) - CSharp - for (var i = 0; i < 10; i++)\n + CSharpExpression - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1709:77,5 [1] SingleLineControlFlowStatements.cshtml) - CSharp - i + CSharpCode - (1710:77,6 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1710:77,6 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n + HtmlContent - (1712:78,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1712:78,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1715:79,1 [43] SingleLineControlFlowStatements.cshtml) - CSharp - foreach (var item in new[] {"hello"})\n + CSharpExpression - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1759:80,5 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item + CSharpCode - (1763:80,9 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1763:80,9 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n + HtmlContent - (1765:81,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1765:81,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1768:82,1 [8] SingleLineControlFlowStatements.cshtml) - CSharp - do\n + CSharpExpression - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1777:83,5 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount + CSharpCode - (1789:83,17 [32] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1789:83,17 [32] SingleLineControlFlowStatements.cshtml) - CSharp - \nwhile (--currentCount >= 0);\n + HtmlContent - (1821:85,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1821:85,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (1824:86,1 [51] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1824:86,1 [51] SingleLineControlFlowStatements.cshtml) - CSharp - while (--currentCount <= 10)\n currentCount++;\n + HtmlContent - (1875:88,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1875:88,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1878:89,1 [99] SingleLineControlFlowStatements.cshtml) - CSharp - using (var reader = new System.IO.StreamReader("/something"))\n // Reading the entire file\n + CSharpExpression - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1978:91,5 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd() + CSharpCode - (1996:91,23 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1996:91,23 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n + HtmlContent - (1998:92,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1998:92,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (2001:93,1 [34] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2001:93,1 [34] SingleLineControlFlowStatements.cshtml) - CSharp - lock (this)\n currentCount++;\n + HtmlContent - (2035:95,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2035:95,0 [2] SingleLineControlFlowStatements.cshtml) - Html - \n + CSharpCode - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2038:96,1 [10] SingleLineControlFlowStatements.cshtml) - CSharp - if (true) + CSharpCode - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2049:96,12 [16] SingleLineControlFlowStatements.cshtml) - CSharp - @GitHubUserName + HtmlContent - (2065:96,28 [17] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2065:96,28 [2] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (2068:96,31 [6] SingleLineControlFlowStatements.cshtml) - Html - Hello! + IntermediateToken - (2074:96,37 [4] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (2078:96,41 [4] SingleLineControlFlowStatements.cshtml) - Html - \n\n + CSharpCode - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2083:98,1 [16] SingleLineControlFlowStatements.cshtml) - CSharp - if (true) \n + HtmlContent - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2101:99,6 [16] SingleLineControlFlowStatements.cshtml) - Html -

        The time is + CSharpExpression - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2118:99,23 [12] SingleLineControlFlowStatements.cshtml) - CSharp - DateTime.Now + HtmlContent - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2130:99,35 [6] SingleLineControlFlowStatements.cshtml) - Html -

        \n + CSharpCode - (2136:100,0 [2] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2136:100,0 [2] SingleLineControlFlowStatements.cshtml) - CSharp - \n + HtmlContent - (2138:101,0 [17] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (2138:101,0 [2] SingleLineControlFlowStatements.cshtml) - Html -

        + IntermediateToken - (2141:101,3 [10] SingleLineControlFlowStatements.cshtml) - Html - After Text + IntermediateToken - (2151:101,13 [4] SingleLineControlFlowStatements.cshtml) - Html -

        + CSharpCode - (846:36,12 [386] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (846:36,12 [386] SingleLineControlFlowStatements.cshtml) - CSharp - \n public string Foo()\n {\n var x = "";\n\n if (DateTime.Now.ToBinary() % 2 == 0)\n return "Current time is divisible by 2";\n else\n return "It isn't divisible by two";\n \n for (var i = 0; i < 10; i++)\n // Incrementing a number\n i--;\n\n foreach (var item in new[] {"hello"})\n + CSharpExpression - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1233:51,13 [4] SingleLineControlFlowStatements.cshtml) - CSharp - item + CSharpCode - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1237:51,17 [28] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n do\n + CSharpExpression - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1266:54,13 [12] SingleLineControlFlowStatements.cshtml) - CSharp - currentCount + CSharpCode - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1278:54,25 [194] SingleLineControlFlowStatements.cshtml) - CSharp - \n while (--currentCount >= 0);\n\n while (--currentCount <= 10)\n currentCount++;\n\n using (var reader = new System.IO.StreamReader("/something"))\n + CSharpExpression - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1473:61,13 [18] SingleLineControlFlowStatements.cshtml) - CSharp - reader.ReadToEnd() + CSharpCode - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml) + IntermediateToken - (1491:61,31 [177] SingleLineControlFlowStatements.cshtml) - CSharp - \n\n lock (this)\n currentCount++;\n }\n\n int currentCount = 0;\n\n public void IncrementCount()\n {\n if (true) currentCount++;\n }\n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml new file mode 100644 index 0000000000..6e12a5f3bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml @@ -0,0 +1,3 @@ +@addTagHelper "*, TestAssembly" + +

        Body of Tag

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml new file mode 100644 index 0000000000..b5c2eddf1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml @@ -0,0 +1,4 @@ +@addTagHelper "*, TestAssembly" + +

        Body of Tag

        \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.codegen.cs new file mode 100644 index 0000000000..2262179514 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.codegen.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml" +__TestNamespace_PTagHelper.Age = 1337; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt new file mode 100644 index 0000000000..caa51dd43d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt @@ -0,0 +1,27 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] SingleTagHelperWithNewlineBeforeAttributes.cshtml) + IntermediateToken - (31:0,31 [4] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - Html - \n\n + TagHelper - (35:2,0 [53] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (73:3,34 [11] SingleTagHelperWithNewlineBeforeAttributes.cshtml) + IntermediateToken - (73:3,34 [11] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - Html - Body of Tag + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (49:3,10 [11] SingleTagHelperWithNewlineBeforeAttributes.cshtml) + IntermediateToken - (49:3,10 [11] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - Html - Hello World + DefaultTagHelperProperty - (67:3,28 [4] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (67:3,28 [4] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - CSharp - 1337 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.mappings.txt new file mode 100644 index 0000000000..18be9514bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml) +|"*, TestAssembly"| +Generated Location: (1071:18,37 [17] ) +|"*, TestAssembly"| + +Source Location: (67:3,28 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml) +|1337| +Generated Location: (1720:36,33 [4] ) +|1337| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..90685cd489 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.codegen.cs @@ -0,0 +1,63 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "00f665efb7bd154c43f2bd30d287b9ed9fa2ffdd" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"00f665efb7bd154c43f2bd30d287b9ed9fa2ffdd", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Body of Tag"); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes.cshtml" +__TestNamespace_PTagHelper.Age = 1337; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt new file mode 100644 index 0000000000..fb67e469d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_Runtime.ir.txt @@ -0,0 +1,20 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] SingleTagHelperWithNewlineBeforeAttributes.cshtml) + IntermediateToken - (33:1,0 [2] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - Html - \n + TagHelper - (35:2,0 [53] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (73:3,34 [11] SingleTagHelperWithNewlineBeforeAttributes.cshtml) + IntermediateToken - (73:3,34 [11] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - Html - Body of Tag + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperProperty - (67:3,28 [4] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (67:3,28 [4] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - CSharp - 1337 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.codegen.cs new file mode 100644 index 0000000000..730bac6f29 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.codegen.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml" +__TestNamespace_PTagHelper.Age = 1337; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt new file mode 100644 index 0000000000..4749a67bfd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt @@ -0,0 +1,27 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] SingleTagHelper.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] SingleTagHelper.cshtml) + IntermediateToken - (31:0,31 [4] SingleTagHelper.cshtml) - Html - \n\n + TagHelper - (35:2,0 [49] SingleTagHelper.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (69:2,34 [11] SingleTagHelper.cshtml) + IntermediateToken - (69:2,34 [11] SingleTagHelper.cshtml) - Html - Body of Tag + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (45:2,10 [11] SingleTagHelper.cshtml) + IntermediateToken - (45:2,10 [11] SingleTagHelper.cshtml) - Html - Hello World + DefaultTagHelperProperty - (63:2,28 [4] SingleTagHelper.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (63:2,28 [4] SingleTagHelper.cshtml) - CSharp - 1337 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.mappings.txt new file mode 100644 index 0000000000..5d033dece6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml) +|"*, TestAssembly"| +Generated Location: (1017:18,37 [17] ) +|"*, TestAssembly"| + +Source Location: (63:2,28 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml) +|1337| +Generated Location: (1639:36,33 [4] ) +|1337| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs new file mode 100644 index 0000000000..f72f804484 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.codegen.cs @@ -0,0 +1,63 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8cdee08b4e2681f8524ae09a405f163fd96d1ed8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"8cdee08b4e2681f8524ae09a405f163fd96d1ed8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Body of Tag"); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper.cshtml" +__TestNamespace_PTagHelper.Age = 1337; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt new file mode 100644 index 0000000000..89ef050a2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_Runtime.ir.txt @@ -0,0 +1,20 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] SingleTagHelper.cshtml) + IntermediateToken - (33:1,0 [2] SingleTagHelper.cshtml) - Html - \n + TagHelper - (35:2,0 [49] SingleTagHelper.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (69:2,34 [11] SingleTagHelper.cshtml) + IntermediateToken - (69:2,34 [11] SingleTagHelper.cshtml) - Html - Body of Tag + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperProperty - (63:2,28 [4] SingleTagHelper.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (63:2,28 [4] SingleTagHelper.cshtml) - CSharp - 1337 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml new file mode 100644 index 0000000000..19d498abfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml @@ -0,0 +1,237 @@ +

        This is line 1

        +

        This is line 2

        +

        This is line 3

        +

        This is line 4

        +

        This is line 5

        +

        This is line 6

        +

        This is line 7

        +

        This is line 8

        +

        This is line 9

        +

        This is line 10

        +

        This is line 11

        +

        This is line 12

        +

        This is line 13

        +

        This is line 14

        +

        This is line 15

        +

        This is line 16

        +

        This is line 17

        +

        This is line 18

        +

        This is line 19

        +

        This is line 20

        +

        This is line 21

        +

        This is line 22

        +

        This is line 23

        +

        This is line 24

        +

        This is line 25

        +

        This is line 26

        +

        This is line 27

        +

        This is line 28

        +

        This is line 29

        +

        This is line 30

        +

        This is line 31

        +

        This is line 32

        +

        This is line 33

        +

        This is line 34

        +

        This is line 35

        +

        This is line 36

        +

        This is line 37

        +

        This is line 38

        +

        This is line 39

        +

        This is line 40

        +

        This is line 41

        +

        This is line 42

        +

        This is line 43

        +

        This is line 44

        +

        This is line 45

        +

        This is line 46

        +

        This is line 47

        +

        This is line 48

        +

        This is line 49

        +

        This is line 50

        +

        This is line 51

        +

        This is line 52

        +

        This is line 53

        +

        This is line 54

        +

        This is line 55

        +

        This is line 56

        +

        This is line 57

        +

        This is line 58

        +

        This is line 59

        +

        This is line 60

        +

        This is line 61

        +

        This is line 62

        +

        This is line 63

        +

        This is line 64

        +

        This is line 65

        +

        This is line 66

        +

        This is line 67

        +

        This is line 68

        +

        This is line 69

        +

        This is line 70

        +

        This is line 71

        +

        This is line 72

        +

        This is line 73

        +

        This is line 74

        +

        This is line 75

        +

        This is line 76

        +

        This is line 77

        +

        This is line 78

        +

        This is line 79

        +

        This is line 80

        +

        This is line 81

        +

        This is line 82

        +

        This is line 83

        +

        This is line 84


        + +@section WriteLiteralsToInHere { +

        This is line 1 nested

        +

        This is line 2 nested

        +

        This is line 3 nested

        +

        This is line 4 nested

        +

        This is line 5 nested

        +

        This is line 6 nested

        +

        This is line 7 nested

        +

        This is line 8 nested

        +

        This is line 9 nested

        +

        This is line 10 nested

        +

        This is line 11 nested

        +

        This is line 12 nested

        +

        This is line 13 nested

        +

        This is line 14 nested

        +

        This is line 15 nested

        +

        This is line 16 nested

        +

        This is line 17 nested

        +

        This is line 18 nested

        +

        This is line 19 nested

        +

        This is line 20 nested

        +

        This is line 21 nested

        +

        This is line 22 nested

        +

        This is line 23 nested

        +

        This is line 24 nested

        +

        This is line 25 nested

        +

        This is line 26 nested

        +

        This is line 27 nested

        +

        This is line 28 nested

        +

        This is line 29 nested

        +

        This is line 30 nested

        +

        This is line 31 nested

        +

        This is line 32 nested

        +

        This is line 33 nested

        +

        This is line 34 nested

        +

        This is line 35 nested

        +

        This is line 36 nested

        +

        This is line 37 nested

        +

        This is line 38 nested

        +

        This is line 39 nested

        +

        This is line 40 nested

        +

        This is line 41 nested

        +

        This is line 42 nested

        +

        This is line 43 nested

        +

        This is line 44 nested

        +

        This is line 45 nested

        +

        This is line 46 nested

        +

        This is line 47 nested

        +

        This is line 48 nested

        +

        This is line 49 nested

        +

        This is line 50 nested

        +

        This is line 51 nested

        +

        This is line 52 nested

        +

        This is line 53 nested

        +

        This is line 54 nested

        +

        This is line 55 nested

        +

        This is line 56 nested

        +

        This is line 57 nested

        +

        This is line 58 nested

        +

        This is line 59 nested

        +

        This is line 60 nested

        +

        This is line 61 nested

        +

        This is line 62 nested

        +

        This is line 63 nested

        +

        This is line 64 nested

        +

        This is line 65 nested

        +

        This is line 66 nested

        +

        This is line 67 nested

        +

        This is line 68 nested

        +

        This is line 69 nested

        +

        This is line 70 nested

        +

        This is line 71 nested

        +

        This is line 72 nested

        +

        This is line 73 nested

        +

        This is line 74 nested

        +

        This is line 75 nested

        +} +

        This is line 1

        +

        This is line 2

        +

        This is line 3

        +

        This is line 4

        +

        This is line 5

        +

        This is line 6

        +

        This is line 7

        +

        This is line 8

        +

        This is line 9

        +

        This is line 10

        +

        This is line 11

        +

        This is line 12

        +

        This is line 13

        +

        This is line 14

        +

        This is line 15

        +

        This is line 16

        +

        This is line 17

        +

        This is line 18

        +

        This is line 19

        +

        This is line 20

        +

        This is line 21

        +

        This is line 22

        +

        This is line 23

        +

        This is line 24

        +

        This is line 25

        +

        This is line 26

        +

        This is line 27

        +

        This is line 28

        +

        This is line 29

        +

        This is line 30

        +

        This is line 31

        +

        This is line 32

        +

        This is line 33

        +

        This is line 34

        +

        This is line 35

        +

        This is line 36

        +

        This is line 37

        +

        This is line 38

        +

        This is line 39

        +

        This is line 40

        +

        This is line 41

        +

        This is line 42

        +

        This is line 43

        hi! +@section WriteLiteralsToInHereAlso { +

        This is line 1 nested

        +

        This is line 2 nested

        +

        This is line 3 nested

        +

        This is line 4 nested

        +

        This is line 5 nested

        +

        This is line 6 nested

        +

        This is line 7 nested

        +

        This is line 8 nested

        +

        This is line 9 nested

        +

        This is line 10 nested

        +

        This is line 11 nested

        +

        This is line 12 nested

        +

        This is line 13 nested

        +

        This is line 14 nested

        +

        This is line 15 nested

        +

        This is line 16 nested

        +

        This is line 17 nested

        +

        This is line 18 nested

        +

        This is line 19 nested

        +

        This is line 20 nested

        +

        This is line 21 nested

        +

        This is line 22 nested

        +

        This is line 23 nested

        +

        This is line 24 nested

        +

        This is line 25 nested

        +

        This is line 26 nested

        +

        This is line 27 nested

        +

        This is line 28 nested

        +

        This is line 29 nested

        +

        30

        +}! \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.codegen.cs new file mode 100644 index 0000000000..d3da7cc7e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_DesignTime + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 86 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml" +global::System.Object WriteLiteralsToInHere = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 206 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml" +global::System.Object WriteLiteralsToInHereAlso = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + DefineSection("WriteLiteralsToInHere", async(__razor_section_writer) => { + } + ); + DefineSection("WriteLiteralsToInHereAlso", async(__razor_section_writer) => { + } + ); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.codegen.html new file mode 100644 index 0000000000..b47c6a931c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.codegen.html @@ -0,0 +1,237 @@ +

        This is line 1

        +

        This is line 2

        +

        This is line 3

        +

        This is line 4

        +

        This is line 5

        +

        This is line 6

        +

        This is line 7

        +

        This is line 8

        +

        This is line 9

        +

        This is line 10

        +

        This is line 11

        +

        This is line 12

        +

        This is line 13

        +

        This is line 14

        +

        This is line 15

        +

        This is line 16

        +

        This is line 17

        +

        This is line 18

        +

        This is line 19

        +

        This is line 20

        +

        This is line 21

        +

        This is line 22

        +

        This is line 23

        +

        This is line 24

        +

        This is line 25

        +

        This is line 26

        +

        This is line 27

        +

        This is line 28

        +

        This is line 29

        +

        This is line 30

        +

        This is line 31

        +

        This is line 32

        +

        This is line 33

        +

        This is line 34

        +

        This is line 35

        +

        This is line 36

        +

        This is line 37

        +

        This is line 38

        +

        This is line 39

        +

        This is line 40

        +

        This is line 41

        +

        This is line 42

        +

        This is line 43

        +

        This is line 44

        +

        This is line 45

        +

        This is line 46

        +

        This is line 47

        +

        This is line 48

        +

        This is line 49

        +

        This is line 50

        +

        This is line 51

        +

        This is line 52

        +

        This is line 53

        +

        This is line 54

        +

        This is line 55

        +

        This is line 56

        +

        This is line 57

        +

        This is line 58

        +

        This is line 59

        +

        This is line 60

        +

        This is line 61

        +

        This is line 62

        +

        This is line 63

        +

        This is line 64

        +

        This is line 65

        +

        This is line 66

        +

        This is line 67

        +

        This is line 68

        +

        This is line 69

        +

        This is line 70

        +

        This is line 71

        +

        This is line 72

        +

        This is line 73

        +

        This is line 74

        +

        This is line 75

        +

        This is line 76

        +

        This is line 77

        +

        This is line 78

        +

        This is line 79

        +

        This is line 80

        +

        This is line 81

        +

        This is line 82

        +

        This is line 83

        +

        This is line 84


        + + +

        This is line 1 nested

        +

        This is line 2 nested

        +

        This is line 3 nested

        +

        This is line 4 nested

        +

        This is line 5 nested

        +

        This is line 6 nested

        +

        This is line 7 nested

        +

        This is line 8 nested

        +

        This is line 9 nested

        +

        This is line 10 nested

        +

        This is line 11 nested

        +

        This is line 12 nested

        +

        This is line 13 nested

        +

        This is line 14 nested

        +

        This is line 15 nested

        +

        This is line 16 nested

        +

        This is line 17 nested

        +

        This is line 18 nested

        +

        This is line 19 nested

        +

        This is line 20 nested

        +

        This is line 21 nested

        +

        This is line 22 nested

        +

        This is line 23 nested

        +

        This is line 24 nested

        +

        This is line 25 nested

        +

        This is line 26 nested

        +

        This is line 27 nested

        +

        This is line 28 nested

        +

        This is line 29 nested

        +

        This is line 30 nested

        +

        This is line 31 nested

        +

        This is line 32 nested

        +

        This is line 33 nested

        +

        This is line 34 nested

        +

        This is line 35 nested

        +

        This is line 36 nested

        +

        This is line 37 nested

        +

        This is line 38 nested

        +

        This is line 39 nested

        +

        This is line 40 nested

        +

        This is line 41 nested

        +

        This is line 42 nested

        +

        This is line 43 nested

        +

        This is line 44 nested

        +

        This is line 45 nested

        +

        This is line 46 nested

        +

        This is line 47 nested

        +

        This is line 48 nested

        +

        This is line 49 nested

        +

        This is line 50 nested

        +

        This is line 51 nested

        +

        This is line 52 nested

        +

        This is line 53 nested

        +

        This is line 54 nested

        +

        This is line 55 nested

        +

        This is line 56 nested

        +

        This is line 57 nested

        +

        This is line 58 nested

        +

        This is line 59 nested

        +

        This is line 60 nested

        +

        This is line 61 nested

        +

        This is line 62 nested

        +

        This is line 63 nested

        +

        This is line 64 nested

        +

        This is line 65 nested

        +

        This is line 66 nested

        +

        This is line 67 nested

        +

        This is line 68 nested

        +

        This is line 69 nested

        +

        This is line 70 nested

        +

        This is line 71 nested

        +

        This is line 72 nested

        +

        This is line 73 nested

        +

        This is line 74 nested

        +

        This is line 75 nested

        + +

        This is line 1

        +

        This is line 2

        +

        This is line 3

        +

        This is line 4

        +

        This is line 5

        +

        This is line 6

        +

        This is line 7

        +

        This is line 8

        +

        This is line 9

        +

        This is line 10

        +

        This is line 11

        +

        This is line 12

        +

        This is line 13

        +

        This is line 14

        +

        This is line 15

        +

        This is line 16

        +

        This is line 17

        +

        This is line 18

        +

        This is line 19

        +

        This is line 20

        +

        This is line 21

        +

        This is line 22

        +

        This is line 23

        +

        This is line 24

        +

        This is line 25

        +

        This is line 26

        +

        This is line 27

        +

        This is line 28

        +

        This is line 29

        +

        This is line 30

        +

        This is line 31

        +

        This is line 32

        +

        This is line 33

        +

        This is line 34

        +

        This is line 35

        +

        This is line 36

        +

        This is line 37

        +

        This is line 38

        +

        This is line 39

        +

        This is line 40

        +

        This is line 41

        +

        This is line 42

        +

        This is line 43

        hi! + +

        This is line 1 nested

        +

        This is line 2 nested

        +

        This is line 3 nested

        +

        This is line 4 nested

        +

        This is line 5 nested

        +

        This is line 6 nested

        +

        This is line 7 nested

        +

        This is line 8 nested

        +

        This is line 9 nested

        +

        This is line 10 nested

        +

        This is line 11 nested

        +

        This is line 12 nested

        +

        This is line 13 nested

        +

        This is line 14 nested

        +

        This is line 15 nested

        +

        This is line 16 nested

        +

        This is line 17 nested

        +

        This is line 18 nested

        +

        This is line 19 nested

        +

        This is line 20 nested

        +

        This is line 21 nested

        +

        This is line 22 nested

        +

        This is line 23 nested

        +

        This is line 24 nested

        +

        This is line 25 nested

        +

        This is line 26 nested

        +

        This is line 27 nested

        +

        This is line 28 nested

        +

        This is line 29 nested

        +

        30

        + ! \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt new file mode 100644 index 0000000000..0c6dbeca8d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt @@ -0,0 +1,1186 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_DesignTime - - + DesignTimeDirective - + DirectiveToken - (2022:85,9 [21] StringLiterals.cshtml) - WriteLiteralsToInHere + DirectiveToken - (5701:205,9 [25] StringLiterals.cshtml) - WriteLiteralsToInHereAlso + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [2013] StringLiterals.cshtml) + IntermediateToken - (0:0,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3:0,3 [14] StringLiterals.cshtml) - Html - This is line 1 + IntermediateToken - (17:0,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (21:0,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (23:1,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (26:1,3 [14] StringLiterals.cshtml) - Html - This is line 2 + IntermediateToken - (40:1,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (44:1,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (46:2,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (49:2,3 [14] StringLiterals.cshtml) - Html - This is line 3 + IntermediateToken - (63:2,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (67:2,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (69:3,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (72:3,3 [14] StringLiterals.cshtml) - Html - This is line 4 + IntermediateToken - (86:3,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (90:3,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (92:4,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (95:4,3 [14] StringLiterals.cshtml) - Html - This is line 5 + IntermediateToken - (109:4,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (113:4,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (115:5,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (118:5,3 [14] StringLiterals.cshtml) - Html - This is line 6 + IntermediateToken - (132:5,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (136:5,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (138:6,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (141:6,3 [14] StringLiterals.cshtml) - Html - This is line 7 + IntermediateToken - (155:6,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (159:6,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (161:7,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (164:7,3 [14] StringLiterals.cshtml) - Html - This is line 8 + IntermediateToken - (178:7,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (182:7,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (184:8,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (187:8,3 [14] StringLiterals.cshtml) - Html - This is line 9 + IntermediateToken - (201:8,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (205:8,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (207:9,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (210:9,3 [15] StringLiterals.cshtml) - Html - This is line 10 + IntermediateToken - (225:9,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (229:9,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (231:10,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (234:10,3 [15] StringLiterals.cshtml) - Html - This is line 11 + IntermediateToken - (249:10,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (253:10,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (255:11,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (258:11,3 [15] StringLiterals.cshtml) - Html - This is line 12 + IntermediateToken - (273:11,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (277:11,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (279:12,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (282:12,3 [15] StringLiterals.cshtml) - Html - This is line 13 + IntermediateToken - (297:12,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (301:12,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (303:13,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (306:13,3 [15] StringLiterals.cshtml) - Html - This is line 14 + IntermediateToken - (321:13,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (325:13,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (327:14,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (330:14,3 [15] StringLiterals.cshtml) - Html - This is line 15 + IntermediateToken - (345:14,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (349:14,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (351:15,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (354:15,3 [15] StringLiterals.cshtml) - Html - This is line 16 + IntermediateToken - (369:15,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (373:15,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (375:16,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (378:16,3 [15] StringLiterals.cshtml) - Html - This is line 17 + IntermediateToken - (393:16,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (397:16,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (399:17,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (402:17,3 [15] StringLiterals.cshtml) - Html - This is line 18 + IntermediateToken - (417:17,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (421:17,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (423:18,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (426:18,3 [15] StringLiterals.cshtml) - Html - This is line 19 + IntermediateToken - (441:18,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (445:18,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (447:19,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (450:19,3 [15] StringLiterals.cshtml) - Html - This is line 20 + IntermediateToken - (465:19,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (469:19,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (471:20,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (474:20,3 [15] StringLiterals.cshtml) - Html - This is line 21 + IntermediateToken - (489:20,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (493:20,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (495:21,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (498:21,3 [15] StringLiterals.cshtml) - Html - This is line 22 + IntermediateToken - (513:21,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (517:21,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (519:22,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (522:22,3 [15] StringLiterals.cshtml) - Html - This is line 23 + IntermediateToken - (537:22,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (541:22,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (543:23,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (546:23,3 [15] StringLiterals.cshtml) - Html - This is line 24 + IntermediateToken - (561:23,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (565:23,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (567:24,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (570:24,3 [15] StringLiterals.cshtml) - Html - This is line 25 + IntermediateToken - (585:24,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (589:24,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (591:25,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (594:25,3 [15] StringLiterals.cshtml) - Html - This is line 26 + IntermediateToken - (609:25,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (613:25,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (615:26,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (618:26,3 [15] StringLiterals.cshtml) - Html - This is line 27 + IntermediateToken - (633:26,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (637:26,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (639:27,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (642:27,3 [15] StringLiterals.cshtml) - Html - This is line 28 + IntermediateToken - (657:27,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (661:27,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (663:28,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (666:28,3 [15] StringLiterals.cshtml) - Html - This is line 29 + IntermediateToken - (681:28,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (685:28,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (687:29,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (690:29,3 [15] StringLiterals.cshtml) - Html - This is line 30 + IntermediateToken - (705:29,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (709:29,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (711:30,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (714:30,3 [15] StringLiterals.cshtml) - Html - This is line 31 + IntermediateToken - (729:30,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (733:30,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (735:31,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (738:31,3 [15] StringLiterals.cshtml) - Html - This is line 32 + IntermediateToken - (753:31,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (757:31,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (759:32,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (762:32,3 [15] StringLiterals.cshtml) - Html - This is line 33 + IntermediateToken - (777:32,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (781:32,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (783:33,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (786:33,3 [15] StringLiterals.cshtml) - Html - This is line 34 + IntermediateToken - (801:33,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (805:33,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (807:34,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (810:34,3 [15] StringLiterals.cshtml) - Html - This is line 35 + IntermediateToken - (825:34,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (829:34,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (831:35,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (834:35,3 [15] StringLiterals.cshtml) - Html - This is line 36 + IntermediateToken - (849:35,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (853:35,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (855:36,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (858:36,3 [15] StringLiterals.cshtml) - Html - This is line 37 + IntermediateToken - (873:36,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (877:36,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (879:37,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (882:37,3 [15] StringLiterals.cshtml) - Html - This is line 38 + IntermediateToken - (897:37,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (901:37,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (903:38,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (906:38,3 [15] StringLiterals.cshtml) - Html - This is line 39 + IntermediateToken - (921:38,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (925:38,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (927:39,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (930:39,3 [15] StringLiterals.cshtml) - Html - This is line 40 + IntermediateToken - (945:39,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (949:39,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (951:40,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (954:40,3 [15] StringLiterals.cshtml) - Html - This is line 41 + IntermediateToken - (969:40,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (973:40,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (975:41,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (978:41,3 [15] StringLiterals.cshtml) - Html - This is line 42 + IntermediateToken - (993:41,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (997:41,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (999:42,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1002:42,3 [15] StringLiterals.cshtml) - Html - This is line 43 + IntermediateToken - (1017:42,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1021:42,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1023:43,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1026:43,3 [15] StringLiterals.cshtml) - Html - This is line 44 + IntermediateToken - (1041:43,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1045:43,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1047:44,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1050:44,3 [15] StringLiterals.cshtml) - Html - This is line 45 + IntermediateToken - (1065:44,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1069:44,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1071:45,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1074:45,3 [15] StringLiterals.cshtml) - Html - This is line 46 + IntermediateToken - (1089:45,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1093:45,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1095:46,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1098:46,3 [15] StringLiterals.cshtml) - Html - This is line 47 + IntermediateToken - (1113:46,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1117:46,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1119:47,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1122:47,3 [15] StringLiterals.cshtml) - Html - This is line 48 + IntermediateToken - (1137:47,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1141:47,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1143:48,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1146:48,3 [15] StringLiterals.cshtml) - Html - This is line 49 + IntermediateToken - (1161:48,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1165:48,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1167:49,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1170:49,3 [15] StringLiterals.cshtml) - Html - This is line 50 + IntermediateToken - (1185:49,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1189:49,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1191:50,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1194:50,3 [15] StringLiterals.cshtml) - Html - This is line 51 + IntermediateToken - (1209:50,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1213:50,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1215:51,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1218:51,3 [15] StringLiterals.cshtml) - Html - This is line 52 + IntermediateToken - (1233:51,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1237:51,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1239:52,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1242:52,3 [15] StringLiterals.cshtml) - Html - This is line 53 + IntermediateToken - (1257:52,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1261:52,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1263:53,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1266:53,3 [15] StringLiterals.cshtml) - Html - This is line 54 + IntermediateToken - (1281:53,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1285:53,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1287:54,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1290:54,3 [15] StringLiterals.cshtml) - Html - This is line 55 + IntermediateToken - (1305:54,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1309:54,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1311:55,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1314:55,3 [15] StringLiterals.cshtml) - Html - This is line 56 + IntermediateToken - (1329:55,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1333:55,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1335:56,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1338:56,3 [15] StringLiterals.cshtml) - Html - This is line 57 + IntermediateToken - (1353:56,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1357:56,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1359:57,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1362:57,3 [15] StringLiterals.cshtml) - Html - This is line 58 + IntermediateToken - (1377:57,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1381:57,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1383:58,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1386:58,3 [15] StringLiterals.cshtml) - Html - This is line 59 + IntermediateToken - (1401:58,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1405:58,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1407:59,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1410:59,3 [15] StringLiterals.cshtml) - Html - This is line 60 + IntermediateToken - (1425:59,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1429:59,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1431:60,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1434:60,3 [15] StringLiterals.cshtml) - Html - This is line 61 + IntermediateToken - (1449:60,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1453:60,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1455:61,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1458:61,3 [15] StringLiterals.cshtml) - Html - This is line 62 + IntermediateToken - (1473:61,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1477:61,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1479:62,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1482:62,3 [15] StringLiterals.cshtml) - Html - This is line 63 + IntermediateToken - (1497:62,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1501:62,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1503:63,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1506:63,3 [15] StringLiterals.cshtml) - Html - This is line 64 + IntermediateToken - (1521:63,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1525:63,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1527:64,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1530:64,3 [15] StringLiterals.cshtml) - Html - This is line 65 + IntermediateToken - (1545:64,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1549:64,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1551:65,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1554:65,3 [15] StringLiterals.cshtml) - Html - This is line 66 + IntermediateToken - (1569:65,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1573:65,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1575:66,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1578:66,3 [15] StringLiterals.cshtml) - Html - This is line 67 + IntermediateToken - (1593:66,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1597:66,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1599:67,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1602:67,3 [15] StringLiterals.cshtml) - Html - This is line 68 + IntermediateToken - (1617:67,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1621:67,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1623:68,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1626:68,3 [15] StringLiterals.cshtml) - Html - This is line 69 + IntermediateToken - (1641:68,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1645:68,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1647:69,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1650:69,3 [15] StringLiterals.cshtml) - Html - This is line 70 + IntermediateToken - (1665:69,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1669:69,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1671:70,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1674:70,3 [15] StringLiterals.cshtml) - Html - This is line 71 + IntermediateToken - (1689:70,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1693:70,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1695:71,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1698:71,3 [15] StringLiterals.cshtml) - Html - This is line 72 + IntermediateToken - (1713:71,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1717:71,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1719:72,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1722:72,3 [15] StringLiterals.cshtml) - Html - This is line 73 + IntermediateToken - (1737:72,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1741:72,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1743:73,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1746:73,3 [15] StringLiterals.cshtml) - Html - This is line 74 + IntermediateToken - (1761:73,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1765:73,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1767:74,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1770:74,3 [15] StringLiterals.cshtml) - Html - This is line 75 + IntermediateToken - (1785:74,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1789:74,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1791:75,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1794:75,3 [15] StringLiterals.cshtml) - Html - This is line 76 + IntermediateToken - (1809:75,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1813:75,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1815:76,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1818:76,3 [15] StringLiterals.cshtml) - Html - This is line 77 + IntermediateToken - (1833:76,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1837:76,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1839:77,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1842:77,3 [15] StringLiterals.cshtml) - Html - This is line 78 + IntermediateToken - (1857:77,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1861:77,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1863:78,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1866:78,3 [15] StringLiterals.cshtml) - Html - This is line 79 + IntermediateToken - (1881:78,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1885:78,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1887:79,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1890:79,3 [15] StringLiterals.cshtml) - Html - This is line 80 + IntermediateToken - (1905:79,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1909:79,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1911:80,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1914:80,3 [15] StringLiterals.cshtml) - Html - This is line 81 + IntermediateToken - (1929:80,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1933:80,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1935:81,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1938:81,3 [15] StringLiterals.cshtml) - Html - This is line 82 + IntermediateToken - (1953:81,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1957:81,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1959:82,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1962:82,3 [15] StringLiterals.cshtml) - Html - This is line 83 + IntermediateToken - (1977:82,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1981:82,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1983:83,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1986:83,3 [15] StringLiterals.cshtml) - Html - This is line 84 + IntermediateToken - (2001:83,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2005:83,22 [3] StringLiterals.cshtml) - Html -
        + IntermediateToken - (2009:83,26 [4] StringLiterals.cshtml) - Html - \n\n + Section - - WriteLiteralsToInHere + HtmlContent - (2045:85,32 [2618] StringLiterals.cshtml) + IntermediateToken - (2045:85,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2051:86,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2054:86,7 [21] StringLiterals.cshtml) - Html - This is line 1 nested + IntermediateToken - (2075:86,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2079:86,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2085:87,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2088:87,7 [21] StringLiterals.cshtml) - Html - This is line 2 nested + IntermediateToken - (2109:87,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2113:87,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2119:88,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2122:88,7 [21] StringLiterals.cshtml) - Html - This is line 3 nested + IntermediateToken - (2143:88,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2147:88,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2153:89,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2156:89,7 [21] StringLiterals.cshtml) - Html - This is line 4 nested + IntermediateToken - (2177:89,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2181:89,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2187:90,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2190:90,7 [21] StringLiterals.cshtml) - Html - This is line 5 nested + IntermediateToken - (2211:90,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2215:90,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2221:91,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2224:91,7 [21] StringLiterals.cshtml) - Html - This is line 6 nested + IntermediateToken - (2245:91,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2249:91,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2255:92,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2258:92,7 [21] StringLiterals.cshtml) - Html - This is line 7 nested + IntermediateToken - (2279:92,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2283:92,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2289:93,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2292:93,7 [21] StringLiterals.cshtml) - Html - This is line 8 nested + IntermediateToken - (2313:93,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2317:93,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2323:94,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2326:94,7 [21] StringLiterals.cshtml) - Html - This is line 9 nested + IntermediateToken - (2347:94,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2351:94,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2357:95,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2360:95,7 [22] StringLiterals.cshtml) - Html - This is line 10 nested + IntermediateToken - (2382:95,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2386:95,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2392:96,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2395:96,7 [22] StringLiterals.cshtml) - Html - This is line 11 nested + IntermediateToken - (2417:96,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2421:96,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2427:97,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2430:97,7 [22] StringLiterals.cshtml) - Html - This is line 12 nested + IntermediateToken - (2452:97,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2456:97,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2462:98,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2465:98,7 [22] StringLiterals.cshtml) - Html - This is line 13 nested + IntermediateToken - (2487:98,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2491:98,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2497:99,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2500:99,7 [22] StringLiterals.cshtml) - Html - This is line 14 nested + IntermediateToken - (2522:99,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2526:99,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2532:100,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2535:100,7 [22] StringLiterals.cshtml) - Html - This is line 15 nested + IntermediateToken - (2557:100,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2561:100,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2567:101,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2570:101,7 [22] StringLiterals.cshtml) - Html - This is line 16 nested + IntermediateToken - (2592:101,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2596:101,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2602:102,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2605:102,7 [22] StringLiterals.cshtml) - Html - This is line 17 nested + IntermediateToken - (2627:102,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2631:102,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2637:103,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2640:103,7 [22] StringLiterals.cshtml) - Html - This is line 18 nested + IntermediateToken - (2662:103,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2666:103,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2672:104,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2675:104,7 [22] StringLiterals.cshtml) - Html - This is line 19 nested + IntermediateToken - (2697:104,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2701:104,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2707:105,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2710:105,7 [22] StringLiterals.cshtml) - Html - This is line 20 nested + IntermediateToken - (2732:105,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2736:105,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2742:106,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2745:106,7 [22] StringLiterals.cshtml) - Html - This is line 21 nested + IntermediateToken - (2767:106,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2771:106,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2777:107,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2780:107,7 [22] StringLiterals.cshtml) - Html - This is line 22 nested + IntermediateToken - (2802:107,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2806:107,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2812:108,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2815:108,7 [22] StringLiterals.cshtml) - Html - This is line 23 nested + IntermediateToken - (2837:108,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2841:108,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2847:109,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2850:109,7 [22] StringLiterals.cshtml) - Html - This is line 24 nested + IntermediateToken - (2872:109,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2876:109,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2882:110,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2885:110,7 [22] StringLiterals.cshtml) - Html - This is line 25 nested + IntermediateToken - (2907:110,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2911:110,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2917:111,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2920:111,7 [22] StringLiterals.cshtml) - Html - This is line 26 nested + IntermediateToken - (2942:111,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2946:111,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2952:112,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2955:112,7 [22] StringLiterals.cshtml) - Html - This is line 27 nested + IntermediateToken - (2977:112,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2981:112,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2987:113,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2990:113,7 [22] StringLiterals.cshtml) - Html - This is line 28 nested + IntermediateToken - (3012:113,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3016:113,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3022:114,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3025:114,7 [22] StringLiterals.cshtml) - Html - This is line 29 nested + IntermediateToken - (3047:114,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3051:114,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3057:115,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3060:115,7 [22] StringLiterals.cshtml) - Html - This is line 30 nested + IntermediateToken - (3082:115,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3086:115,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3092:116,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3095:116,7 [22] StringLiterals.cshtml) - Html - This is line 31 nested + IntermediateToken - (3117:116,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3121:116,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3127:117,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3130:117,7 [22] StringLiterals.cshtml) - Html - This is line 32 nested + IntermediateToken - (3152:117,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3156:117,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3162:118,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3165:118,7 [22] StringLiterals.cshtml) - Html - This is line 33 nested + IntermediateToken - (3187:118,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3191:118,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3197:119,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3200:119,7 [22] StringLiterals.cshtml) - Html - This is line 34 nested + IntermediateToken - (3222:119,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3226:119,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3232:120,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3235:120,7 [22] StringLiterals.cshtml) - Html - This is line 35 nested + IntermediateToken - (3257:120,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3261:120,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3267:121,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3270:121,7 [22] StringLiterals.cshtml) - Html - This is line 36 nested + IntermediateToken - (3292:121,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3296:121,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3302:122,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3305:122,7 [22] StringLiterals.cshtml) - Html - This is line 37 nested + IntermediateToken - (3327:122,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3331:122,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3337:123,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3340:123,7 [22] StringLiterals.cshtml) - Html - This is line 38 nested + IntermediateToken - (3362:123,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3366:123,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3372:124,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3375:124,7 [22] StringLiterals.cshtml) - Html - This is line 39 nested + IntermediateToken - (3397:124,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3401:124,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3407:125,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3410:125,7 [22] StringLiterals.cshtml) - Html - This is line 40 nested + IntermediateToken - (3432:125,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3436:125,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3442:126,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3445:126,7 [22] StringLiterals.cshtml) - Html - This is line 41 nested + IntermediateToken - (3467:126,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3471:126,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3477:127,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3480:127,7 [22] StringLiterals.cshtml) - Html - This is line 42 nested + IntermediateToken - (3502:127,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3506:127,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3512:128,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3515:128,7 [22] StringLiterals.cshtml) - Html - This is line 43 nested + IntermediateToken - (3537:128,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3541:128,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3547:129,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3550:129,7 [22] StringLiterals.cshtml) - Html - This is line 44 nested + IntermediateToken - (3572:129,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3576:129,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3582:130,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3585:130,7 [22] StringLiterals.cshtml) - Html - This is line 45 nested + IntermediateToken - (3607:130,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3611:130,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3617:131,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3620:131,7 [22] StringLiterals.cshtml) - Html - This is line 46 nested + IntermediateToken - (3642:131,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3646:131,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3652:132,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3655:132,7 [22] StringLiterals.cshtml) - Html - This is line 47 nested + IntermediateToken - (3677:132,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3681:132,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3687:133,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3690:133,7 [22] StringLiterals.cshtml) - Html - This is line 48 nested + IntermediateToken - (3712:133,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3716:133,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3722:134,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3725:134,7 [22] StringLiterals.cshtml) - Html - This is line 49 nested + IntermediateToken - (3747:134,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3751:134,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3757:135,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3760:135,7 [22] StringLiterals.cshtml) - Html - This is line 50 nested + IntermediateToken - (3782:135,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3786:135,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3792:136,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3795:136,7 [22] StringLiterals.cshtml) - Html - This is line 51 nested + IntermediateToken - (3817:136,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3821:136,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3827:137,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3830:137,7 [22] StringLiterals.cshtml) - Html - This is line 52 nested + IntermediateToken - (3852:137,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3856:137,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3862:138,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3865:138,7 [22] StringLiterals.cshtml) - Html - This is line 53 nested + IntermediateToken - (3887:138,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3891:138,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3897:139,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3900:139,7 [22] StringLiterals.cshtml) - Html - This is line 54 nested + IntermediateToken - (3922:139,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3926:139,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3932:140,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3935:140,7 [22] StringLiterals.cshtml) - Html - This is line 55 nested + IntermediateToken - (3957:140,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3961:140,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3967:141,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3970:141,7 [22] StringLiterals.cshtml) - Html - This is line 56 nested + IntermediateToken - (3992:141,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3996:141,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4002:142,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4005:142,7 [22] StringLiterals.cshtml) - Html - This is line 57 nested + IntermediateToken - (4027:142,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4031:142,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4037:143,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4040:143,7 [22] StringLiterals.cshtml) - Html - This is line 58 nested + IntermediateToken - (4062:143,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4066:143,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4072:144,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4075:144,7 [22] StringLiterals.cshtml) - Html - This is line 59 nested + IntermediateToken - (4097:144,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4101:144,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4107:145,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4110:145,7 [22] StringLiterals.cshtml) - Html - This is line 60 nested + IntermediateToken - (4132:145,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4136:145,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4142:146,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4145:146,7 [22] StringLiterals.cshtml) - Html - This is line 61 nested + IntermediateToken - (4167:146,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4171:146,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4177:147,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4180:147,7 [22] StringLiterals.cshtml) - Html - This is line 62 nested + IntermediateToken - (4202:147,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4206:147,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4212:148,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4215:148,7 [22] StringLiterals.cshtml) - Html - This is line 63 nested + IntermediateToken - (4237:148,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4241:148,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4247:149,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4250:149,7 [22] StringLiterals.cshtml) - Html - This is line 64 nested + IntermediateToken - (4272:149,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4276:149,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4282:150,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4285:150,7 [22] StringLiterals.cshtml) - Html - This is line 65 nested + IntermediateToken - (4307:150,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4311:150,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4317:151,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4320:151,7 [22] StringLiterals.cshtml) - Html - This is line 66 nested + IntermediateToken - (4342:151,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4346:151,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4352:152,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4355:152,7 [22] StringLiterals.cshtml) - Html - This is line 67 nested + IntermediateToken - (4377:152,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4381:152,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4387:153,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4390:153,7 [22] StringLiterals.cshtml) - Html - This is line 68 nested + IntermediateToken - (4412:153,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4416:153,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4422:154,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4425:154,7 [22] StringLiterals.cshtml) - Html - This is line 69 nested + IntermediateToken - (4447:154,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4451:154,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4457:155,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4460:155,7 [22] StringLiterals.cshtml) - Html - This is line 70 nested + IntermediateToken - (4482:155,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4486:155,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4492:156,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4495:156,7 [22] StringLiterals.cshtml) - Html - This is line 71 nested + IntermediateToken - (4517:156,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4521:156,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4527:157,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4530:157,7 [22] StringLiterals.cshtml) - Html - This is line 72 nested + IntermediateToken - (4552:157,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4556:157,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4562:158,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4565:158,7 [22] StringLiterals.cshtml) - Html - This is line 73 nested + IntermediateToken - (4587:158,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4591:158,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4597:159,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4600:159,7 [22] StringLiterals.cshtml) - Html - This is line 74 nested + IntermediateToken - (4622:159,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4626:159,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4632:160,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4635:160,7 [22] StringLiterals.cshtml) - Html - This is line 75 nested + IntermediateToken - (4657:160,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4661:160,33 [2] StringLiterals.cshtml) - Html - \n + HtmlContent - (4664:161,1 [1028] StringLiterals.cshtml) + IntermediateToken - (4664:161,1 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4666:162,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4669:162,3 [14] StringLiterals.cshtml) - Html - This is line 1 + IntermediateToken - (4683:162,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4687:162,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4689:163,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4692:163,3 [14] StringLiterals.cshtml) - Html - This is line 2 + IntermediateToken - (4706:163,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4710:163,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4712:164,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4715:164,3 [14] StringLiterals.cshtml) - Html - This is line 3 + IntermediateToken - (4729:164,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4733:164,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4735:165,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4738:165,3 [14] StringLiterals.cshtml) - Html - This is line 4 + IntermediateToken - (4752:165,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4756:165,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4758:166,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4761:166,3 [14] StringLiterals.cshtml) - Html - This is line 5 + IntermediateToken - (4775:166,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4779:166,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4781:167,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4784:167,3 [14] StringLiterals.cshtml) - Html - This is line 6 + IntermediateToken - (4798:167,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4802:167,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4804:168,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4807:168,3 [14] StringLiterals.cshtml) - Html - This is line 7 + IntermediateToken - (4821:168,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4825:168,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4827:169,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4830:169,3 [14] StringLiterals.cshtml) - Html - This is line 8 + IntermediateToken - (4844:169,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4848:169,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4850:170,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4853:170,3 [14] StringLiterals.cshtml) - Html - This is line 9 + IntermediateToken - (4867:170,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4871:170,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4873:171,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4876:171,3 [15] StringLiterals.cshtml) - Html - This is line 10 + IntermediateToken - (4891:171,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4895:171,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4897:172,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4900:172,3 [15] StringLiterals.cshtml) - Html - This is line 11 + IntermediateToken - (4915:172,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4919:172,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4921:173,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4924:173,3 [15] StringLiterals.cshtml) - Html - This is line 12 + IntermediateToken - (4939:173,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4943:173,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4945:174,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4948:174,3 [15] StringLiterals.cshtml) - Html - This is line 13 + IntermediateToken - (4963:174,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4967:174,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4969:175,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4972:175,3 [15] StringLiterals.cshtml) - Html - This is line 14 + IntermediateToken - (4987:175,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4991:175,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4993:176,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4996:176,3 [15] StringLiterals.cshtml) - Html - This is line 15 + IntermediateToken - (5011:176,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5015:176,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5017:177,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5020:177,3 [15] StringLiterals.cshtml) - Html - This is line 16 + IntermediateToken - (5035:177,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5039:177,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5041:178,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5044:178,3 [15] StringLiterals.cshtml) - Html - This is line 17 + IntermediateToken - (5059:178,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5063:178,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5065:179,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5068:179,3 [15] StringLiterals.cshtml) - Html - This is line 18 + IntermediateToken - (5083:179,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5087:179,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5089:180,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5092:180,3 [15] StringLiterals.cshtml) - Html - This is line 19 + IntermediateToken - (5107:180,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5111:180,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5113:181,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5116:181,3 [15] StringLiterals.cshtml) - Html - This is line 20 + IntermediateToken - (5131:181,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5135:181,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5137:182,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5140:182,3 [15] StringLiterals.cshtml) - Html - This is line 21 + IntermediateToken - (5155:182,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5159:182,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5161:183,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5164:183,3 [15] StringLiterals.cshtml) - Html - This is line 22 + IntermediateToken - (5179:183,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5183:183,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5185:184,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5188:184,3 [15] StringLiterals.cshtml) - Html - This is line 23 + IntermediateToken - (5203:184,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5207:184,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5209:185,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5212:185,3 [15] StringLiterals.cshtml) - Html - This is line 24 + IntermediateToken - (5227:185,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5231:185,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5233:186,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5236:186,3 [15] StringLiterals.cshtml) - Html - This is line 25 + IntermediateToken - (5251:186,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5255:186,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5257:187,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5260:187,3 [15] StringLiterals.cshtml) - Html - This is line 26 + IntermediateToken - (5275:187,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5279:187,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5281:188,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5284:188,3 [15] StringLiterals.cshtml) - Html - This is line 27 + IntermediateToken - (5299:188,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5303:188,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5305:189,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5308:189,3 [15] StringLiterals.cshtml) - Html - This is line 28 + IntermediateToken - (5323:189,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5327:189,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5329:190,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5332:190,3 [15] StringLiterals.cshtml) - Html - This is line 29 + IntermediateToken - (5347:190,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5351:190,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5353:191,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5356:191,3 [15] StringLiterals.cshtml) - Html - This is line 30 + IntermediateToken - (5371:191,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5375:191,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5377:192,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5380:192,3 [15] StringLiterals.cshtml) - Html - This is line 31 + IntermediateToken - (5395:192,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5399:192,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5401:193,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5404:193,3 [15] StringLiterals.cshtml) - Html - This is line 32 + IntermediateToken - (5419:193,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5423:193,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5425:194,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5428:194,3 [15] StringLiterals.cshtml) - Html - This is line 33 + IntermediateToken - (5443:194,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5447:194,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5449:195,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5452:195,3 [15] StringLiterals.cshtml) - Html - This is line 34 + IntermediateToken - (5467:195,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5471:195,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5473:196,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5476:196,3 [15] StringLiterals.cshtml) - Html - This is line 35 + IntermediateToken - (5491:196,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5495:196,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5497:197,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5500:197,3 [15] StringLiterals.cshtml) - Html - This is line 36 + IntermediateToken - (5515:197,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5519:197,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5521:198,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5524:198,3 [15] StringLiterals.cshtml) - Html - This is line 37 + IntermediateToken - (5539:198,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5543:198,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5545:199,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5548:199,3 [15] StringLiterals.cshtml) - Html - This is line 38 + IntermediateToken - (5563:199,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5567:199,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5569:200,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5572:200,3 [15] StringLiterals.cshtml) - Html - This is line 39 + IntermediateToken - (5587:200,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5591:200,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5593:201,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5596:201,3 [15] StringLiterals.cshtml) - Html - This is line 40 + IntermediateToken - (5611:201,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5615:201,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5617:202,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5620:202,3 [15] StringLiterals.cshtml) - Html - This is line 41 + IntermediateToken - (5635:202,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5639:202,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5641:203,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5644:203,3 [15] StringLiterals.cshtml) - Html - This is line 42 + IntermediateToken - (5659:203,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5663:203,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5665:204,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5668:204,3 [15] StringLiterals.cshtml) - Html - This is line 43 + IntermediateToken - (5683:204,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5687:204,22 [5] StringLiterals.cshtml) - Html - hi!\n + Section - - WriteLiteralsToInHereAlso + HtmlContent - (5728:205,36 [1023] StringLiterals.cshtml) + IntermediateToken - (5728:205,36 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5734:206,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5737:206,7 [21] StringLiterals.cshtml) - Html - This is line 1 nested + IntermediateToken - (5758:206,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5762:206,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5768:207,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5771:207,7 [21] StringLiterals.cshtml) - Html - This is line 2 nested + IntermediateToken - (5792:207,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5796:207,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5802:208,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5805:208,7 [21] StringLiterals.cshtml) - Html - This is line 3 nested + IntermediateToken - (5826:208,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5830:208,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5836:209,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5839:209,7 [21] StringLiterals.cshtml) - Html - This is line 4 nested + IntermediateToken - (5860:209,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5864:209,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5870:210,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5873:210,7 [21] StringLiterals.cshtml) - Html - This is line 5 nested + IntermediateToken - (5894:210,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5898:210,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5904:211,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5907:211,7 [21] StringLiterals.cshtml) - Html - This is line 6 nested + IntermediateToken - (5928:211,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5932:211,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5938:212,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5941:212,7 [21] StringLiterals.cshtml) - Html - This is line 7 nested + IntermediateToken - (5962:212,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5966:212,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5972:213,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5975:213,7 [21] StringLiterals.cshtml) - Html - This is line 8 nested + IntermediateToken - (5996:213,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6000:213,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6006:214,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6009:214,7 [21] StringLiterals.cshtml) - Html - This is line 9 nested + IntermediateToken - (6030:214,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6034:214,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6040:215,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6043:215,7 [22] StringLiterals.cshtml) - Html - This is line 10 nested + IntermediateToken - (6065:215,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6069:215,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6075:216,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6078:216,7 [22] StringLiterals.cshtml) - Html - This is line 11 nested + IntermediateToken - (6100:216,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6104:216,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6110:217,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6113:217,7 [22] StringLiterals.cshtml) - Html - This is line 12 nested + IntermediateToken - (6135:217,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6139:217,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6145:218,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6148:218,7 [22] StringLiterals.cshtml) - Html - This is line 13 nested + IntermediateToken - (6170:218,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6174:218,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6180:219,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6183:219,7 [22] StringLiterals.cshtml) - Html - This is line 14 nested + IntermediateToken - (6205:219,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6209:219,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6215:220,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6218:220,7 [22] StringLiterals.cshtml) - Html - This is line 15 nested + IntermediateToken - (6240:220,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6244:220,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6250:221,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6253:221,7 [22] StringLiterals.cshtml) - Html - This is line 16 nested + IntermediateToken - (6275:221,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6279:221,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6285:222,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6288:222,7 [22] StringLiterals.cshtml) - Html - This is line 17 nested + IntermediateToken - (6310:222,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6314:222,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6320:223,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6323:223,7 [22] StringLiterals.cshtml) - Html - This is line 18 nested + IntermediateToken - (6345:223,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6349:223,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6355:224,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6358:224,7 [22] StringLiterals.cshtml) - Html - This is line 19 nested + IntermediateToken - (6380:224,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6384:224,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6390:225,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6393:225,7 [22] StringLiterals.cshtml) - Html - This is line 20 nested + IntermediateToken - (6415:225,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6419:225,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6425:226,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6428:226,7 [22] StringLiterals.cshtml) - Html - This is line 21 nested + IntermediateToken - (6450:226,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6454:226,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6460:227,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6463:227,7 [22] StringLiterals.cshtml) - Html - This is line 22 nested + IntermediateToken - (6485:227,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6489:227,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6495:228,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6498:228,7 [22] StringLiterals.cshtml) - Html - This is line 23 nested + IntermediateToken - (6520:228,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6524:228,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6530:229,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6533:229,7 [22] StringLiterals.cshtml) - Html - This is line 24 nested + IntermediateToken - (6555:229,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6559:229,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6565:230,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6568:230,7 [22] StringLiterals.cshtml) - Html - This is line 25 nested + IntermediateToken - (6590:230,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6594:230,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6600:231,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6603:231,7 [22] StringLiterals.cshtml) - Html - This is line 26 nested + IntermediateToken - (6625:231,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6629:231,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6635:232,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6638:232,7 [22] StringLiterals.cshtml) - Html - This is line 27 nested + IntermediateToken - (6660:232,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6664:232,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6670:233,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6673:233,7 [22] StringLiterals.cshtml) - Html - This is line 28 nested + IntermediateToken - (6695:233,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6699:233,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6705:234,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6708:234,7 [22] StringLiterals.cshtml) - Html - This is line 29 nested + IntermediateToken - (6730:234,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6734:234,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6740:235,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6743:235,7 [2] StringLiterals.cshtml) - Html - 30 + IntermediateToken - (6745:235,9 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6749:235,13 [2] StringLiterals.cshtml) - Html - \n + HtmlContent - (6752:236,1 [1] StringLiterals.cshtml) + IntermediateToken - (6752:236,1 [1] StringLiterals.cshtml) - Html - ! diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.mappings.txt new file mode 100644 index 0000000000..3338234435 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (2022:85,9 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml) +|WriteLiteralsToInHere| +Generated Location: (515:12,22 [21] ) +|WriteLiteralsToInHere| + +Source Location: (5701:205,9 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml) +|WriteLiteralsToInHereAlso| +Generated Location: (790:22,22 [25] ) +|WriteLiteralsToInHereAlso| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs new file mode 100644 index 0000000000..b2c587c14d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.codegen.cs @@ -0,0 +1,267 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "711aea8060d90aea04acd3324afb4bb4a0caccde" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"711aea8060d90aea04acd3324afb4bb4a0caccde", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral(@"

        This is line 1

        +

        This is line 2

        +

        This is line 3

        +

        This is line 4

        +

        This is line 5

        +

        This is line 6

        +

        This is line 7

        +

        This is line 8

        +

        This is line 9

        +

        This is line 10

        +

        This is line 11

        +

        This is line 12

        +

        This is line 13

        +

        This is line 14

        +

        This is line 15

        +

        This is line 16

        +

        This is line 17

        +

        This is line 18

        +

        This is line 19

        +

        This is line 20

        +

        This is line 21

        +

        This is line 22

        +

        This is line 23

        +

        This is line 24

        +

        This is line 25

        +

        This is line 26

        +

        This is line 27

        +

        This is line 28

        +

        This is line 29

        +

        This is line 30

        +

        This is line 31

        +

        This is line 32

        +

        This is line 33

        +

        This is line 34

        +

        This is line 35

        +

        This is line 36

        +

        This is line 37

        +

        This is line 38

        +

        This is line 39

        +

        This is line 40

        +

        This is line 41

        +

        This is line 42

        +

        This is line 43

        +<"); + WriteLiteral(@"p>This is line 44

        +

        This is line 45

        +

        This is line 46

        +

        This is line 47

        +

        This is line 48

        +

        This is line 49

        +

        This is line 50

        +

        This is line 51

        +

        This is line 52

        +

        This is line 53

        +

        This is line 54

        +

        This is line 55

        +

        This is line 56

        +

        This is line 57

        +

        This is line 58

        +

        This is line 59

        +

        This is line 60

        +

        This is line 61

        +

        This is line 62

        +

        This is line 63

        +

        This is line 64

        +

        This is line 65

        +

        This is line 66

        +

        This is line 67

        +

        This is line 68

        +

        This is line 69

        +

        This is line 70

        +

        This is line 71

        +

        This is line 72

        +

        This is line 73

        +

        This is line 74

        +

        This is line 75

        +

        This is line 76

        +

        This is line 77

        +

        This is line 78

        +

        This is line 79

        +

        This is line 80

        +

        This is line 81

        +

        This is line 82

        +

        This is line 83

        +

        This is line 84


        + +"); + DefineSection("WriteLiteralsToInHere", async() => { + WriteLiteral(@" +

        This is line 1 nested

        +

        This is line 2 nested

        +

        This is line 3 nested

        +

        This is line 4 nested

        +

        This is line 5 nested

        +

        This is line 6 nested

        +

        This is line 7 nested

        +

        This is line 8 nested

        +

        This is line 9 nested

        +

        This is line 10 nested

        +

        This is line 11 nested

        +

        This is line 12 nested

        +

        This is line 13 nested

        +

        This is line 14 nested

        +

        This is line 15 nested

        +

        This is line 16 nested

        +

        This is line 17 nested

        +

        This is line 18 nested

        +

        This is line 19 nested

        +

        This is line 20 nested

        +

        This is line 21 nested

        +

        This is line 22 nested

        +

        This is line 23 nested

        +

        This is line 24 nested

        +

        This is line 25 nested

        +

        This is line 26 nested

        +

        This is line 27 nested

        +

        This is line 28 nested

        +

        This is line 29 nested

        +

        This is l"); + WriteLiteral(@"ine 30 nested

        +

        This is line 31 nested

        +

        This is line 32 nested

        +

        This is line 33 nested

        +

        This is line 34 nested

        +

        This is line 35 nested

        +

        This is line 36 nested

        +

        This is line 37 nested

        +

        This is line 38 nested

        +

        This is line 39 nested

        +

        This is line 40 nested

        +

        This is line 41 nested

        +

        This is line 42 nested

        +

        This is line 43 nested

        +

        This is line 44 nested

        +

        This is line 45 nested

        +

        This is line 46 nested

        +

        This is line 47 nested

        +

        This is line 48 nested

        +

        This is line 49 nested

        +

        This is line 50 nested

        +

        This is line 51 nested

        +

        This is line 52 nested

        +

        This is line 53 nested

        +

        This is line 54 nested

        +

        This is line 55 nested

        +

        This is line 56 nested

        +

        This is line 57 nested

        +

        This is line 58 nested

        +

        This is line 59 ne"); + WriteLiteral(@"sted

        +

        This is line 60 nested

        +

        This is line 61 nested

        +

        This is line 62 nested

        +

        This is line 63 nested

        +

        This is line 64 nested

        +

        This is line 65 nested

        +

        This is line 66 nested

        +

        This is line 67 nested

        +

        This is line 68 nested

        +

        This is line 69 nested

        +

        This is line 70 nested

        +

        This is line 71 nested

        +

        This is line 72 nested

        +

        This is line 73 nested

        +

        This is line 74 nested

        +

        This is line 75 nested

        +"); + } + ); + WriteLiteral(@"

        This is line 1

        +

        This is line 2

        +

        This is line 3

        +

        This is line 4

        +

        This is line 5

        +

        This is line 6

        +

        This is line 7

        +

        This is line 8

        +

        This is line 9

        +

        This is line 10

        +

        This is line 11

        +

        This is line 12

        +

        This is line 13

        +

        This is line 14

        +

        This is line 15

        +

        This is line 16

        +

        This is line 17

        +

        This is line 18

        +

        This is line 19

        +

        This is line 20

        +

        This is line 21

        +

        This is line 22

        +

        This is line 23

        +

        This is line 24

        +

        This is line 25

        +

        This is line 26

        +

        This is line 27

        +

        This is line 28

        +

        This is line 29

        +

        This is line 30

        +

        This is line 31

        +

        This is line 32

        +

        This is line 33

        +

        This is line 34

        +

        This is line 35

        +

        This is line 36

        +

        This is line 37

        +

        This is line 38

        +

        This is line 39

        +

        This is line 40

        +

        This is line 41

        +

        This is line 42

        +

        This is line 43

        hi!"); + WriteLiteral("\r\n"); + DefineSection("WriteLiteralsToInHereAlso", async() => { + WriteLiteral(@" +

        This is line 1 nested

        +

        This is line 2 nested

        +

        This is line 3 nested

        +

        This is line 4 nested

        +

        This is line 5 nested

        +

        This is line 6 nested

        +

        This is line 7 nested

        +

        This is line 8 nested

        +

        This is line 9 nested

        +

        This is line 10 nested

        +

        This is line 11 nested

        +

        This is line 12 nested

        +

        This is line 13 nested

        +

        This is line 14 nested

        +

        This is line 15 nested

        +

        This is line 16 nested

        +

        This is line 17 nested

        +

        This is line 18 nested

        +

        This is line 19 nested

        +

        This is line 20 nested

        +

        This is line 21 nested

        +

        This is line 22 nested

        +

        This is line 23 nested

        +

        This is line 24 nested

        +

        This is line 25 nested

        +

        This is line 26 nested

        +

        This is line 27 nested

        +

        This is line 28 nested

        +

        This is line 29 nested

        +

        30

        +"); + } + ); + WriteLiteral("!"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt new file mode 100644 index 0000000000..0866f75837 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_Runtime.ir.txt @@ -0,0 +1,1178 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (0:0,0 [2013] StringLiterals.cshtml) + IntermediateToken - (0:0,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3:0,3 [14] StringLiterals.cshtml) - Html - This is line 1 + IntermediateToken - (17:0,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (21:0,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (23:1,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (26:1,3 [14] StringLiterals.cshtml) - Html - This is line 2 + IntermediateToken - (40:1,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (44:1,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (46:2,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (49:2,3 [14] StringLiterals.cshtml) - Html - This is line 3 + IntermediateToken - (63:2,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (67:2,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (69:3,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (72:3,3 [14] StringLiterals.cshtml) - Html - This is line 4 + IntermediateToken - (86:3,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (90:3,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (92:4,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (95:4,3 [14] StringLiterals.cshtml) - Html - This is line 5 + IntermediateToken - (109:4,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (113:4,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (115:5,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (118:5,3 [14] StringLiterals.cshtml) - Html - This is line 6 + IntermediateToken - (132:5,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (136:5,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (138:6,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (141:6,3 [14] StringLiterals.cshtml) - Html - This is line 7 + IntermediateToken - (155:6,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (159:6,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (161:7,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (164:7,3 [14] StringLiterals.cshtml) - Html - This is line 8 + IntermediateToken - (178:7,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (182:7,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (184:8,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (187:8,3 [14] StringLiterals.cshtml) - Html - This is line 9 + IntermediateToken - (201:8,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (205:8,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (207:9,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (210:9,3 [15] StringLiterals.cshtml) - Html - This is line 10 + IntermediateToken - (225:9,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (229:9,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (231:10,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (234:10,3 [15] StringLiterals.cshtml) - Html - This is line 11 + IntermediateToken - (249:10,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (253:10,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (255:11,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (258:11,3 [15] StringLiterals.cshtml) - Html - This is line 12 + IntermediateToken - (273:11,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (277:11,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (279:12,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (282:12,3 [15] StringLiterals.cshtml) - Html - This is line 13 + IntermediateToken - (297:12,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (301:12,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (303:13,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (306:13,3 [15] StringLiterals.cshtml) - Html - This is line 14 + IntermediateToken - (321:13,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (325:13,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (327:14,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (330:14,3 [15] StringLiterals.cshtml) - Html - This is line 15 + IntermediateToken - (345:14,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (349:14,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (351:15,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (354:15,3 [15] StringLiterals.cshtml) - Html - This is line 16 + IntermediateToken - (369:15,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (373:15,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (375:16,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (378:16,3 [15] StringLiterals.cshtml) - Html - This is line 17 + IntermediateToken - (393:16,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (397:16,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (399:17,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (402:17,3 [15] StringLiterals.cshtml) - Html - This is line 18 + IntermediateToken - (417:17,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (421:17,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (423:18,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (426:18,3 [15] StringLiterals.cshtml) - Html - This is line 19 + IntermediateToken - (441:18,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (445:18,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (447:19,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (450:19,3 [15] StringLiterals.cshtml) - Html - This is line 20 + IntermediateToken - (465:19,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (469:19,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (471:20,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (474:20,3 [15] StringLiterals.cshtml) - Html - This is line 21 + IntermediateToken - (489:20,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (493:20,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (495:21,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (498:21,3 [15] StringLiterals.cshtml) - Html - This is line 22 + IntermediateToken - (513:21,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (517:21,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (519:22,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (522:22,3 [15] StringLiterals.cshtml) - Html - This is line 23 + IntermediateToken - (537:22,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (541:22,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (543:23,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (546:23,3 [15] StringLiterals.cshtml) - Html - This is line 24 + IntermediateToken - (561:23,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (565:23,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (567:24,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (570:24,3 [15] StringLiterals.cshtml) - Html - This is line 25 + IntermediateToken - (585:24,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (589:24,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (591:25,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (594:25,3 [15] StringLiterals.cshtml) - Html - This is line 26 + IntermediateToken - (609:25,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (613:25,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (615:26,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (618:26,3 [15] StringLiterals.cshtml) - Html - This is line 27 + IntermediateToken - (633:26,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (637:26,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (639:27,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (642:27,3 [15] StringLiterals.cshtml) - Html - This is line 28 + IntermediateToken - (657:27,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (661:27,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (663:28,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (666:28,3 [15] StringLiterals.cshtml) - Html - This is line 29 + IntermediateToken - (681:28,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (685:28,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (687:29,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (690:29,3 [15] StringLiterals.cshtml) - Html - This is line 30 + IntermediateToken - (705:29,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (709:29,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (711:30,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (714:30,3 [15] StringLiterals.cshtml) - Html - This is line 31 + IntermediateToken - (729:30,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (733:30,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (735:31,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (738:31,3 [15] StringLiterals.cshtml) - Html - This is line 32 + IntermediateToken - (753:31,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (757:31,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (759:32,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (762:32,3 [15] StringLiterals.cshtml) - Html - This is line 33 + IntermediateToken - (777:32,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (781:32,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (783:33,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (786:33,3 [15] StringLiterals.cshtml) - Html - This is line 34 + IntermediateToken - (801:33,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (805:33,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (807:34,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (810:34,3 [15] StringLiterals.cshtml) - Html - This is line 35 + IntermediateToken - (825:34,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (829:34,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (831:35,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (834:35,3 [15] StringLiterals.cshtml) - Html - This is line 36 + IntermediateToken - (849:35,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (853:35,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (855:36,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (858:36,3 [15] StringLiterals.cshtml) - Html - This is line 37 + IntermediateToken - (873:36,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (877:36,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (879:37,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (882:37,3 [15] StringLiterals.cshtml) - Html - This is line 38 + IntermediateToken - (897:37,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (901:37,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (903:38,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (906:38,3 [15] StringLiterals.cshtml) - Html - This is line 39 + IntermediateToken - (921:38,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (925:38,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (927:39,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (930:39,3 [15] StringLiterals.cshtml) - Html - This is line 40 + IntermediateToken - (945:39,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (949:39,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (951:40,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (954:40,3 [15] StringLiterals.cshtml) - Html - This is line 41 + IntermediateToken - (969:40,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (973:40,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (975:41,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (978:41,3 [15] StringLiterals.cshtml) - Html - This is line 42 + IntermediateToken - (993:41,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (997:41,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (999:42,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1002:42,3 [15] StringLiterals.cshtml) - Html - This is line 43 + IntermediateToken - (1017:42,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1021:42,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1023:43,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1026:43,3 [15] StringLiterals.cshtml) - Html - This is line 44 + IntermediateToken - (1041:43,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1045:43,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1047:44,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1050:44,3 [15] StringLiterals.cshtml) - Html - This is line 45 + IntermediateToken - (1065:44,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1069:44,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1071:45,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1074:45,3 [15] StringLiterals.cshtml) - Html - This is line 46 + IntermediateToken - (1089:45,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1093:45,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1095:46,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1098:46,3 [15] StringLiterals.cshtml) - Html - This is line 47 + IntermediateToken - (1113:46,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1117:46,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1119:47,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1122:47,3 [15] StringLiterals.cshtml) - Html - This is line 48 + IntermediateToken - (1137:47,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1141:47,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1143:48,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1146:48,3 [15] StringLiterals.cshtml) - Html - This is line 49 + IntermediateToken - (1161:48,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1165:48,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1167:49,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1170:49,3 [15] StringLiterals.cshtml) - Html - This is line 50 + IntermediateToken - (1185:49,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1189:49,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1191:50,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1194:50,3 [15] StringLiterals.cshtml) - Html - This is line 51 + IntermediateToken - (1209:50,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1213:50,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1215:51,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1218:51,3 [15] StringLiterals.cshtml) - Html - This is line 52 + IntermediateToken - (1233:51,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1237:51,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1239:52,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1242:52,3 [15] StringLiterals.cshtml) - Html - This is line 53 + IntermediateToken - (1257:52,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1261:52,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1263:53,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1266:53,3 [15] StringLiterals.cshtml) - Html - This is line 54 + IntermediateToken - (1281:53,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1285:53,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1287:54,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1290:54,3 [15] StringLiterals.cshtml) - Html - This is line 55 + IntermediateToken - (1305:54,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1309:54,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1311:55,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1314:55,3 [15] StringLiterals.cshtml) - Html - This is line 56 + IntermediateToken - (1329:55,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1333:55,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1335:56,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1338:56,3 [15] StringLiterals.cshtml) - Html - This is line 57 + IntermediateToken - (1353:56,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1357:56,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1359:57,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1362:57,3 [15] StringLiterals.cshtml) - Html - This is line 58 + IntermediateToken - (1377:57,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1381:57,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1383:58,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1386:58,3 [15] StringLiterals.cshtml) - Html - This is line 59 + IntermediateToken - (1401:58,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1405:58,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1407:59,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1410:59,3 [15] StringLiterals.cshtml) - Html - This is line 60 + IntermediateToken - (1425:59,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1429:59,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1431:60,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1434:60,3 [15] StringLiterals.cshtml) - Html - This is line 61 + IntermediateToken - (1449:60,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1453:60,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1455:61,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1458:61,3 [15] StringLiterals.cshtml) - Html - This is line 62 + IntermediateToken - (1473:61,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1477:61,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1479:62,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1482:62,3 [15] StringLiterals.cshtml) - Html - This is line 63 + IntermediateToken - (1497:62,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1501:62,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1503:63,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1506:63,3 [15] StringLiterals.cshtml) - Html - This is line 64 + IntermediateToken - (1521:63,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1525:63,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1527:64,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1530:64,3 [15] StringLiterals.cshtml) - Html - This is line 65 + IntermediateToken - (1545:64,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1549:64,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1551:65,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1554:65,3 [15] StringLiterals.cshtml) - Html - This is line 66 + IntermediateToken - (1569:65,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1573:65,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1575:66,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1578:66,3 [15] StringLiterals.cshtml) - Html - This is line 67 + IntermediateToken - (1593:66,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1597:66,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1599:67,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1602:67,3 [15] StringLiterals.cshtml) - Html - This is line 68 + IntermediateToken - (1617:67,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1621:67,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1623:68,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1626:68,3 [15] StringLiterals.cshtml) - Html - This is line 69 + IntermediateToken - (1641:68,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1645:68,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1647:69,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1650:69,3 [15] StringLiterals.cshtml) - Html - This is line 70 + IntermediateToken - (1665:69,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1669:69,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1671:70,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1674:70,3 [15] StringLiterals.cshtml) - Html - This is line 71 + IntermediateToken - (1689:70,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1693:70,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1695:71,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1698:71,3 [15] StringLiterals.cshtml) - Html - This is line 72 + IntermediateToken - (1713:71,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1717:71,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1719:72,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1722:72,3 [15] StringLiterals.cshtml) - Html - This is line 73 + IntermediateToken - (1737:72,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1741:72,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1743:73,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1746:73,3 [15] StringLiterals.cshtml) - Html - This is line 74 + IntermediateToken - (1761:73,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1765:73,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1767:74,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1770:74,3 [15] StringLiterals.cshtml) - Html - This is line 75 + IntermediateToken - (1785:74,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1789:74,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1791:75,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1794:75,3 [15] StringLiterals.cshtml) - Html - This is line 76 + IntermediateToken - (1809:75,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1813:75,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1815:76,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1818:76,3 [15] StringLiterals.cshtml) - Html - This is line 77 + IntermediateToken - (1833:76,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1837:76,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1839:77,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1842:77,3 [15] StringLiterals.cshtml) - Html - This is line 78 + IntermediateToken - (1857:77,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1861:77,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1863:78,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1866:78,3 [15] StringLiterals.cshtml) - Html - This is line 79 + IntermediateToken - (1881:78,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1885:78,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1887:79,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1890:79,3 [15] StringLiterals.cshtml) - Html - This is line 80 + IntermediateToken - (1905:79,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1909:79,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1911:80,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1914:80,3 [15] StringLiterals.cshtml) - Html - This is line 81 + IntermediateToken - (1929:80,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1933:80,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1935:81,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1938:81,3 [15] StringLiterals.cshtml) - Html - This is line 82 + IntermediateToken - (1953:81,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1957:81,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1959:82,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1962:82,3 [15] StringLiterals.cshtml) - Html - This is line 83 + IntermediateToken - (1977:82,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1981:82,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (1983:83,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (1986:83,3 [15] StringLiterals.cshtml) - Html - This is line 84 + IntermediateToken - (2001:83,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2005:83,22 [3] StringLiterals.cshtml) - Html -
        + IntermediateToken - (2009:83,26 [4] StringLiterals.cshtml) - Html - \n\n + Section - - WriteLiteralsToInHere + HtmlContent - (2045:85,32 [2618] StringLiterals.cshtml) + IntermediateToken - (2045:85,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2051:86,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2054:86,7 [21] StringLiterals.cshtml) - Html - This is line 1 nested + IntermediateToken - (2075:86,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2079:86,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2085:87,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2088:87,7 [21] StringLiterals.cshtml) - Html - This is line 2 nested + IntermediateToken - (2109:87,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2113:87,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2119:88,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2122:88,7 [21] StringLiterals.cshtml) - Html - This is line 3 nested + IntermediateToken - (2143:88,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2147:88,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2153:89,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2156:89,7 [21] StringLiterals.cshtml) - Html - This is line 4 nested + IntermediateToken - (2177:89,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2181:89,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2187:90,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2190:90,7 [21] StringLiterals.cshtml) - Html - This is line 5 nested + IntermediateToken - (2211:90,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2215:90,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2221:91,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2224:91,7 [21] StringLiterals.cshtml) - Html - This is line 6 nested + IntermediateToken - (2245:91,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2249:91,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2255:92,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2258:92,7 [21] StringLiterals.cshtml) - Html - This is line 7 nested + IntermediateToken - (2279:92,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2283:92,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2289:93,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2292:93,7 [21] StringLiterals.cshtml) - Html - This is line 8 nested + IntermediateToken - (2313:93,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2317:93,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2323:94,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2326:94,7 [21] StringLiterals.cshtml) - Html - This is line 9 nested + IntermediateToken - (2347:94,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2351:94,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2357:95,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2360:95,7 [22] StringLiterals.cshtml) - Html - This is line 10 nested + IntermediateToken - (2382:95,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2386:95,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2392:96,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2395:96,7 [22] StringLiterals.cshtml) - Html - This is line 11 nested + IntermediateToken - (2417:96,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2421:96,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2427:97,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2430:97,7 [22] StringLiterals.cshtml) - Html - This is line 12 nested + IntermediateToken - (2452:97,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2456:97,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2462:98,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2465:98,7 [22] StringLiterals.cshtml) - Html - This is line 13 nested + IntermediateToken - (2487:98,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2491:98,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2497:99,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2500:99,7 [22] StringLiterals.cshtml) - Html - This is line 14 nested + IntermediateToken - (2522:99,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2526:99,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2532:100,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2535:100,7 [22] StringLiterals.cshtml) - Html - This is line 15 nested + IntermediateToken - (2557:100,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2561:100,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2567:101,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2570:101,7 [22] StringLiterals.cshtml) - Html - This is line 16 nested + IntermediateToken - (2592:101,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2596:101,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2602:102,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2605:102,7 [22] StringLiterals.cshtml) - Html - This is line 17 nested + IntermediateToken - (2627:102,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2631:102,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2637:103,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2640:103,7 [22] StringLiterals.cshtml) - Html - This is line 18 nested + IntermediateToken - (2662:103,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2666:103,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2672:104,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2675:104,7 [22] StringLiterals.cshtml) - Html - This is line 19 nested + IntermediateToken - (2697:104,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2701:104,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2707:105,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2710:105,7 [22] StringLiterals.cshtml) - Html - This is line 20 nested + IntermediateToken - (2732:105,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2736:105,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2742:106,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2745:106,7 [22] StringLiterals.cshtml) - Html - This is line 21 nested + IntermediateToken - (2767:106,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2771:106,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2777:107,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2780:107,7 [22] StringLiterals.cshtml) - Html - This is line 22 nested + IntermediateToken - (2802:107,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2806:107,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2812:108,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2815:108,7 [22] StringLiterals.cshtml) - Html - This is line 23 nested + IntermediateToken - (2837:108,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2841:108,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2847:109,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2850:109,7 [22] StringLiterals.cshtml) - Html - This is line 24 nested + IntermediateToken - (2872:109,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2876:109,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2882:110,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2885:110,7 [22] StringLiterals.cshtml) - Html - This is line 25 nested + IntermediateToken - (2907:110,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2911:110,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2917:111,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2920:111,7 [22] StringLiterals.cshtml) - Html - This is line 26 nested + IntermediateToken - (2942:111,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2946:111,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2952:112,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2955:112,7 [22] StringLiterals.cshtml) - Html - This is line 27 nested + IntermediateToken - (2977:112,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2981:112,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (2987:113,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (2990:113,7 [22] StringLiterals.cshtml) - Html - This is line 28 nested + IntermediateToken - (3012:113,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3016:113,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3022:114,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3025:114,7 [22] StringLiterals.cshtml) - Html - This is line 29 nested + IntermediateToken - (3047:114,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3051:114,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3057:115,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3060:115,7 [22] StringLiterals.cshtml) - Html - This is line 30 nested + IntermediateToken - (3082:115,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3086:115,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3092:116,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3095:116,7 [22] StringLiterals.cshtml) - Html - This is line 31 nested + IntermediateToken - (3117:116,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3121:116,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3127:117,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3130:117,7 [22] StringLiterals.cshtml) - Html - This is line 32 nested + IntermediateToken - (3152:117,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3156:117,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3162:118,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3165:118,7 [22] StringLiterals.cshtml) - Html - This is line 33 nested + IntermediateToken - (3187:118,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3191:118,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3197:119,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3200:119,7 [22] StringLiterals.cshtml) - Html - This is line 34 nested + IntermediateToken - (3222:119,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3226:119,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3232:120,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3235:120,7 [22] StringLiterals.cshtml) - Html - This is line 35 nested + IntermediateToken - (3257:120,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3261:120,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3267:121,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3270:121,7 [22] StringLiterals.cshtml) - Html - This is line 36 nested + IntermediateToken - (3292:121,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3296:121,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3302:122,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3305:122,7 [22] StringLiterals.cshtml) - Html - This is line 37 nested + IntermediateToken - (3327:122,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3331:122,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3337:123,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3340:123,7 [22] StringLiterals.cshtml) - Html - This is line 38 nested + IntermediateToken - (3362:123,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3366:123,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3372:124,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3375:124,7 [22] StringLiterals.cshtml) - Html - This is line 39 nested + IntermediateToken - (3397:124,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3401:124,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3407:125,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3410:125,7 [22] StringLiterals.cshtml) - Html - This is line 40 nested + IntermediateToken - (3432:125,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3436:125,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3442:126,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3445:126,7 [22] StringLiterals.cshtml) - Html - This is line 41 nested + IntermediateToken - (3467:126,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3471:126,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3477:127,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3480:127,7 [22] StringLiterals.cshtml) - Html - This is line 42 nested + IntermediateToken - (3502:127,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3506:127,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3512:128,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3515:128,7 [22] StringLiterals.cshtml) - Html - This is line 43 nested + IntermediateToken - (3537:128,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3541:128,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3547:129,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3550:129,7 [22] StringLiterals.cshtml) - Html - This is line 44 nested + IntermediateToken - (3572:129,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3576:129,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3582:130,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3585:130,7 [22] StringLiterals.cshtml) - Html - This is line 45 nested + IntermediateToken - (3607:130,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3611:130,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3617:131,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3620:131,7 [22] StringLiterals.cshtml) - Html - This is line 46 nested + IntermediateToken - (3642:131,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3646:131,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3652:132,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3655:132,7 [22] StringLiterals.cshtml) - Html - This is line 47 nested + IntermediateToken - (3677:132,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3681:132,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3687:133,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3690:133,7 [22] StringLiterals.cshtml) - Html - This is line 48 nested + IntermediateToken - (3712:133,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3716:133,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3722:134,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3725:134,7 [22] StringLiterals.cshtml) - Html - This is line 49 nested + IntermediateToken - (3747:134,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3751:134,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3757:135,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3760:135,7 [22] StringLiterals.cshtml) - Html - This is line 50 nested + IntermediateToken - (3782:135,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3786:135,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3792:136,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3795:136,7 [22] StringLiterals.cshtml) - Html - This is line 51 nested + IntermediateToken - (3817:136,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3821:136,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3827:137,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3830:137,7 [22] StringLiterals.cshtml) - Html - This is line 52 nested + IntermediateToken - (3852:137,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3856:137,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3862:138,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3865:138,7 [22] StringLiterals.cshtml) - Html - This is line 53 nested + IntermediateToken - (3887:138,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3891:138,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3897:139,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3900:139,7 [22] StringLiterals.cshtml) - Html - This is line 54 nested + IntermediateToken - (3922:139,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3926:139,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3932:140,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3935:140,7 [22] StringLiterals.cshtml) - Html - This is line 55 nested + IntermediateToken - (3957:140,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3961:140,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (3967:141,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3970:141,7 [22] StringLiterals.cshtml) - Html - This is line 56 nested + IntermediateToken - (3992:141,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (3996:141,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4002:142,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4005:142,7 [22] StringLiterals.cshtml) - Html - This is line 57 nested + IntermediateToken - (4027:142,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4031:142,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4037:143,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4040:143,7 [22] StringLiterals.cshtml) - Html - This is line 58 nested + IntermediateToken - (4062:143,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4066:143,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4072:144,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4075:144,7 [22] StringLiterals.cshtml) - Html - This is line 59 nested + IntermediateToken - (4097:144,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4101:144,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4107:145,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4110:145,7 [22] StringLiterals.cshtml) - Html - This is line 60 nested + IntermediateToken - (4132:145,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4136:145,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4142:146,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4145:146,7 [22] StringLiterals.cshtml) - Html - This is line 61 nested + IntermediateToken - (4167:146,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4171:146,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4177:147,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4180:147,7 [22] StringLiterals.cshtml) - Html - This is line 62 nested + IntermediateToken - (4202:147,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4206:147,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4212:148,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4215:148,7 [22] StringLiterals.cshtml) - Html - This is line 63 nested + IntermediateToken - (4237:148,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4241:148,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4247:149,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4250:149,7 [22] StringLiterals.cshtml) - Html - This is line 64 nested + IntermediateToken - (4272:149,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4276:149,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4282:150,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4285:150,7 [22] StringLiterals.cshtml) - Html - This is line 65 nested + IntermediateToken - (4307:150,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4311:150,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4317:151,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4320:151,7 [22] StringLiterals.cshtml) - Html - This is line 66 nested + IntermediateToken - (4342:151,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4346:151,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4352:152,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4355:152,7 [22] StringLiterals.cshtml) - Html - This is line 67 nested + IntermediateToken - (4377:152,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4381:152,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4387:153,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4390:153,7 [22] StringLiterals.cshtml) - Html - This is line 68 nested + IntermediateToken - (4412:153,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4416:153,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4422:154,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4425:154,7 [22] StringLiterals.cshtml) - Html - This is line 69 nested + IntermediateToken - (4447:154,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4451:154,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4457:155,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4460:155,7 [22] StringLiterals.cshtml) - Html - This is line 70 nested + IntermediateToken - (4482:155,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4486:155,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4492:156,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4495:156,7 [22] StringLiterals.cshtml) - Html - This is line 71 nested + IntermediateToken - (4517:156,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4521:156,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4527:157,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4530:157,7 [22] StringLiterals.cshtml) - Html - This is line 72 nested + IntermediateToken - (4552:157,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4556:157,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4562:158,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4565:158,7 [22] StringLiterals.cshtml) - Html - This is line 73 nested + IntermediateToken - (4587:158,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4591:158,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4597:159,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4600:159,7 [22] StringLiterals.cshtml) - Html - This is line 74 nested + IntermediateToken - (4622:159,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4626:159,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4632:160,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4635:160,7 [22] StringLiterals.cshtml) - Html - This is line 75 nested + IntermediateToken - (4657:160,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4661:160,33 [2] StringLiterals.cshtml) - Html - \n + HtmlContent - (4666:162,0 [1026] StringLiterals.cshtml) + IntermediateToken - (4666:162,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4669:162,3 [14] StringLiterals.cshtml) - Html - This is line 1 + IntermediateToken - (4683:162,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4687:162,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4689:163,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4692:163,3 [14] StringLiterals.cshtml) - Html - This is line 2 + IntermediateToken - (4706:163,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4710:163,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4712:164,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4715:164,3 [14] StringLiterals.cshtml) - Html - This is line 3 + IntermediateToken - (4729:164,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4733:164,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4735:165,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4738:165,3 [14] StringLiterals.cshtml) - Html - This is line 4 + IntermediateToken - (4752:165,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4756:165,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4758:166,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4761:166,3 [14] StringLiterals.cshtml) - Html - This is line 5 + IntermediateToken - (4775:166,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4779:166,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4781:167,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4784:167,3 [14] StringLiterals.cshtml) - Html - This is line 6 + IntermediateToken - (4798:167,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4802:167,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4804:168,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4807:168,3 [14] StringLiterals.cshtml) - Html - This is line 7 + IntermediateToken - (4821:168,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4825:168,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4827:169,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4830:169,3 [14] StringLiterals.cshtml) - Html - This is line 8 + IntermediateToken - (4844:169,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4848:169,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4850:170,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4853:170,3 [14] StringLiterals.cshtml) - Html - This is line 9 + IntermediateToken - (4867:170,17 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4871:170,21 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4873:171,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4876:171,3 [15] StringLiterals.cshtml) - Html - This is line 10 + IntermediateToken - (4891:171,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4895:171,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4897:172,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4900:172,3 [15] StringLiterals.cshtml) - Html - This is line 11 + IntermediateToken - (4915:172,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4919:172,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4921:173,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4924:173,3 [15] StringLiterals.cshtml) - Html - This is line 12 + IntermediateToken - (4939:173,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4943:173,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4945:174,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4948:174,3 [15] StringLiterals.cshtml) - Html - This is line 13 + IntermediateToken - (4963:174,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4967:174,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4969:175,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4972:175,3 [15] StringLiterals.cshtml) - Html - This is line 14 + IntermediateToken - (4987:175,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4991:175,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (4993:176,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (4996:176,3 [15] StringLiterals.cshtml) - Html - This is line 15 + IntermediateToken - (5011:176,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5015:176,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5017:177,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5020:177,3 [15] StringLiterals.cshtml) - Html - This is line 16 + IntermediateToken - (5035:177,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5039:177,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5041:178,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5044:178,3 [15] StringLiterals.cshtml) - Html - This is line 17 + IntermediateToken - (5059:178,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5063:178,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5065:179,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5068:179,3 [15] StringLiterals.cshtml) - Html - This is line 18 + IntermediateToken - (5083:179,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5087:179,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5089:180,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5092:180,3 [15] StringLiterals.cshtml) - Html - This is line 19 + IntermediateToken - (5107:180,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5111:180,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5113:181,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5116:181,3 [15] StringLiterals.cshtml) - Html - This is line 20 + IntermediateToken - (5131:181,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5135:181,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5137:182,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5140:182,3 [15] StringLiterals.cshtml) - Html - This is line 21 + IntermediateToken - (5155:182,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5159:182,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5161:183,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5164:183,3 [15] StringLiterals.cshtml) - Html - This is line 22 + IntermediateToken - (5179:183,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5183:183,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5185:184,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5188:184,3 [15] StringLiterals.cshtml) - Html - This is line 23 + IntermediateToken - (5203:184,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5207:184,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5209:185,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5212:185,3 [15] StringLiterals.cshtml) - Html - This is line 24 + IntermediateToken - (5227:185,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5231:185,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5233:186,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5236:186,3 [15] StringLiterals.cshtml) - Html - This is line 25 + IntermediateToken - (5251:186,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5255:186,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5257:187,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5260:187,3 [15] StringLiterals.cshtml) - Html - This is line 26 + IntermediateToken - (5275:187,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5279:187,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5281:188,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5284:188,3 [15] StringLiterals.cshtml) - Html - This is line 27 + IntermediateToken - (5299:188,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5303:188,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5305:189,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5308:189,3 [15] StringLiterals.cshtml) - Html - This is line 28 + IntermediateToken - (5323:189,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5327:189,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5329:190,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5332:190,3 [15] StringLiterals.cshtml) - Html - This is line 29 + IntermediateToken - (5347:190,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5351:190,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5353:191,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5356:191,3 [15] StringLiterals.cshtml) - Html - This is line 30 + IntermediateToken - (5371:191,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5375:191,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5377:192,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5380:192,3 [15] StringLiterals.cshtml) - Html - This is line 31 + IntermediateToken - (5395:192,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5399:192,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5401:193,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5404:193,3 [15] StringLiterals.cshtml) - Html - This is line 32 + IntermediateToken - (5419:193,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5423:193,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5425:194,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5428:194,3 [15] StringLiterals.cshtml) - Html - This is line 33 + IntermediateToken - (5443:194,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5447:194,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5449:195,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5452:195,3 [15] StringLiterals.cshtml) - Html - This is line 34 + IntermediateToken - (5467:195,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5471:195,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5473:196,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5476:196,3 [15] StringLiterals.cshtml) - Html - This is line 35 + IntermediateToken - (5491:196,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5495:196,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5497:197,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5500:197,3 [15] StringLiterals.cshtml) - Html - This is line 36 + IntermediateToken - (5515:197,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5519:197,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5521:198,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5524:198,3 [15] StringLiterals.cshtml) - Html - This is line 37 + IntermediateToken - (5539:198,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5543:198,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5545:199,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5548:199,3 [15] StringLiterals.cshtml) - Html - This is line 38 + IntermediateToken - (5563:199,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5567:199,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5569:200,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5572:200,3 [15] StringLiterals.cshtml) - Html - This is line 39 + IntermediateToken - (5587:200,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5591:200,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5593:201,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5596:201,3 [15] StringLiterals.cshtml) - Html - This is line 40 + IntermediateToken - (5611:201,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5615:201,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5617:202,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5620:202,3 [15] StringLiterals.cshtml) - Html - This is line 41 + IntermediateToken - (5635:202,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5639:202,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5641:203,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5644:203,3 [15] StringLiterals.cshtml) - Html - This is line 42 + IntermediateToken - (5659:203,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5663:203,22 [2] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5665:204,0 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5668:204,3 [15] StringLiterals.cshtml) - Html - This is line 43 + IntermediateToken - (5683:204,18 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5687:204,22 [5] StringLiterals.cshtml) - Html - hi!\n + Section - - WriteLiteralsToInHereAlso + HtmlContent - (5728:205,36 [1023] StringLiterals.cshtml) + IntermediateToken - (5728:205,36 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5734:206,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5737:206,7 [21] StringLiterals.cshtml) - Html - This is line 1 nested + IntermediateToken - (5758:206,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5762:206,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5768:207,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5771:207,7 [21] StringLiterals.cshtml) - Html - This is line 2 nested + IntermediateToken - (5792:207,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5796:207,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5802:208,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5805:208,7 [21] StringLiterals.cshtml) - Html - This is line 3 nested + IntermediateToken - (5826:208,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5830:208,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5836:209,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5839:209,7 [21] StringLiterals.cshtml) - Html - This is line 4 nested + IntermediateToken - (5860:209,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5864:209,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5870:210,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5873:210,7 [21] StringLiterals.cshtml) - Html - This is line 5 nested + IntermediateToken - (5894:210,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5898:210,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5904:211,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5907:211,7 [21] StringLiterals.cshtml) - Html - This is line 6 nested + IntermediateToken - (5928:211,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5932:211,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5938:212,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5941:212,7 [21] StringLiterals.cshtml) - Html - This is line 7 nested + IntermediateToken - (5962:212,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5966:212,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (5972:213,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (5975:213,7 [21] StringLiterals.cshtml) - Html - This is line 8 nested + IntermediateToken - (5996:213,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6000:213,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6006:214,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6009:214,7 [21] StringLiterals.cshtml) - Html - This is line 9 nested + IntermediateToken - (6030:214,28 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6034:214,32 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6040:215,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6043:215,7 [22] StringLiterals.cshtml) - Html - This is line 10 nested + IntermediateToken - (6065:215,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6069:215,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6075:216,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6078:216,7 [22] StringLiterals.cshtml) - Html - This is line 11 nested + IntermediateToken - (6100:216,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6104:216,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6110:217,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6113:217,7 [22] StringLiterals.cshtml) - Html - This is line 12 nested + IntermediateToken - (6135:217,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6139:217,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6145:218,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6148:218,7 [22] StringLiterals.cshtml) - Html - This is line 13 nested + IntermediateToken - (6170:218,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6174:218,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6180:219,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6183:219,7 [22] StringLiterals.cshtml) - Html - This is line 14 nested + IntermediateToken - (6205:219,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6209:219,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6215:220,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6218:220,7 [22] StringLiterals.cshtml) - Html - This is line 15 nested + IntermediateToken - (6240:220,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6244:220,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6250:221,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6253:221,7 [22] StringLiterals.cshtml) - Html - This is line 16 nested + IntermediateToken - (6275:221,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6279:221,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6285:222,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6288:222,7 [22] StringLiterals.cshtml) - Html - This is line 17 nested + IntermediateToken - (6310:222,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6314:222,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6320:223,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6323:223,7 [22] StringLiterals.cshtml) - Html - This is line 18 nested + IntermediateToken - (6345:223,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6349:223,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6355:224,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6358:224,7 [22] StringLiterals.cshtml) - Html - This is line 19 nested + IntermediateToken - (6380:224,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6384:224,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6390:225,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6393:225,7 [22] StringLiterals.cshtml) - Html - This is line 20 nested + IntermediateToken - (6415:225,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6419:225,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6425:226,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6428:226,7 [22] StringLiterals.cshtml) - Html - This is line 21 nested + IntermediateToken - (6450:226,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6454:226,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6460:227,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6463:227,7 [22] StringLiterals.cshtml) - Html - This is line 22 nested + IntermediateToken - (6485:227,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6489:227,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6495:228,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6498:228,7 [22] StringLiterals.cshtml) - Html - This is line 23 nested + IntermediateToken - (6520:228,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6524:228,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6530:229,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6533:229,7 [22] StringLiterals.cshtml) - Html - This is line 24 nested + IntermediateToken - (6555:229,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6559:229,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6565:230,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6568:230,7 [22] StringLiterals.cshtml) - Html - This is line 25 nested + IntermediateToken - (6590:230,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6594:230,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6600:231,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6603:231,7 [22] StringLiterals.cshtml) - Html - This is line 26 nested + IntermediateToken - (6625:231,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6629:231,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6635:232,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6638:232,7 [22] StringLiterals.cshtml) - Html - This is line 27 nested + IntermediateToken - (6660:232,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6664:232,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6670:233,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6673:233,7 [22] StringLiterals.cshtml) - Html - This is line 28 nested + IntermediateToken - (6695:233,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6699:233,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6705:234,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6708:234,7 [22] StringLiterals.cshtml) - Html - This is line 29 nested + IntermediateToken - (6730:234,29 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6734:234,33 [6] StringLiterals.cshtml) - Html - \n + IntermediateToken - (6740:235,4 [2] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6743:235,7 [2] StringLiterals.cshtml) - Html - 30 + IntermediateToken - (6745:235,9 [4] StringLiterals.cshtml) - Html -

        + IntermediateToken - (6749:235,13 [2] StringLiterals.cshtml) - Html - \n + HtmlContent - (6752:236,1 [1] StringLiterals.cshtml) + IntermediateToken - (6752:236,1 [1] StringLiterals.cshtml) - Html - ! diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml new file mode 100644 index 0000000000..c653cff1b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml @@ -0,0 +1,19 @@ +@addTagHelper *, TestAssembly + +
          +
            + + + +
            +
            + +
              +
                + + + +
                +
                \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.codegen.cs new file mode 100644 index 0000000000..38be520e24 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.codegen.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_DesignTime + { + #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::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.ListItems = items; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.ArrayItems = items; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.Event1 = doSomething(); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.Event2 = doSomething(); + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper.StringProperty1 = "value"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __TestNamespace_CatchAllTagHelper.StringProperty2 = "value"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..1ee160ff70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.diagnostics.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property 'System.Collections.Generic.List TestNamespace.CatchAllTagHelper.ListItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'System.Collections.Generic.List TestNamespace.CatchAllTagHelper.ListItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'System.String[] TestNamespace.CatchAllTagHelper.ArrayItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'System.String[] TestNamespace.CatchAllTagHelper.ArrayItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'string TestNamespace.CatchAllTagHelper.StringProperty1' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt new file mode 100644 index 0000000000..5315700a1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt @@ -0,0 +1,140 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] SymbolBoundAttributes.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [255] SymbolBoundAttributes.cshtml) + IntermediateToken - (29:0,29 [4] SymbolBoundAttributes.cshtml) - Html - \n\n + IntermediateToken - (33:2,0 [3] SymbolBoundAttributes.cshtml) - Html -
                  + IntermediateToken - (52:2,19 [5] SymbolBoundAttributes.cshtml) - Html -
                + IntermediateToken - (57:2,24 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (59:3,0 [3] SymbolBoundAttributes.cshtml) - Html -
                  + IntermediateToken - (80:3,21 [5] SymbolBoundAttributes.cshtml) - Html -
                + IntermediateToken - (85:3,26 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (87:4,0 [7] SymbolBoundAttributes.cshtml) - Html - + IntermediateToken - (136:4,49 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (138:5,0 [7] SymbolBoundAttributes.cshtml) - Html - + IntermediateToken - (188:5,50 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (190:6,0 [9] SymbolBoundAttributes.cshtml) - Html - + IntermediateToken - (232:7,11 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (234:8,0 [4] SymbolBoundAttributes.cshtml) - Html -
                + IntermediateToken - (246:8,12 [6] SymbolBoundAttributes.cshtml) - Html -
                + IntermediateToken - (252:8,18 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (254:9,0 [4] SymbolBoundAttributes.cshtml) - Html -
                + IntermediateToken - (274:9,20 [6] SymbolBoundAttributes.cshtml) - Html -
                + IntermediateToken - (280:9,26 [4] SymbolBoundAttributes.cshtml) - Html - \n\n + TagHelper - (284:11,0 [45] SymbolBoundAttributes.cshtml) - ul - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (302:11,18 [5] SymbolBoundAttributes.cshtml) - [item] - System.Collections.Generic.List TestNamespace.CatchAllTagHelper.ListItems - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (302:11,18 [5] SymbolBoundAttributes.cshtml) - CSharp - items + DefaultTagHelperHtmlAttribute - - [item] - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (317:11,33 [5] SymbolBoundAttributes.cshtml) + IntermediateToken - (317:11,33 [5] SymbolBoundAttributes.cshtml) - Html - items + DefaultTagHelperExecute - + HtmlContent - (329:11,45 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (329:11,45 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (331:12,0 [49] SymbolBoundAttributes.cshtml) - ul - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (351:12,20 [5] SymbolBoundAttributes.cshtml) - [(item)] - System.String[] TestNamespace.CatchAllTagHelper.ArrayItems - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (351:12,20 [5] SymbolBoundAttributes.cshtml) - CSharp - items + DefaultTagHelperHtmlAttribute - - [(item)] - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (368:12,37 [5] SymbolBoundAttributes.cshtml) + IntermediateToken - (368:12,37 [5] SymbolBoundAttributes.cshtml) - Html - items + DefaultTagHelperExecute - + HtmlContent - (380:12,49 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (380:12,49 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (382:13,0 [79] SymbolBoundAttributes.cshtml) - button - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (444:13,62 [8] SymbolBoundAttributes.cshtml) + IntermediateToken - (444:13,62 [8] SymbolBoundAttributes.cshtml) - Html - Click Me + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (405:13,23 [13] SymbolBoundAttributes.cshtml) - (click) - System.Action TestNamespace.CatchAllTagHelper.Event1 - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (405:13,23 [13] SymbolBoundAttributes.cshtml) - CSharp - doSomething() + DefaultTagHelperHtmlAttribute - - (click) - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (429:13,47 [13] SymbolBoundAttributes.cshtml) + IntermediateToken - (429:13,47 [13] SymbolBoundAttributes.cshtml) - Html - doSomething() + DefaultTagHelperExecute - + HtmlContent - (461:13,79 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (461:13,79 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (463:14,0 [81] SymbolBoundAttributes.cshtml) - button - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (527:14,64 [8] SymbolBoundAttributes.cshtml) + IntermediateToken - (527:14,64 [8] SymbolBoundAttributes.cshtml) - Html - Click Me + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (487:14,24 [13] SymbolBoundAttributes.cshtml) - (^click) - System.Action TestNamespace.CatchAllTagHelper.Event2 - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (487:14,24 [13] SymbolBoundAttributes.cshtml) - CSharp - doSomething() + DefaultTagHelperHtmlAttribute - - (^click) - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (512:14,49 [13] SymbolBoundAttributes.cshtml) + IntermediateToken - (512:14,49 [13] SymbolBoundAttributes.cshtml) - Html - doSomething() + DefaultTagHelperExecute - + HtmlContent - (544:14,81 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (544:14,81 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (546:15,0 [67] SymbolBoundAttributes.cshtml) - template - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (600:15,54 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (600:15,54 [2] SymbolBoundAttributes.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (574:15,28 [5] SymbolBoundAttributes.cshtml) - *something - string TestNamespace.CatchAllTagHelper.StringProperty1 - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (574:15,28 [5] SymbolBoundAttributes.cshtml) + IntermediateToken - (574:15,28 [5] SymbolBoundAttributes.cshtml) - Html - value + DefaultTagHelperHtmlAttribute - - *something - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (593:15,47 [5] SymbolBoundAttributes.cshtml) + IntermediateToken - (593:15,47 [5] SymbolBoundAttributes.cshtml) - Html - value + DefaultTagHelperExecute - + HtmlContent - (613:16,11 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (613:16,11 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (615:17,0 [33] SymbolBoundAttributes.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperHtmlAttribute - - #localminimized - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (648:17,33 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (648:17,33 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (650:18,0 [47] SymbolBoundAttributes.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (669:18,19 [5] SymbolBoundAttributes.cshtml) - #local - string TestNamespace.CatchAllTagHelper.StringProperty2 - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (669:18,19 [5] SymbolBoundAttributes.cshtml) + IntermediateToken - (669:18,19 [5] SymbolBoundAttributes.cshtml) - Html - value + DefaultTagHelperHtmlAttribute - - #local - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (684:18,34 [5] SymbolBoundAttributes.cshtml) + IntermediateToken - (684:18,34 [5] SymbolBoundAttributes.cshtml) - Html - value + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.mappings.txt new file mode 100644 index 0000000000..d7873fb744 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml) +|*, TestAssembly| +Generated Location: (1044:18,38 [15] ) +|*, TestAssembly| + +Source Location: (302:11,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml) +|items| +Generated Location: (1699:36,46 [5] ) +|items| + +Source Location: (351:12,20 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml) +|items| +Generated Location: (2106:45,47 [5] ) +|items| + +Source Location: (405:13,23 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml) +|doSomething()| +Generated Location: (2509:54,43 [13] ) +|doSomething()| + +Source Location: (487:14,24 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml) +|doSomething()| +Generated Location: (2920:63,43 [13] ) +|doSomething()| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..697cafafff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.codegen.cs @@ -0,0 +1,207 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "911fabc92d64c2732fa0cff025d454076241edb8" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"911fabc92d64c2732fa0cff025d454076241edb8", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("[item]", new global::Microsoft.AspNetCore.Html.HtmlString("items"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("[(item)]", new global::Microsoft.AspNetCore.Html.HtmlString("items"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("(click)", new global::Microsoft.AspNetCore.Html.HtmlString("doSomething()"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("(^click)", new global::Microsoft.AspNetCore.Html.HtmlString("doSomething()"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("*something", "value", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("*something", new global::Microsoft.AspNetCore.Html.HtmlString("value"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_6 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("#local", "value", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_7 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("#local", new global::Microsoft.AspNetCore.Html.HtmlString("value"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.CatchAllTagHelper __TestNamespace_CatchAllTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n
                  \r\n
                    \r\n\r\n\r\n\r\n
                    \r\n
                    \r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("ul", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.ListItems = items; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("[item]", __TestNamespace_CatchAllTagHelper.ListItems, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("ul", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.ArrayItems = items; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("[(item)]", __TestNamespace_CatchAllTagHelper.ArrayItems, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("button", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Click Me"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); +#nullable restore +#line 14 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.Event1 = doSomething(); + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("(click)", __TestNamespace_CatchAllTagHelper.Event1, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("button", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Click Me"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes.cshtml" +__TestNamespace_CatchAllTagHelper.Event2 = doSomething(); + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("(^click)", __TestNamespace_CatchAllTagHelper.Event2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("template", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n"); + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + __TestNamespace_CatchAllTagHelper.StringProperty1 = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("#localminimized", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_CatchAllTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_CatchAllTagHelper); + BeginWriteTagHelperAttribute(); + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("bound", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.Minimized); + __TestNamespace_CatchAllTagHelper.StringProperty2 = (string)__tagHelperAttribute_6.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_7); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.diagnostics.txt new file mode 100644 index 0000000000..1ee160ff70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.diagnostics.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property 'System.Collections.Generic.List TestNamespace.CatchAllTagHelper.ListItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'System.Collections.Generic.List TestNamespace.CatchAllTagHelper.ListItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'System.String[] TestNamespace.CatchAllTagHelper.ArrayItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'System.String[] TestNamespace.CatchAllTagHelper.ArrayItems' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property 'string TestNamespace.CatchAllTagHelper.StringProperty1' on tag helper 'TestNamespace.CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt new file mode 100644 index 0000000000..ee4dc7af83 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_Runtime.ir.txt @@ -0,0 +1,126 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - [item] - items - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - [(item)] - items - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - (click) - doSomething() - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - (^click) - doSomething() - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_4 - *something - value - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_5 - *something - value - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_6 - #local - value - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_7 - #local - value - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.CatchAllTagHelper - __TestNamespace_CatchAllTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:1,0 [253] SymbolBoundAttributes.cshtml) + IntermediateToken - (31:1,0 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (33:2,0 [3] SymbolBoundAttributes.cshtml) - Html -
                      + IntermediateToken - (52:2,19 [5] SymbolBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (57:2,24 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (59:3,0 [3] SymbolBoundAttributes.cshtml) - Html -
                      + IntermediateToken - (80:3,21 [5] SymbolBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (85:3,26 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (87:4,0 [7] SymbolBoundAttributes.cshtml) - Html - + IntermediateToken - (136:4,49 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (138:5,0 [7] SymbolBoundAttributes.cshtml) - Html - + IntermediateToken - (188:5,50 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (190:6,0 [9] SymbolBoundAttributes.cshtml) - Html - + IntermediateToken - (232:7,11 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (234:8,0 [4] SymbolBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (246:8,12 [6] SymbolBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (252:8,18 [2] SymbolBoundAttributes.cshtml) - Html - \n + IntermediateToken - (254:9,0 [4] SymbolBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (274:9,20 [6] SymbolBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (280:9,26 [4] SymbolBoundAttributes.cshtml) - Html - \n\n + TagHelper - (284:11,0 [45] SymbolBoundAttributes.cshtml) - ul - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (302:11,18 [5] SymbolBoundAttributes.cshtml) - [item] - System.Collections.Generic.List TestNamespace.CatchAllTagHelper.ListItems - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (302:11,18 [5] SymbolBoundAttributes.cshtml) - CSharp - items + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (329:11,45 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (329:11,45 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (331:12,0 [49] SymbolBoundAttributes.cshtml) - ul - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (351:12,20 [5] SymbolBoundAttributes.cshtml) - [(item)] - System.String[] TestNamespace.CatchAllTagHelper.ArrayItems - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (351:12,20 [5] SymbolBoundAttributes.cshtml) - CSharp - items + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + HtmlContent - (380:12,49 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (380:12,49 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (382:13,0 [79] SymbolBoundAttributes.cshtml) - button - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (444:13,62 [8] SymbolBoundAttributes.cshtml) + IntermediateToken - (444:13,62 [8] SymbolBoundAttributes.cshtml) - Html - Click Me + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (405:13,23 [13] SymbolBoundAttributes.cshtml) - (click) - System.Action TestNamespace.CatchAllTagHelper.Event1 - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (405:13,23 [13] SymbolBoundAttributes.cshtml) - CSharp - doSomething() + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (461:13,79 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (461:13,79 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (463:14,0 [81] SymbolBoundAttributes.cshtml) - button - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (527:14,64 [8] SymbolBoundAttributes.cshtml) + IntermediateToken - (527:14,64 [8] SymbolBoundAttributes.cshtml) - Html - Click Me + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperProperty - (487:14,24 [13] SymbolBoundAttributes.cshtml) - (^click) - System.Action TestNamespace.CatchAllTagHelper.Event2 - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (487:14,24 [13] SymbolBoundAttributes.cshtml) - CSharp - doSomething() + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + HtmlContent - (544:14,81 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (544:14,81 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (546:15,0 [67] SymbolBoundAttributes.cshtml) - template - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (600:15,54 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (600:15,54 [2] SymbolBoundAttributes.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + PreallocatedTagHelperProperty - (574:15,28 [5] SymbolBoundAttributes.cshtml) - __tagHelperAttribute_4 - *something - StringProperty1 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + DefaultTagHelperExecute - + HtmlContent - (613:16,11 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (613:16,11 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (615:17,0 [33] SymbolBoundAttributes.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + DefaultTagHelperHtmlAttribute - - #localminimized - HtmlAttributeValueStyle.Minimized + DefaultTagHelperExecute - + HtmlContent - (648:17,33 [2] SymbolBoundAttributes.cshtml) + IntermediateToken - (648:17,33 [2] SymbolBoundAttributes.cshtml) - Html - \n + TagHelper - (650:18,0 [47] SymbolBoundAttributes.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.CatchAllTagHelper + DefaultTagHelperHtmlAttribute - - bound - HtmlAttributeValueStyle.Minimized + PreallocatedTagHelperProperty - (669:18,19 [5] SymbolBoundAttributes.cshtml) - __tagHelperAttribute_6 - #local - StringProperty2 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_7 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml new file mode 100644 index 0000000000..12d0afd197 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml @@ -0,0 +1,20 @@ +@addTagHelper "*, TestAssembly" + +@{ + var code = "some code"; +} + +@section MySection { +
                    + + In None ContentBehavior. + Some buffered values with @code + +
                    + + @section nestedsection { +
                    + +
                    + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.codegen.cs new file mode 100644 index 0000000000..eeb070f4e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.codegen.cs @@ -0,0 +1,98 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_DesignTime + { + #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::TestNamespace.MyTagHelper __TestNamespace_MyTagHelper; + private global::TestNamespace.NestedTagHelper __TestNamespace_NestedTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" +global::System.Object MySection = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 15 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" +global::System.Object nestedsection = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + + var code = "some code"; + +#line default +#line hidden +#nullable disable + DefineSection("MySection", async(__razor_section_writer) => { +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + __o = code; + +#line default +#line hidden +#nullable disable + __TestNamespace_NestedTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_MyTagHelper = CreateTagHelper(); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + __TestNamespace_MyTagHelper.BoundProperty = string.Empty; +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_NestedTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + ); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.diagnostics.txt new file mode 100644 index 0000000000..0efe33796f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml(15,5): Error RZ2002: Section blocks ("@section Header { ... }") cannot be nested. Only one level of section blocks are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.ir.txt new file mode 100644 index 0000000000..1f073cdb22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.ir.txt @@ -0,0 +1,80 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.MyTagHelper - __TestNamespace_MyTagHelper + FieldDeclaration - - private - global::TestNamespace.NestedTagHelper - __TestNamespace_NestedTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] TagHelpersInSection.cshtml) - "*, TestAssembly" + DirectiveToken - (82:6,9 [9] TagHelpersInSection.cshtml) - MySection + DirectiveToken - (388:14,13 [13] TagHelpersInSection.cshtml) - nestedsection + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] TagHelpersInSection.cshtml) + IntermediateToken - (31:0,31 [4] TagHelpersInSection.cshtml) - Html - \n\n + CSharpCode - (37:2,2 [31] TagHelpersInSection.cshtml) + IntermediateToken - (37:2,2 [31] TagHelpersInSection.cshtml) - CSharp - \n var code = "some code";\n + HtmlContent - (71:5,0 [2] TagHelpersInSection.cshtml) + IntermediateToken - (71:5,0 [2] TagHelpersInSection.cshtml) - Html - \n + Section - - MySection + HtmlContent - (93:6,20 [21] TagHelpersInSection.cshtml) + IntermediateToken - (93:6,20 [6] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (99:7,4 [4] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (104:7,9 [10] TagHelpersInSection.cshtml) - Html - \n + TagHelper - (114:8,8 [245] TagHelpersInSection.cshtml) - mytaghelper - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (217:8,111 [52] TagHelpersInSection.cshtml) + IntermediateToken - (217:8,111 [52] TagHelpersInSection.cshtml) - Html - \n In None ContentBehavior.\n + TagHelper - (269:10,12 [66] TagHelpersInSection.cshtml) - nestedtaghelper - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (286:10,29 [26] TagHelpersInSection.cshtml) + IntermediateToken - (286:10,29 [26] TagHelpersInSection.cshtml) - Html - Some buffered values with + CSharpExpression - (313:10,56 [4] TagHelpersInSection.cshtml) + IntermediateToken - (313:10,56 [4] TagHelpersInSection.cshtml) - CSharp - code + DefaultTagHelperCreate - - TestNamespace.NestedTagHelper + DefaultTagHelperExecute - + HtmlContent - (335:10,78 [10] TagHelpersInSection.cshtml) + IntermediateToken - (335:10,78 [10] TagHelpersInSection.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.MyTagHelper + DefaultTagHelperProperty - (142:8,36 [27] TagHelpersInSection.cshtml) - boundproperty - string TestNamespace.MyTagHelper.BoundProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (142:8,36 [14] TagHelpersInSection.cshtml) + IntermediateToken - (142:8,36 [7] TagHelpersInSection.cshtml) - Html - Current + IntermediateToken - (149:8,43 [6] TagHelpersInSection.cshtml) - Html - Time: + IntermediateToken - (155:8,49 [1] TagHelpersInSection.cshtml) - Html - + CSharpExpression - (157:8,51 [12] TagHelpersInSection.cshtml) + IntermediateToken - (157:8,51 [12] TagHelpersInSection.cshtml) - CSharp - DateTime.Now + DefaultTagHelperHtmlAttribute - - unboundproperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (188:8,82 [7] TagHelpersInSection.cshtml) - + IntermediateToken - (188:8,82 [7] TagHelpersInSection.cshtml) - Html - Current + HtmlAttributeValue - (195:8,89 [6] TagHelpersInSection.cshtml) - + IntermediateToken - (196:8,90 [5] TagHelpersInSection.cshtml) - Html - Time: + CSharpExpressionAttributeValue - (201:8,95 [14] TagHelpersInSection.cshtml) - + IntermediateToken - (203:8,97 [12] TagHelpersInSection.cshtml) - CSharp - DateTime.Now + DefaultTagHelperExecute - + HtmlContent - (359:11,22 [20] TagHelpersInSection.cshtml) + IntermediateToken - (359:11,22 [6] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (365:12,4 [6] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (371:12,10 [8] TagHelpersInSection.cshtml) - Html - \n\n + MalformedDirective - (379:14,4 [112] TagHelpersInSection.cshtml) - section + DirectiveToken - (388:14,13 [13] TagHelpersInSection.cshtml) - nestedsection + HtmlContent - (404:14,29 [29] TagHelpersInSection.cshtml) + IntermediateToken - (404:14,29 [10] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (414:15,8 [4] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (419:15,13 [14] TagHelpersInSection.cshtml) - Html - \n + TagHelper - (433:16,12 [35] TagHelpersInSection.cshtml) - nestedtaghelper - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.NestedTagHelper + DefaultTagHelperExecute - + HtmlContent - (468:16,47 [22] TagHelpersInSection.cshtml) + IntermediateToken - (468:16,47 [10] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (478:17,8 [6] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (484:17,14 [6] TagHelpersInSection.cshtml) - Html - \n + HtmlContent - (491:18,5 [2] TagHelpersInSection.cshtml) + IntermediateToken - (491:18,5 [2] TagHelpersInSection.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.mappings.txt new file mode 100644 index 0000000000..cc25475c21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_DesignTime.mappings.txt @@ -0,0 +1,39 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +|"*, TestAssembly"| +Generated Location: (1115:19,37 [17] ) +|"*, TestAssembly"| + +Source Location: (82:6,9 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +|MySection| +Generated Location: (1381:29,22 [9] ) +|MySection| + +Source Location: (388:14,13 [13] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +|nestedsection| +Generated Location: (1648:39,22 [13] ) +|nestedsection| + +Source Location: (37:2,2 [31] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +| + var code = "some code"; +| +Generated Location: (2152:56,2 [31] ) +| + var code = "some code"; +| + +Source Location: (313:10,56 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +|code| +Generated Location: (2479:65,56 [4] ) +|code| + +Source Location: (157:8,51 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +|DateTime.Now| +Generated Location: (2991:75,51 [12] ) +|DateTime.Now| + +Source Location: (203:8,97 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml) +|DateTime.Now| +Generated Location: (3342:83,97 [12] ) +|DateTime.Now| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs new file mode 100644 index 0000000000..edc37eb1e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.codegen.cs @@ -0,0 +1,126 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "7d1f5fcf069d8b265b8300a5070e14e2312ef599" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"7d1f5fcf069d8b265b8300a5070e14e2312ef599", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime + { + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.MyTagHelper __TestNamespace_MyTagHelper; + private global::TestNamespace.NestedTagHelper __TestNamespace_NestedTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + + var code = "some code"; + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); + DefineSection("MySection", async() => { + WriteLiteral("\r\n
                    \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n In None ContentBehavior.\r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Some buffered values with "); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + Write(code); + +#line default +#line hidden +#nullable disable + } + ); + __TestNamespace_NestedTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_NestedTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n "); + } + ); + __TestNamespace_MyTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_MyTagHelper); + BeginWriteTagHelperAttribute(); + WriteLiteral("Current Time: "); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" + WriteLiteral(DateTime.Now); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __TestNamespace_MyTagHelper.BoundProperty = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("boundproperty", __TestNamespace_MyTagHelper.BoundProperty, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "unboundproperty", 3, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + AddHtmlAttributeValue("", 188, "Current", 188, 7, true); + AddHtmlAttributeValue(" ", 195, "Time:", 196, 6, true); +#nullable restore +#line 9 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml" +AddHtmlAttributeValue(" ", 201, DateTime.Now, 202, 13, false); + +#line default +#line hidden +#nullable disable + EndAddHtmlAttributeValues(__tagHelperExecutionContext); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
                    \r\n\r\n"); + WriteLiteral("\r\n
                    \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_NestedTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_NestedTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n
                    \r\n "); + } + ); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.diagnostics.txt new file mode 100644 index 0000000000..0efe33796f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.diagnostics.txt @@ -0,0 +1 @@ +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection.cshtml(15,5): Error RZ2002: Section blocks ("@section Header { ... }") cannot be nested. Only one level of section blocks are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt new file mode 100644 index 0000000000..f59eaa42bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersInSection_Runtime.ir.txt @@ -0,0 +1,70 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersInSection_Runtime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.MyTagHelper - __TestNamespace_MyTagHelper + FieldDeclaration - - private - global::TestNamespace.NestedTagHelper - __TestNamespace_NestedTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] TagHelpersInSection.cshtml) + IntermediateToken - (33:1,0 [2] TagHelpersInSection.cshtml) - Html - \n + CSharpCode - (37:2,2 [31] TagHelpersInSection.cshtml) + IntermediateToken - (37:2,2 [31] TagHelpersInSection.cshtml) - CSharp - \n var code = "some code";\n + HtmlContent - (71:5,0 [2] TagHelpersInSection.cshtml) + IntermediateToken - (71:5,0 [2] TagHelpersInSection.cshtml) - Html - \n + Section - - MySection + HtmlContent - (93:6,20 [21] TagHelpersInSection.cshtml) + IntermediateToken - (93:6,20 [6] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (99:7,4 [4] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (104:7,9 [10] TagHelpersInSection.cshtml) - Html - \n + TagHelper - (114:8,8 [245] TagHelpersInSection.cshtml) - mytaghelper - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (217:8,111 [52] TagHelpersInSection.cshtml) + IntermediateToken - (217:8,111 [52] TagHelpersInSection.cshtml) - Html - \n In None ContentBehavior.\n + TagHelper - (269:10,12 [66] TagHelpersInSection.cshtml) - nestedtaghelper - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (286:10,29 [26] TagHelpersInSection.cshtml) + IntermediateToken - (286:10,29 [26] TagHelpersInSection.cshtml) - Html - Some buffered values with + CSharpExpression - (313:10,56 [4] TagHelpersInSection.cshtml) + IntermediateToken - (313:10,56 [4] TagHelpersInSection.cshtml) - CSharp - code + DefaultTagHelperCreate - - TestNamespace.NestedTagHelper + DefaultTagHelperExecute - + HtmlContent - (335:10,78 [10] TagHelpersInSection.cshtml) + IntermediateToken - (335:10,78 [10] TagHelpersInSection.cshtml) - Html - \n + DefaultTagHelperCreate - - TestNamespace.MyTagHelper + DefaultTagHelperProperty - (142:8,36 [27] TagHelpersInSection.cshtml) - boundproperty - string TestNamespace.MyTagHelper.BoundProperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (142:8,36 [14] TagHelpersInSection.cshtml) + IntermediateToken - (142:8,36 [7] TagHelpersInSection.cshtml) - Html - Current + IntermediateToken - (149:8,43 [6] TagHelpersInSection.cshtml) - Html - Time: + IntermediateToken - (155:8,49 [1] TagHelpersInSection.cshtml) - Html - + CSharpExpression - (157:8,51 [12] TagHelpersInSection.cshtml) + IntermediateToken - (157:8,51 [12] TagHelpersInSection.cshtml) - CSharp - DateTime.Now + DefaultTagHelperHtmlAttribute - - unboundproperty - HtmlAttributeValueStyle.DoubleQuotes + HtmlAttributeValue - (188:8,82 [7] TagHelpersInSection.cshtml) - + IntermediateToken - (188:8,82 [7] TagHelpersInSection.cshtml) - Html - Current + HtmlAttributeValue - (195:8,89 [6] TagHelpersInSection.cshtml) - + IntermediateToken - (196:8,90 [5] TagHelpersInSection.cshtml) - Html - Time: + CSharpExpressionAttributeValue - (201:8,95 [14] TagHelpersInSection.cshtml) - + IntermediateToken - (203:8,97 [12] TagHelpersInSection.cshtml) - CSharp - DateTime.Now + DefaultTagHelperExecute - + HtmlContent - (359:11,22 [16] TagHelpersInSection.cshtml) + IntermediateToken - (359:11,22 [6] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (365:12,4 [6] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (371:12,10 [4] TagHelpersInSection.cshtml) - Html - \n\n + MalformedDirective - (379:14,4 [114] TagHelpersInSection.cshtml) - section + DirectiveToken - (388:14,13 [13] TagHelpersInSection.cshtml) - nestedsection + HtmlContent - (404:14,29 [29] TagHelpersInSection.cshtml) + IntermediateToken - (404:14,29 [10] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (414:15,8 [4] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (419:15,13 [14] TagHelpersInSection.cshtml) - Html - \n + TagHelper - (433:16,12 [35] TagHelpersInSection.cshtml) - nestedtaghelper - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.NestedTagHelper + DefaultTagHelperExecute - + HtmlContent - (468:16,47 [22] TagHelpersInSection.cshtml) + IntermediateToken - (468:16,47 [10] TagHelpersInSection.cshtml) - Html - \n + IntermediateToken - (478:17,8 [6] TagHelpersInSection.cshtml) - Html -
                    + IntermediateToken - (484:17,14 [6] TagHelpersInSection.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml new file mode 100644 index 0000000000..83023559d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml @@ -0,0 +1,4 @@ +@addTagHelper *, TestAssembly +
                    + +
                    \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.codegen.cs new file mode 100644 index 0000000000..bb24a4e6cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_DesignTime + { + #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::InputTagHelper __InputTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __InputTagHelper = CreateTagHelper(); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml" + __o = Hello; + +#line default +#line hidden +#nullable disable + __InputTagHelper.BoundProp = string.Empty; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt new file mode 100644 index 0000000000..1b4902d35d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] TagHelpersWithBoundAttributes.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [14] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (29:0,29 [2] TagHelpersWithBoundAttributes.cshtml) - Html - \n + IntermediateToken - (31:1,0 [5] TagHelpersWithBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (37:1,6 [6] TagHelpersWithBoundAttributes.cshtml) - Html - \n + TagHelper - (43:2,4 [34] TagHelpersWithBoundAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (56:2,17 [6] TagHelpersWithBoundAttributes.cshtml) - bound - string InputTagHelper.BoundProp - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (57:2,18 [5] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (57:2,18 [5] TagHelpersWithBoundAttributes.cshtml) - CSharp - Hello + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (69:2,30 [4] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (69:2,30 [4] TagHelpersWithBoundAttributes.cshtml) - Html - text + DefaultTagHelperExecute - + HtmlContent - (77:2,38 [9] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (77:2,38 [2] TagHelpersWithBoundAttributes.cshtml) - Html - \n + IntermediateToken - (79:3,0 [7] TagHelpersWithBoundAttributes.cshtml) - Html -
                    diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.mappings.txt new file mode 100644 index 0000000000..b9e407e704 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml) +|*, TestAssembly| +Generated Location: (1026:18,38 [15] ) +|*, TestAssembly| + +Source Location: (57:2,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml) +|Hello| +Generated Location: (1626:36,18 [5] ) +|Hello| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..7965f8cdbd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.codegen.cs @@ -0,0 +1,66 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "111aa585040c2e45a0dac3f5bdb65ee0252748d2" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"111aa585040c2e45a0dac3f5bdb65ee0252748d2", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::InputTagHelper __InputTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("
                    \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes.cshtml" + WriteLiteral(Hello); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __InputTagHelper.BoundProp = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("bound", __InputTagHelper.BoundProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt new file mode 100644 index 0000000000..cc8c24201a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_Runtime.ir.txt @@ -0,0 +1,24 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:1,0 [12] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (31:1,0 [5] TagHelpersWithBoundAttributes.cshtml) - Html -
                    + IntermediateToken - (37:1,6 [6] TagHelpersWithBoundAttributes.cshtml) - Html - \n + TagHelper - (43:2,4 [34] TagHelpersWithBoundAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (56:2,17 [6] TagHelpersWithBoundAttributes.cshtml) - bound - string InputTagHelper.BoundProp - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (57:2,18 [5] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (57:2,18 [5] TagHelpersWithBoundAttributes.cshtml) - CSharp - Hello + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (77:2,38 [9] TagHelpersWithBoundAttributes.cshtml) + IntermediateToken - (77:2,38 [2] TagHelpersWithBoundAttributes.cshtml) - Html - \n + IntermediateToken - (79:3,0 [7] TagHelpersWithBoundAttributes.cshtml) - Html -
                    diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml new file mode 100644 index 0000000000..2a341893ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, TestAssembly + + +
                    +

                    diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.codegen.cs new file mode 100644 index 0000000000..e4c7c9faf2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.codegen.cs @@ -0,0 +1,65 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithDataDashAttributes_DesignTime + { + #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::InputTagHelper __InputTagHelper; + private global::DivTagHelper __DivTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __InputTagHelper = CreateTagHelper(); + __InputTagHelper.BoundProp = "hello"; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" + __o = foo; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" + __o = bar; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); +#nullable restore +#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" + __o = foo; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.ir.txt new file mode 100644 index 0000000000..2fadae0eec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.ir.txt @@ -0,0 +1,67 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithDataDashAttributes_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] TagHelpersWithDataDashAttributes.cshtml) - *, TestAssembly + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [4] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (29:0,29 [4] TagHelpersWithDataDashAttributes.cshtml) - Html - \n\n + TagHelper - (33:2,0 [61] TagHelpersWithDataDashAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (47:2,14 [5] TagHelpersWithDataDashAttributes.cshtml) - bound - string InputTagHelper.BoundProp - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (47:2,14 [5] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (47:2,14 [5] TagHelpersWithDataDashAttributes.cshtml) - Html - hello + DefaultTagHelperHtmlAttribute - - data-one - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (64:2,31 [1] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (64:2,31 [1] TagHelpersWithDataDashAttributes.cshtml) - Html - 1 + DefaultTagHelperHtmlAttribute - - data-two - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (76:2,43 [1] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (76:2,43 [1] TagHelpersWithDataDashAttributes.cshtml) - Html - 2 + DefaultTagHelperHtmlAttribute - - data-three - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (90:2,57 [0] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (90:2,57 [0] TagHelpersWithDataDashAttributes.cshtml) - Html - + DefaultTagHelperExecute - + HtmlContent - (94:2,61 [2] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (94:2,61 [2] TagHelpersWithDataDashAttributes.cshtml) - Html - \n + TagHelper - (96:3,0 [66] TagHelpersWithDataDashAttributes.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - data-one - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (111:3,15 [3] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (111:3,15 [3] TagHelpersWithDataDashAttributes.cshtml) - CSharp - foo + DefaultTagHelperHtmlAttribute - - data-two - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (126:3,30 [3] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (126:3,30 [3] TagHelpersWithDataDashAttributes.cshtml) - CSharp - bar + DefaultTagHelperHtmlAttribute - - data-three - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (142:3,46 [0] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (142:3,46 [0] TagHelpersWithDataDashAttributes.cshtml) - Html - + DefaultTagHelperHtmlAttribute - - data-four - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (154:3,58 [0] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (154:3,58 [0] TagHelpersWithDataDashAttributes.cshtml) - Html - + DefaultTagHelperExecute - + HtmlContent - (162:3,66 [4] TagHelpersWithDataDashAttributes.cshtml) + IntermediateToken - (162:3,66 [2] TagHelpersWithDataDashAttributes.cshtml) - Html - \n + IntermediateToken - (164:4,0 [2] TagHelpersWithDataDashAttributes.cshtml) - Html -

                    + IntermediateToken - (229:4,65 [2] TagHelpersWithDataDashAttributes.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.mappings.txt new file mode 100644 index 0000000000..d4c4b87de2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml) +|*, TestAssembly| +Generated Location: (1086:19,38 [15] ) +|*, TestAssembly| + +Source Location: (111:3,15 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml) +|foo| +Generated Location: (1884:40,15 [3] ) +|foo| + +Source Location: (126:3,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml) +|bar| +Generated Location: (2097:47,30 [3] ) +|bar| + +Source Location: (225:4,61 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml) +|foo| +Generated Location: (2417:55,61 [3] ) +|foo| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..363ecea82c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes_Runtime.codegen.cs @@ -0,0 +1,110 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cf45e3f3bb37acbe0abf214d8091170eaa98ce5f" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithDataDashAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"cf45e3f3bb37acbe0abf214d8091170eaa98ce5f", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithDataDashAttributes_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bound", "hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-one", new global::Microsoft.AspNetCore.Html.HtmlString("1"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-two", new global::Microsoft.AspNetCore.Html.HtmlString("2"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-three", new global::Microsoft.AspNetCore.Html.HtmlString(""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-four", new global::Microsoft.AspNetCore.Html.HtmlString(""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::InputTagHelper __InputTagHelper; + private global::DivTagHelper __DivTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __InputTagHelper.BoundProp = (string)__tagHelperAttribute_0.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" + Write(foo); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("data-one", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithDataDashAttributes.cshtml" + Write(bar); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("data-two", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n

                    + IntermediateToken - (229:4,65 [2] TagHelpersWithDataDashAttributes.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml new file mode 100644 index 0000000000..e365dd4d60 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, TestAssembly +@tagHelperPrefix cool: +

                    + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.codegen.cs new file mode 100644 index 0000000000..62cb6098ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.codegen.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_DesignTime + { + #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::InputTagHelper __InputTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" +global::System.Object __typeHelper = "cool:"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __InputTagHelper = CreateTagHelper(); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" + __o = Hello; + +#line default +#line hidden +#nullable disable + __InputTagHelper.BoundProp = string.Empty; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt new file mode 100644 index 0000000000..52f53933c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt @@ -0,0 +1,35 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [15] TagHelpersWithPrefix.cshtml) - *, TestAssembly + DirectiveToken - (48:1,17 [5] TagHelpersWithPrefix.cshtml) - cool: + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (29:0,29 [2] TagHelpersWithPrefix.cshtml) + IntermediateToken - (29:0,29 [2] TagHelpersWithPrefix.cshtml) - Html - \n + HtmlContent - (53:1,22 [14] TagHelpersWithPrefix.cshtml) + IntermediateToken - (53:1,22 [2] TagHelpersWithPrefix.cshtml) - Html - \n + IntermediateToken - (55:2,0 [5] TagHelpersWithPrefix.cshtml) - Html -
                    + IntermediateToken - (61:2,6 [6] TagHelpersWithPrefix.cshtml) - Html - \n + TagHelper - (67:3,4 [39] TagHelpersWithPrefix.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (85:3,22 [6] TagHelpersWithPrefix.cshtml) - bound - string InputTagHelper.BoundProp - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (86:3,23 [5] TagHelpersWithPrefix.cshtml) + IntermediateToken - (86:3,23 [5] TagHelpersWithPrefix.cshtml) - CSharp - Hello + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (98:3,35 [4] TagHelpersWithPrefix.cshtml) + IntermediateToken - (98:3,35 [4] TagHelpersWithPrefix.cshtml) - Html - text + DefaultTagHelperExecute - + HtmlContent - (106:3,43 [9] TagHelpersWithPrefix.cshtml) + IntermediateToken - (106:3,43 [2] TagHelpersWithPrefix.cshtml) - Html - \n + IntermediateToken - (108:4,0 [7] TagHelpersWithPrefix.cshtml) - Html -
                    diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.mappings.txt new file mode 100644 index 0000000000..cebc5962cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml) +|*, TestAssembly| +Generated Location: (1008:18,38 [15] ) +|*, TestAssembly| + +Source Location: (48:1,17 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml) +|cool:| +Generated Location: (1290:28,38 [5] ) +|cool:| + +Source Location: (86:3,23 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml) +|Hello| +Generated Location: (1876:46,23 [5] ) +|Hello| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs new file mode 100644 index 0000000000..a91161ce3a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.codegen.cs @@ -0,0 +1,66 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5c97c003c8158f389b506a6dbc47e468892ec57d" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5c97c003c8158f389b506a6dbc47e468892ec57d", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("text"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::InputTagHelper __InputTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("
                    \r\n "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix.cshtml" + WriteLiteral(Hello); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __InputTagHelper.BoundProp = __tagHelperStringValueBuffer; + __tagHelperExecutionContext.AddTagHelperAttribute("bound", __InputTagHelper.BoundProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt new file mode 100644 index 0000000000..3a88f319f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_Runtime.ir.txt @@ -0,0 +1,24 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - text - HtmlAttributeValueStyle.SingleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (55:2,0 [12] TagHelpersWithPrefix.cshtml) + IntermediateToken - (55:2,0 [5] TagHelpersWithPrefix.cshtml) - Html -
                    + IntermediateToken - (61:2,6 [6] TagHelpersWithPrefix.cshtml) - Html - \n + TagHelper - (67:3,4 [39] TagHelpersWithPrefix.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperProperty - (85:3,22 [6] TagHelpersWithPrefix.cshtml) - bound - string InputTagHelper.BoundProp - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (86:3,23 [5] TagHelpersWithPrefix.cshtml) + IntermediateToken - (86:3,23 [5] TagHelpersWithPrefix.cshtml) - CSharp - Hello + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperExecute - + HtmlContent - (106:3,43 [9] TagHelpersWithPrefix.cshtml) + IntermediateToken - (106:3,43 [2] TagHelpersWithPrefix.cshtml) - Html - \n + IntermediateToken - (108:4,0 [7] TagHelpersWithPrefix.cshtml) - Html -
                    diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml new file mode 100644 index 0000000000..071122c261 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml @@ -0,0 +1,19 @@ +@addTagHelper "*, TestAssembly" + +@functions { + public void RenderTemplate(string title, Func template) + { + Output.WriteLine("

                    Rendering Template:

                    "); + var helperResult = template(title); + helperResult.WriteTo(Output, HtmlEncoder); + } +} + +
                    + @{ + RenderTemplate( + "Template: ", + @

                    @item

                    ); + } +
                    + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.codegen.cs new file mode 100644 index 0000000000..8d7c885bce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.codegen.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_DesignTime + { + #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::DivTagHelper __DivTagHelper; + private global::InputTagHelper __InputTagHelper; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + + RenderTemplate( + "Template: ", + + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable + __InputTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + ) +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + ); + + +#line default +#line hidden +#nullable disable + __DivTagHelper = CreateTagHelper(); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + + public void RenderTemplate(string title, Func template) + { + Output.WriteLine("

                    Rendering Template:

                    "); + var helperResult = template(title); + helperResult.WriteTo(Output, HtmlEncoder); + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt new file mode 100644 index 0000000000..229134183a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt @@ -0,0 +1,58 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] TagHelpersWithTemplate.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (31:0,31 [4] TagHelpersWithTemplate.cshtml) - Html - \n\n + HtmlContent - (316:9,1 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (316:9,1 [4] TagHelpersWithTemplate.cshtml) - Html - \n\n + TagHelper - (320:11,0 [179] TagHelpersWithTemplate.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (325:11,5 [6] TagHelpersWithTemplate.cshtml) + IntermediateToken - (325:11,5 [6] TagHelpersWithTemplate.cshtml) - Html - \n + CSharpCode - (333:12,6 [66] TagHelpersWithTemplate.cshtml) + IntermediateToken - (333:12,6 [66] TagHelpersWithTemplate.cshtml) - CSharp - \n RenderTemplate(\n "Template: ",\n + Template - (400:15,13 [82] TagHelpersWithTemplate.cshtml) + TagHelper - (400:15,13 [82] TagHelpersWithTemplate.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (422:15,35 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (422:15,35 [3] TagHelpersWithTemplate.cshtml) - Html -

                    + CSharpExpression - (427:15,40 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (427:15,40 [4] TagHelpersWithTemplate.cshtml) - CSharp - item + HtmlContent - (431:15,44 [5] TagHelpersWithTemplate.cshtml) + IntermediateToken - (431:15,44 [5] TagHelpersWithTemplate.cshtml) - Html -

                    + TagHelper - (436:15,49 [40] TagHelpersWithTemplate.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + DefaultTagHelperHtmlAttribute - - type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (449:15,62 [8] TagHelpersWithTemplate.cshtml) + IntermediateToken - (449:15,62 [8] TagHelpersWithTemplate.cshtml) - Html - checkbox + DefaultTagHelperHtmlAttribute - - checked - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (468:15,81 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (468:15,81 [4] TagHelpersWithTemplate.cshtml) - Html - true + DefaultTagHelperExecute - + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperHtmlAttribute - - condition - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (416:15,29 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (416:15,29 [4] TagHelpersWithTemplate.cshtml) - Html - true + DefaultTagHelperExecute - + CSharpCode - (482:15,95 [8] TagHelpersWithTemplate.cshtml) + IntermediateToken - (482:15,95 [8] TagHelpersWithTemplate.cshtml) - CSharp - );\n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + HtmlContent - (499:17,6 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (499:17,6 [4] TagHelpersWithTemplate.cshtml) - Html - \n\n + CSharpCode - (47:2,12 [268] TagHelpersWithTemplate.cshtml) + IntermediateToken - (47:2,12 [268] TagHelpersWithTemplate.cshtml) - CSharp - \n public void RenderTemplate(string title, Func template)\n {\n Output.WriteLine("

                    Rendering Template:

                    ");\n var helperResult = template(title);\n helperResult.WriteTo(Output, HtmlEncoder);\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.mappings.txt new file mode 100644 index 0000000000..e66ab1a080 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.mappings.txt @@ -0,0 +1,47 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml) +|"*, TestAssembly"| +Generated Location: (1065:19,37 [17] ) +|"*, TestAssembly"| + +Source Location: (333:12,6 [66] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml) +| + RenderTemplate( + "Template: ", + | +Generated Location: (1573:36,6 [66] ) +| + RenderTemplate( + "Template: ", + | + +Source Location: (427:15,40 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml) +|item| +Generated Location: (1919:47,40 [4] ) +|item| + +Source Location: (482:15,95 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml) +|); + | +Generated Location: (2533:60,95 [8] ) +|); + | + +Source Location: (47:2,12 [268] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml) +| + public void RenderTemplate(string title, Func template) + { + Output.WriteLine("

                    Rendering Template:

                    "); + var helperResult = template(title); + helperResult.WriteTo(Output, HtmlEncoder); + } +| +Generated Location: (2918:72,12 [268] ) +| + public void RenderTemplate(string title, Func template) + { + Output.WriteLine("

                    Rendering Template:

                    "); + var helperResult = template(title); + helperResult.WriteTo(Output, HtmlEncoder); + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs new file mode 100644 index 0000000000..5d918c6a7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.codegen.cs @@ -0,0 +1,131 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "d02421b6972074e82cabcfd56c7ab2739d5f3d49" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"d02421b6972074e82cabcfd56c7ab2739d5f3d49", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", new global::Microsoft.AspNetCore.Html.HtmlString("checkbox"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("checked", new global::Microsoft.AspNetCore.Html.HtmlString("true"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("condition", new global::Microsoft.AspNetCore.Html.HtmlString("true"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::DivTagHelper __DivTagHelper; + private global::InputTagHelper __InputTagHelper; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("\r\n"); +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + + RenderTemplate( + "Template: ", + + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("

                    "); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + Write(item); + +#line default +#line hidden +#nullable disable + WriteLiteral("

                    "); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__InputTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + PopWriter(); + } + ) +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + ); + + +#line default +#line hidden +#nullable disable + } + ); + __DivTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__DivTagHelper); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate.cshtml" + + public void RenderTemplate(string title, Func template) + { + Output.WriteLine("

                    Rendering Template:

                    "); + var helperResult = template(title); + helperResult.WriteTo(Output, HtmlEncoder); + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt new file mode 100644 index 0000000000..2c551023fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_Runtime.ir.txt @@ -0,0 +1,51 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - type - checkbox - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_1 - checked - true - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - condition - true - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::DivTagHelper - __DivTagHelper + FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] TagHelpersWithTemplate.cshtml) + IntermediateToken - (33:1,0 [2] TagHelpersWithTemplate.cshtml) - Html - \n + HtmlContent - (318:10,0 [2] TagHelpersWithTemplate.cshtml) + IntermediateToken - (318:10,0 [2] TagHelpersWithTemplate.cshtml) - Html - \n + TagHelper - (320:11,0 [179] TagHelpersWithTemplate.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (325:11,5 [2] TagHelpersWithTemplate.cshtml) + IntermediateToken - (325:11,5 [2] TagHelpersWithTemplate.cshtml) - Html - \n + CSharpCode - (327:12,0 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (327:12,0 [4] TagHelpersWithTemplate.cshtml) - CSharp - + CSharpCode - (333:12,6 [66] TagHelpersWithTemplate.cshtml) + IntermediateToken - (333:12,6 [66] TagHelpersWithTemplate.cshtml) - CSharp - \n RenderTemplate(\n "Template: ",\n + Template - (400:15,13 [82] TagHelpersWithTemplate.cshtml) + TagHelper - (400:15,13 [82] TagHelpersWithTemplate.cshtml) - div - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (422:15,35 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (422:15,35 [3] TagHelpersWithTemplate.cshtml) - Html -

                    + CSharpExpression - (427:15,40 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (427:15,40 [4] TagHelpersWithTemplate.cshtml) - CSharp - item + HtmlContent - (431:15,44 [5] TagHelpersWithTemplate.cshtml) + IntermediateToken - (431:15,44 [5] TagHelpersWithTemplate.cshtml) - Html -

                    + TagHelper - (436:15,49 [40] TagHelpersWithTemplate.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - InputTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_1 + DefaultTagHelperExecute - + DefaultTagHelperCreate - - DivTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + CSharpCode - (482:15,95 [8] TagHelpersWithTemplate.cshtml) + IntermediateToken - (482:15,95 [8] TagHelpersWithTemplate.cshtml) - CSharp - );\n + DefaultTagHelperCreate - - DivTagHelper + DefaultTagHelperExecute - + HtmlContent - (499:17,6 [4] TagHelpersWithTemplate.cshtml) + IntermediateToken - (499:17,6 [4] TagHelpersWithTemplate.cshtml) - Html - \n\n + CSharpCode - (47:2,12 [268] TagHelpersWithTemplate.cshtml) + IntermediateToken - (47:2,12 [268] TagHelpersWithTemplate.cshtml) - CSharp - \n public void RenderTemplate(string title, Func template)\n {\n Output.WriteLine("

                    Rendering Template:

                    ");\n var helperResult = template(title);\n helperResult.WriteTo(Output, HtmlEncoder);\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml new file mode 100644 index 0000000000..1796ed5c04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml @@ -0,0 +1,15 @@ +@addTagHelper "*, TestAssembly" + +

                    Body of Tag

                    + + + +

                    + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.codegen.cs new file mode 100644 index 0000000000..2940a1e2be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.codegen.cs @@ -0,0 +1,75 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_DesignTime + { + #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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" +global::System.Object __typeHelper = "*, TestAssembly"; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" +__TestNamespace_PTagHelper.Age = 1337; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" + __o = true; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "text"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_PTagHelper = CreateTagHelper(); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" +__TestNamespace_PTagHelper.Age = 1234; + +#line default +#line hidden +#nullable disable + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __TestNamespace_InputTagHelper.Type = "password"; + __TestNamespace_InputTagHelper2.Type = __TestNamespace_InputTagHelper.Type; + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt new file mode 100644 index 0000000000..8f89ff3a4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt @@ -0,0 +1,75 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_DesignTime - - + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + DesignTimeDirective - + DirectiveToken - (14:0,14 [17] TagHelpersWithWeirdlySpacedAttributes.cshtml) - "*, TestAssembly" + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (31:0,31 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (31:0,31 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (35:2,0 [85] TagHelpersWithWeirdlySpacedAttributes.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (105:6,25 [11] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (105:6,25 [11] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - Body of Tag + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperHtmlAttribute - - class - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (54:5,1 [11] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (54:5,1 [11] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - Hello World + DefaultTagHelperProperty - (74:5,21 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (74:5,21 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - CSharp - 1337 + DefaultTagHelperHtmlAttribute - - data-content - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (99:6,19 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (99:6,19 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (120:6,40 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (120:6,40 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (124:8,0 [47] TagHelpersWithWeirdlySpacedAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - text + DefaultTagHelperProperty - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - text + DefaultTagHelperHtmlAttribute - - data-content - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (162:8,38 [5] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (162:8,38 [5] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - hello + DefaultTagHelperExecute - + HtmlContent - (171:8,47 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (171:8,47 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (175:10,0 [46] TagHelpersWithWeirdlySpacedAttributes.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (186:10,11 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (186:10,11 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - CSharp - 1234 + DefaultTagHelperHtmlAttribute - - data-content - HtmlAttributeValueStyle.SingleQuotes + HtmlContent - (209:11,3 [6] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (209:11,3 [6] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - hello2 + DefaultTagHelperExecute - + HtmlContent - (221:11,15 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (221:11,15 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (225:13,0 [51] TagHelpersWithWeirdlySpacedAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + DefaultTagHelperProperty - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) - type - string TestNamespace.InputTagHelper.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - password + DefaultTagHelperProperty - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) - type - string TestNamespace.InputTagHelper2.Type - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - password + DefaultTagHelperHtmlAttribute - - data-content - HtmlAttributeValueStyle.DoubleQuotes + HtmlContent - (270:14,31 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (270:14,31 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - blah + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.mappings.txt new file mode 100644 index 0000000000..f37aba9dd4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml) +|"*, TestAssembly"| +Generated Location: (1235:20,37 [17] ) +|"*, TestAssembly"| + +Source Location: (74:5,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml) +|1337| +Generated Location: (1879:38,33 [4] ) +|1337| + +Source Location: (99:6,19 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml) +|true| +Generated Location: (2087:45,19 [4] ) +|true| + +Source Location: (186:10,11 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml) +|1234| +Generated Location: (2913:59,33 [4] ) +|1234| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs new file mode 100644 index 0000000000..2a566574c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.codegen.cs @@ -0,0 +1,142 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a58200cdb2a70e95e4cebb5c830216be0ae4b62c" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"a58200cdb2a70e95e4cebb5c830216be0ae4b62c", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime + { + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("Hello World"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "text", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-content", new global::Microsoft.AspNetCore.Html.HtmlString("hello"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-content", new global::Microsoft.AspNetCore.Html.HtmlString("hello2"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.SingleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_4 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("type", "password", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_5 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("data-content", new global::Microsoft.AspNetCore.Html.HtmlString("blah"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + #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(); + #pragma warning disable 0169 + private string __tagHelperStringValueBuffer; + #pragma warning restore 0169 + 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::TestNamespace.PTagHelper __TestNamespace_PTagHelper; + private global::TestNamespace.InputTagHelper __TestNamespace_InputTagHelper; + private global::TestNamespace.InputTagHelper2 __TestNamespace_InputTagHelper2; + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + WriteLiteral("Body of Tag"); + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); +#nullable restore +#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" +__TestNamespace_PTagHelper.Age = 1337; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + BeginWriteTagHelperAttribute(); +#nullable restore +#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" + Write(true); + +#line default +#line hidden +#nullable disable + __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); + __tagHelperExecutionContext.AddHtmlAttribute("data-content", Html.Raw(__tagHelperStringValueBuffer), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_1.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + } + ); + __TestNamespace_PTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_PTagHelper); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes.cshtml" +__TestNamespace_PTagHelper.Age = 1234; + +#line default +#line hidden +#nullable disable + __tagHelperExecutionContext.AddTagHelperAttribute("age", __TestNamespace_PTagHelper.Age, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + WriteLiteral("\r\n\r\n"); + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => { + } + ); + __TestNamespace_InputTagHelper = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper); + __TestNamespace_InputTagHelper2 = CreateTagHelper(); + __tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2); + __TestNamespace_InputTagHelper.Type = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + __TestNamespace_InputTagHelper2.Type = (string)__tagHelperAttribute_4.Value; + __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); + __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5); + await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); + if (!__tagHelperExecutionContext.Output.IsContentModified) + { + await __tagHelperExecutionContext.SetOutputContentAsync(); + } + Write(__tagHelperExecutionContext.Output); + __tagHelperExecutionContext = __tagHelperScopeManager.End(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt new file mode 100644 index 0000000000..b89b1ddb27 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_Runtime.ir.txt @@ -0,0 +1,59 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_Runtime - - + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_0 - class - Hello World - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - type - text - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_2 - data-content - hello - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_3 - data-content - hello2 - HtmlAttributeValueStyle.SingleQuotes + PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_4 - type - password - HtmlAttributeValueStyle.DoubleQuotes + PreallocatedTagHelperHtmlAttributeValue - - __tagHelperAttribute_5 - data-content - blah - HtmlAttributeValueStyle.DoubleQuotes + DefaultTagHelperRuntime - + FieldDeclaration - - private - global::TestNamespace.PTagHelper - __TestNamespace_PTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper - __TestNamespace_InputTagHelper + FieldDeclaration - - private - global::TestNamespace.InputTagHelper2 - __TestNamespace_InputTagHelper2 + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (33:1,0 [2] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (33:1,0 [2] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n + TagHelper - (35:2,0 [85] TagHelpersWithWeirdlySpacedAttributes.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + HtmlContent - (105:6,25 [11] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (105:6,25 [11] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - Body of Tag + DefaultTagHelperCreate - - TestNamespace.PTagHelper + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_0 + DefaultTagHelperProperty - (74:5,21 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (74:5,21 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - CSharp - 1337 + DefaultTagHelperHtmlAttribute - - data-content - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (99:6,19 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (99:6,19 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - CSharp - true + DefaultTagHelperExecute - + HtmlContent - (120:6,40 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (120:6,40 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (124:8,0 [47] TagHelpersWithWeirdlySpacedAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - __tagHelperAttribute_1 - type - Type + PreallocatedTagHelperProperty - (140:8,16 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - __tagHelperAttribute_1 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_2 + DefaultTagHelperExecute - + HtmlContent - (171:8,47 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (171:8,47 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (175:10,0 [46] TagHelpersWithWeirdlySpacedAttributes.cshtml) - p - TagMode.StartTagAndEndTag + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.PTagHelper + DefaultTagHelperProperty - (186:10,11 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - age - int TestNamespace.PTagHelper.Age - HtmlAttributeValueStyle.DoubleQuotes + IntermediateToken - (186:10,11 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - CSharp - 1234 + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_3 + DefaultTagHelperExecute - + HtmlContent - (221:11,15 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) + IntermediateToken - (221:11,15 [4] TagHelpersWithWeirdlySpacedAttributes.cshtml) - Html - \n\n + TagHelper - (225:13,0 [51] TagHelpersWithWeirdlySpacedAttributes.cshtml) - input - TagMode.SelfClosing + DefaultTagHelperBody - + DefaultTagHelperCreate - - TestNamespace.InputTagHelper + DefaultTagHelperCreate - - TestNamespace.InputTagHelper2 + PreallocatedTagHelperProperty - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) - __tagHelperAttribute_4 - type - Type + PreallocatedTagHelperProperty - (247:14,8 [8] TagHelpersWithWeirdlySpacedAttributes.cshtml) - __tagHelperAttribute_4 - type - Type + PreallocatedTagHelperHtmlAttribute - - __tagHelperAttribute_5 + DefaultTagHelperExecute - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml new file mode 100644 index 0000000000..05c96f57a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml @@ -0,0 +1,9 @@ +@{ + +} + + + + +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Tags_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml" + + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml" + + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_DesignTime.codegen.html new file mode 100644 index 0000000000..419c13c11c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_DesignTime.codegen.html @@ -0,0 +1,9 @@ + + + + + + +") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_DesignTime.ir.txt new file mode 100644 index 0000000000..b3a19f88d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_DesignTime.ir.txt @@ -0,0 +1,43 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Tags_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [6] Tags.cshtml) + IntermediateToken - (2:0,2 [6] Tags.cshtml) - CSharp - \n + HtmlContent - (8:1,4 [31] Tags.cshtml) + IntermediateToken - (8:1,4 [7] Tags.cshtml) - Html - + CSharpCode - (59:1,55 [2] Tags.cshtml) + IntermediateToken - (59:1,55 [2] Tags.cshtml) - CSharp - \n + HtmlContent - (64:3,0 [38] Tags.cshtml) + IntermediateToken - (64:3,0 [2] Tags.cshtml) - Html - \n + IntermediateToken - (66:4,0 [7] Tags.cshtml) - Html - + IntermediateToken - (134:6,9 [4] Tags.cshtml) - Html - \n\n + IntermediateToken - (138:8,0 [7] Tags.cshtml) - Html - +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Tags_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"75edd5542ddb6f78ab6a4d309bb3525a99ecfa55", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Tags_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral(" \r\n"); + WriteLiteral("\r\n\r\n\r\n") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_Runtime.ir.txt new file mode 100644 index 0000000000..f50d573ada --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Tags_Runtime.ir.txt @@ -0,0 +1,40 @@ +Document - + RazorCompiledItemAttribute - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + RazorSourceChecksumAttribute - + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Tags_Runtime - - + MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync + CSharpCode - (2:0,2 [2] Tags.cshtml) + IntermediateToken - (2:0,2 [2] Tags.cshtml) - CSharp - \n + HtmlContent - (4:1,0 [35] Tags.cshtml) + IntermediateToken - (4:1,0 [4] Tags.cshtml) - Html - + IntermediateToken - (8:1,4 [7] Tags.cshtml) - Html - + IntermediateToken - (59:1,55 [2] Tags.cshtml) - Html - \n + CSharpCode - (61:2,0 [0] Tags.cshtml) + IntermediateToken - (61:2,0 [0] Tags.cshtml) - CSharp - + HtmlContent - (64:3,0 [38] Tags.cshtml) + IntermediateToken - (64:3,0 [2] Tags.cshtml) - Html - \n + IntermediateToken - (66:4,0 [7] Tags.cshtml) - Html - + IntermediateToken - (134:6,9 [4] Tags.cshtml) - Html - \n\n + IntermediateToken - (138:8,0 [7] Tags.cshtml) - Html - template) { + return new HelperResult((writer) => { + for(int i = 0; i < times; i++) { + ((HelperResult)template(i)).WriteTo(writer); + } + }); + } +} + +@{ + Func foo = @This works @item!; + @foo("") +} + +@{ + Func bar = @

                    Hello

                    ; + @bar("myclass") +} + +
                      +@(Repeat(10, @
                    • Item #@item
                    • )) +
                    + +

                    +@Repeat(10, + @: This is line#@item of markup
                    +) +

                    + +

                    +@Repeat(10, + @:: This is line#@item of markup
                    +) +

                    + +

                    +@Repeat(10, + @::: This is line#@item of markup
                    +) +

                    + + +
                      + @Repeat(10, @
                    • + Item #@item + @{var parent = item;} +
                        +
                      • Child Items... ?
                      • + @*Repeat(10, @
                      • Item #@(parent).@item
                      • )*@ +
                      +
                    • ) +
                    \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs new file mode 100644 index 0000000000..e9338fa173 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs @@ -0,0 +1,206 @@ +// +#pragma warning disable 1591 +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_DesignTime + { + #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 System.Threading.Tasks.Task ExecuteAsync() + { +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + Func foo = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable + } + ) +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + ; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = foo(""); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + Func bar = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable + } + ) +#nullable restore +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + ; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = bar("myclass"); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = Repeat(10, item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +} +)); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = Repeat(10, + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +} +)); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 32 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = Repeat(10, + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +} +)); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = Repeat(10, + item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 39 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +} +)); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 45 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = Repeat(10, item => new Template(async(__razor_template_writer) => { +#nullable restore +#line 46 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 47 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + var parent = item; + +#line default +#line hidden +#nullable disable +} +)); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + public HelperResult Repeat(int times, Func template) { + return new HelperResult((writer) => { + for(int i = 0; i < times; i++) { + ((HelperResult)template(i)).WriteTo(writer); + } + }); + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.html new file mode 100644 index 0000000000..de0b735525 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.html @@ -0,0 +1,53 @@ + + + + + + + + + + + + This works ! + + + + +

                    Hello

                    + + + +
                      +
                    • Item #
                    • +
                    + +

                    + + This is line# of markup
                    + +

                    + +

                    + + : This is line# of markup
                    + +

                    + +

                    + + :: This is line# of markup
                    + +

                    + + +
                      +
                    • + Item # + +
                        +
                      • Child Items... ?
                      • + +
                      +
                    • +
                    \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt new file mode 100644 index 0000000000..f43be6acf7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt @@ -0,0 +1,158 @@ +Document - + NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles + ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_DesignTime - - + DesignTimeDirective - + 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 - System.Threading.Tasks.Task - ExecuteAsync + HtmlContent - (278:8,1 [4] Templates.cshtml) + IntermediateToken - (278:8,1 [4] Templates.cshtml) - Html - \n\n + CSharpCode - (284:10,2 [34] Templates.cshtml) + IntermediateToken - (284:10,2 [34] Templates.cshtml) - CSharp - \n Func foo = + Template - (325:11,39 [16] Templates.cshtml) + HtmlContent - (325:11,39 [11] Templates.cshtml) + IntermediateToken - (325:11,39 [11] Templates.cshtml) - Html - This works + CSharpExpression - (337:11,51 [4] Templates.cshtml) + IntermediateToken - (337:11,51 [4] Templates.cshtml) - CSharp - item + HtmlContent - (341:11,55 [1] Templates.cshtml) + IntermediateToken - (341:11,55 [1] Templates.cshtml) - Html - ! + CSharpCode - (349:11,63 [7] Templates.cshtml) + IntermediateToken - (349:11,63 [7] Templates.cshtml) - CSharp - ;\n + CSharpExpression - (357:12,5 [7] Templates.cshtml) + IntermediateToken - (357:12,5 [7] Templates.cshtml) - CSharp - foo("") + CSharpCode - (364:12,12 [2] Templates.cshtml) + IntermediateToken - (364:12,12 [2] Templates.cshtml) - CSharp - \n + HtmlContent - (369:14,0 [2] Templates.cshtml) + IntermediateToken - (369:14,0 [2] Templates.cshtml) - Html - \n + CSharpCode - (373:15,2 [35] Templates.cshtml) + IntermediateToken - (373:15,2 [35] Templates.cshtml) - CSharp - \n Func bar = + Template - (409:16,33 [26] Templates.cshtml) + HtmlContent - (409:16,33 [2] Templates.cshtml) + IntermediateToken - (409:16,33 [2] Templates.cshtml) - Html -

                    + IntermediateToken - (426:16,50 [5] Templates.cshtml) - Html - Hello + IntermediateToken - (431:16,55 [4] Templates.cshtml) - Html -

                    + CSharpCode - (435:16,59 [7] Templates.cshtml) + IntermediateToken - (435:16,59 [7] Templates.cshtml) - CSharp - ;\n + CSharpExpression - (443:17,5 [14] Templates.cshtml) + IntermediateToken - (443:17,5 [14] Templates.cshtml) - CSharp - bar("myclass") + CSharpCode - (457:17,19 [2] Templates.cshtml) + IntermediateToken - (457:17,19 [2] Templates.cshtml) - CSharp - \n + HtmlContent - (462:19,0 [8] Templates.cshtml) + IntermediateToken - (462:19,0 [2] Templates.cshtml) - Html - \n + IntermediateToken - (464:20,0 [3] Templates.cshtml) - Html -
                      + IntermediateToken - (468:20,4 [2] Templates.cshtml) - Html - \n + CSharpExpression - (472:21,2 [31] Templates.cshtml) + IntermediateToken - (472:21,2 [11] Templates.cshtml) - CSharp - Repeat(10, + Template - (484:21,14 [19] Templates.cshtml) + HtmlContent - (484:21,14 [10] Templates.cshtml) + IntermediateToken - (484:21,14 [3] Templates.cshtml) - Html -
                    • + IntermediateToken - (488:21,18 [6] Templates.cshtml) - Html - Item # + CSharpExpression - (495:21,25 [4] Templates.cshtml) + IntermediateToken - (495:21,25 [4] Templates.cshtml) - CSharp - item + HtmlContent - (499:21,29 [5] Templates.cshtml) + IntermediateToken - (499:21,29 [5] Templates.cshtml) - Html -
                    • + IntermediateToken - (504:21,34 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (506:21,36 [16] Templates.cshtml) + IntermediateToken - (506:21,36 [2] Templates.cshtml) - Html - \n + IntermediateToken - (508:22,0 [5] Templates.cshtml) - Html -
                    + IntermediateToken - (513:22,5 [4] Templates.cshtml) - Html - \n\n + IntermediateToken - (517:24,0 [2] Templates.cshtml) - Html -

                    + IntermediateToken - (520:24,3 [2] Templates.cshtml) - Html - \n + CSharpExpression - (523:25,1 [52] Templates.cshtml) + IntermediateToken - (523:25,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n + Template - (541:26,6 [35] Templates.cshtml) + HtmlContent - (541:26,6 [14] Templates.cshtml) + IntermediateToken - (541:26,6 [14] Templates.cshtml) - Html - This is line# + CSharpExpression - (556:26,21 [4] Templates.cshtml) + IntermediateToken - (556:26,21 [4] Templates.cshtml) - CSharp - item + HtmlContent - (560:26,25 [17] Templates.cshtml) + IntermediateToken - (560:26,25 [17] Templates.cshtml) - Html - of markup
                    \n + IntermediateToken - (577:27,0 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (578:27,1 [15] Templates.cshtml) + IntermediateToken - (578:27,1 [2] Templates.cshtml) - Html - \n + IntermediateToken - (580:28,0 [4] Templates.cshtml) - Html -

                    + IntermediateToken - (584:28,4 [4] Templates.cshtml) - Html - \n\n + IntermediateToken - (588:30,0 [2] Templates.cshtml) - Html -

                    + IntermediateToken - (591:30,3 [2] Templates.cshtml) - Html - \n + CSharpExpression - (594:31,1 [54] Templates.cshtml) + IntermediateToken - (594:31,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n + Template - (612:32,6 [37] Templates.cshtml) + HtmlContent - (612:32,6 [15] Templates.cshtml) + IntermediateToken - (612:32,6 [15] Templates.cshtml) - Html - : This is line# + CSharpExpression - (628:32,22 [4] Templates.cshtml) + IntermediateToken - (628:32,22 [4] Templates.cshtml) - CSharp - item + HtmlContent - (632:32,26 [18] Templates.cshtml) + IntermediateToken - (632:32,26 [18] Templates.cshtml) - Html - of markup
                    \n + IntermediateToken - (650:33,0 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (651:33,1 [15] Templates.cshtml) + IntermediateToken - (651:33,1 [2] Templates.cshtml) - Html - \n + IntermediateToken - (653:34,0 [4] Templates.cshtml) - Html -

                    + IntermediateToken - (657:34,4 [4] Templates.cshtml) - Html - \n\n + IntermediateToken - (661:36,0 [2] Templates.cshtml) - Html -

                    + IntermediateToken - (664:36,3 [2] Templates.cshtml) - Html - \n + CSharpExpression - (667:37,1 [55] Templates.cshtml) + IntermediateToken - (667:37,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n + Template - (685:38,6 [38] Templates.cshtml) + HtmlContent - (685:38,6 [16] Templates.cshtml) + IntermediateToken - (685:38,6 [16] Templates.cshtml) - Html - :: This is line# + CSharpExpression - (702:38,23 [4] Templates.cshtml) + IntermediateToken - (702:38,23 [4] Templates.cshtml) - CSharp - item + HtmlContent - (706:38,27 [18] Templates.cshtml) + IntermediateToken - (706:38,27 [18] Templates.cshtml) - Html - of markup
                    \n + IntermediateToken - (724:39,0 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (725:39,1 [22] Templates.cshtml) + IntermediateToken - (725:39,1 [2] Templates.cshtml) - Html - \n + IntermediateToken - (727:40,0 [4] Templates.cshtml) - Html -

                    + IntermediateToken - (731:40,4 [6] Templates.cshtml) - Html - \n\n\n + IntermediateToken - (737:43,0 [3] Templates.cshtml) - Html -
                      + IntermediateToken - (741:43,4 [6] Templates.cshtml) - Html - \n + CSharpExpression - (748:44,5 [141] Templates.cshtml) + IntermediateToken - (748:44,5 [11] Templates.cshtml) - CSharp - Repeat(10, + Template - (760:44,17 [129] Templates.cshtml) + HtmlContent - (760:44,17 [20] Templates.cshtml) + IntermediateToken - (760:44,17 [3] Templates.cshtml) - Html -
                    • + IntermediateToken - (764:44,21 [16] Templates.cshtml) - Html - \n Item # + CSharpExpression - (781:45,15 [4] Templates.cshtml) + IntermediateToken - (781:45,15 [4] Templates.cshtml) - CSharp - item + HtmlContent - (785:45,19 [10] Templates.cshtml) + IntermediateToken - (785:45,19 [10] Templates.cshtml) - Html - \n + CSharpCode - (797:46,10 [18] Templates.cshtml) + IntermediateToken - (797:46,10 [18] Templates.cshtml) - CSharp - var parent = item; + HtmlContent - (818:47,0 [53] Templates.cshtml) + IntermediateToken - (818:47,0 [8] Templates.cshtml) - Html - + IntermediateToken - (826:47,8 [3] Templates.cshtml) - Html -
                        + IntermediateToken - (830:47,12 [14] Templates.cshtml) - Html - \n + IntermediateToken - (844:48,12 [3] Templates.cshtml) - Html -
                      • + IntermediateToken - (848:48,16 [16] Templates.cshtml) - Html - Child Items... ? + IntermediateToken - (864:48,32 [5] Templates.cshtml) - Html -
                      • + IntermediateToken - (869:48,37 [2] Templates.cshtml) - Html - \n + HtmlContent - (932:50,0 [24] Templates.cshtml) + IntermediateToken - (932:50,0 [8] Templates.cshtml) - Html - + IntermediateToken - (940:50,8 [5] Templates.cshtml) - Html -
                      + IntermediateToken - (945:50,13 [6] Templates.cshtml) - Html - \n + IntermediateToken - (951:51,4 [5] Templates.cshtml) - Html -
                    • + IntermediateToken - (956:51,9 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (957:51,10 [8] Templates.cshtml) + IntermediateToken - (957:51,10 [2] Templates.cshtml) - Html - \n + IntermediateToken - (959:52,0 [5] Templates.cshtml) - Html -
                    + IntermediateToken - (964:52,5 [1] Templates.cshtml) - Html - + CSharpCode - (12:0,12 [265] Templates.cshtml) + IntermediateToken - (12:0,12 [265] Templates.cshtml) - CSharp - \n public HelperResult Repeat(int times, Func template) {\n return new HelperResult((writer) => {\n for(int i = 0; i < times; i++) {\n ((HelperResult)template(i)).WriteTo(writer);\n }\n });\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt new file mode 100644 index 0000000000..4c67be5de0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt @@ -0,0 +1,169 @@ +Source Location: (284:10,2 [34] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| + Func foo = | +Generated Location: (739:19,2 [34] ) +| + Func foo = | + +Source Location: (337:11,51 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (1051:28,51 [4] ) +|item| + +Source Location: (349:11,63 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|; + | +Generated Location: (1306:37,63 [7] ) +|; + | + +Source Location: (357:12,5 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|foo("")| +Generated Location: (1476:45,6 [7] ) +|foo("")| + +Source Location: (364:12,12 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| +| +Generated Location: (1653:52,12 [2] ) +| +| + +Source Location: (373:15,2 [35] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| + Func bar = | +Generated Location: (1812:59,2 [35] ) +| + Func bar = | + +Source Location: (420:16,44 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (2118:68,44 [4] ) +|item| + +Source Location: (435:16,59 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|; + | +Generated Location: (2369:77,59 [7] ) +|; + | + +Source Location: (443:17,5 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|bar("myclass")| +Generated Location: (2539:85,6 [14] ) +|bar("myclass")| + +Source Location: (457:17,19 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| +| +Generated Location: (2730:92,19 [2] ) +| +| + +Source Location: (472:21,2 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|Repeat(10, | +Generated Location: (2893:99,6 [11] ) +|Repeat(10, | + +Source Location: (495:21,25 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (3092:102,25 [4] ) +|item| + +Source Location: (504:21,34 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|)| +Generated Location: (3153:108,1 [1] ) +|)| + +Source Location: (523:25,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|Repeat(10, + | +Generated Location: (3318:115,6 [16] ) +|Repeat(10, + | + +Source Location: (556:26,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (3518:119,21 [4] ) +|item| + +Source Location: (577:27,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|)| +Generated Location: (3579:125,1 [1] ) +|)| + +Source Location: (594:31,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|Repeat(10, + | +Generated Location: (3744:132,6 [16] ) +|Repeat(10, + | + +Source Location: (628:32,22 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (3945:136,22 [4] ) +|item| + +Source Location: (650:33,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|)| +Generated Location: (4006:142,1 [1] ) +|)| + +Source Location: (667:37,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|Repeat(10, + | +Generated Location: (4171:149,6 [16] ) +|Repeat(10, + | + +Source Location: (702:38,23 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (4373:153,23 [4] ) +|item| + +Source Location: (724:39,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|)| +Generated Location: (4434:159,1 [1] ) +|)| + +Source Location: (748:44,5 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|Repeat(10, | +Generated Location: (4599:166,6 [11] ) +|Repeat(10, | + +Source Location: (781:45,15 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (4788:169,15 [4] ) +|item| + +Source Location: (797:46,10 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|var parent = item;| +Generated Location: (4960:176,10 [18] ) +|var parent = item;| + +Source Location: (956:51,9 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|)| +Generated Location: (5034:182,1 [1] ) +|)| + +Source Location: (12:0,12 [265] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| + public HelperResult Repeat(int times, Func template) { + return new HelperResult((writer) => { + for(int i = 0; i < times; i++) { + ((HelperResult)template(i)).WriteTo(writer); + } + }); + } +| +Generated Location: (5253:191,12 [265] ) +| + public HelperResult Repeat(int times, Func template) { + return new HelperResult((writer) => { + for(int i = 0; i < times; i++) { + ((HelperResult)template(i)).WriteTo(writer); + } + }); + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs new file mode 100644 index 0000000000..8dccc5c266 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs @@ -0,0 +1,228 @@ +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "488aa2f21a6d3e3c761871ec0bf2f295695db71a" +// +#pragma warning disable 1591 +[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime), @"default", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml")] +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles +{ + #line hidden + [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"488aa2f21a6d3e3c761871ec0bf2f295695db71a", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml")] + public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_Runtime + { + #pragma warning disable 1998 + public async System.Threading.Tasks.Task ExecuteAsync() + { + WriteLiteral("\r\n"); +#nullable restore +#line 11 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + Func foo = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + WriteLiteral("This works "); +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + Write(item); + +#line default +#line hidden +#nullable disable + WriteLiteral("!"); + PopWriter(); + } + ) +#nullable restore +#line 12 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + ; + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 13 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +Write(foo("")); + +#line default +#line hidden +#nullable disable + WriteLiteral("\r\n"); +#nullable restore +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + Func bar = + +#line default +#line hidden +#nullable disable + item => new Template(async(__razor_template_writer) => { + PushWriter(__razor_template_writer); + WriteLiteral("
                    LF }] + MarkupBlock - [0..352)::352 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..352)::352 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..36)::35 - [foreach(var c in db.Categories) {LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[c]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[db]; + Dot;[.]; + Identifier;[Categories]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [36..343)::307 + MarkupTextLiteral - [36..48)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [48..341)::293 + MarkupStartTag - [48..53)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [53..71)::18 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [71..87)::16 + MarkupStartTag - [71..75)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[h1]; + CloseAngle;[>]; + MarkupTextLiteral - [75..75)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [75..82)::7 + CSharpImplicitExpression - [75..82)::7 + CSharpTransition - [75..76)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [76..82)::6 + CSharpCodeBlock - [76..82)::6 + CSharpExpressionLiteral - [76..82)::6 - [c.Name] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[c]; + Dot;[.]; + Identifier;[Name]; + MarkupEndTag - [82..87)::5 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[h1]; + CloseAngle;[>]; + MarkupTextLiteral - [87..105)::18 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [105..321)::216 + MarkupStartTag - [105..109)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; + MarkupTextLiteral - [321..335)::14 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupEndTag - [335..341)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [341..343)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [343..352)::9 - [ }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [352..352)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.cspans.txt new file mode 100644 index 0000000000..789aee764e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [181] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [181] ) +Code span at (1:0,1 [180] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [181] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.stree.txt new file mode 100644 index 0000000000..bef141e83a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesElseIfBranchesOfIfStatement.stree.txt @@ -0,0 +1,101 @@ +RazorDocument - [0..181)::181 - [@if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] + MarkupBlock - [0..181)::181 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..181)::181 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..181)::180 - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.cspans.txt new file mode 100644 index 0000000000..e9b4132796 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [13] ) +Code span at (12:0,12 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (11:0,11 [13] ) +Code span at (24:0,24 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.stree.txt new file mode 100644 index 0000000000..4d0d95b0bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..26)::26 - [@if(foo) { @foo[4].bar() }] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..11)::10 - [if(foo) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [11..24)::13 + CSharpImplicitExpression - [11..24)::13 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [12..24)::12 + CSharpCodeBlock - [12..24)::12 + CSharpExpressionLiteral - [12..24)::12 - [foo[4].bar()] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Identifier;[foo]; + LeftBracket;[[]; + IntegerLiteral;[4]; + RightBracket;[]]; + Dot;[.]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + CSharpStatementLiteral - [24..26)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.cspans.txt new file mode 100644 index 0000000000..fa6fe6f284 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [12] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [12] ) +Code span at (13:0,13 [9] ) (Accepts:Any) - Parent: Expression block at (11:0,11 [12] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [12] ) +Code span at (23:0,23 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.stree.txt new file mode 100644 index 0000000000..13b1192f70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesExpressionOnSwitchCharacterFollowedByOpenParen.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..25)::25 - [@if(foo) { @(foo + bar) }] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..11)::10 - [if(foo) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [11..23)::12 + CSharpExplicitExpression - [11..23)::12 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [12..23)::11 + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [13..22)::9 + CSharpExpressionLiteral - [13..22)::9 - [foo + bar] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + Whitespace;[ ]; + Plus;[+]; + Whitespace;[ ]; + Identifier;[bar]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + CSharpStatementLiteral - [23..25)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.cspans.txt new file mode 100644 index 0000000000..2fe075b558 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [460] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [460] ) +Code span at (1:0,1 [459] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [460] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.stree.txt new file mode 100644 index 0000000000..c7b7c42a7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatement.stree.txt @@ -0,0 +1,245 @@ +RazorDocument - [0..460)::460 - [@if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] + MarkupBlock - [0..460)::460 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..460)::460 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..460)::459 - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.cspans.txt new file mode 100644 index 0000000000..605d3b6d2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [314] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [314] ) +Code span at (1:0,1 [313] ) (Accepts:None) - Parent: Statement block at (0:0,0 [314] ) +Markup span at (314:6,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [314] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.stree.txt new file mode 100644 index 0000000000..aa1209b97a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch.stree.txt @@ -0,0 +1,165 @@ +RazorDocument - [0..314)::314 - [@if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else { Debug.WriteLine(@"bar } baz"); }] + MarkupBlock - [0..314)::314 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..314)::314 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..314)::313 - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else { Debug.WriteLine(@"bar } baz"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [314..314)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt new file mode 100644 index 0000000000..38e57fe477 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Code span at (1:0,1 [28] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt new file mode 100644 index 0000000000..824fdc01ed --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..29)::29 - [@using FooBarBaz = FooBarBaz;] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + RazorDirective - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..29)::28 + CSharpStatementLiteral - [1..29)::28 - [using FooBarBaz = FooBarBaz;] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Identifier;[FooBarBaz]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[FooBarBaz]; + Semicolon;[;]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt new file mode 100644 index 0000000000..0fa4fa9054 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (1:0,1 [18] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt new file mode 100644 index 0000000000..e80602c1cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..19)::19 - [@using Foo.Bar.Baz;] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + RazorDirective - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..19)::18 + CSharpStatementLiteral - [1..19)::18 - [using Foo.Bar.Baz;] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Identifier;[Foo]; + Dot;[.]; + Identifier;[Bar]; + Dot;[.]; + Identifier;[Baz]; + Semicolon;[;]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.cspans.txt new file mode 100644 index 0000000000..3331924bfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [83] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [83] ) +Code span at (1:0,1 [82] ) (Accepts:None) - Parent: Statement block at (0:0,0 [83] ) +Markup span at (83:0,83 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [83] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.stree.txt new file mode 100644 index 0000000000..9b56c74626 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..83)::83 - [@for(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] + MarkupBlock - [0..83)::83 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..83)::83 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..83)::82 - [for(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[for]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [83..83)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.cspans.txt new file mode 100644 index 0000000000..3dcf5604d4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [87] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [87] ) +Code span at (1:0,1 [86] ) (Accepts:None) - Parent: Statement block at (0:0,0 [87] ) +Markup span at (87:0,87 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [87] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.stree.txt new file mode 100644 index 0000000000..57c9e1ffbc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..87)::87 - [@foreach(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] + MarkupBlock - [0..87)::87 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..87)::87 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..87)::86 - [foreach(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[foreach]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [87..87)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.cspans.txt new file mode 100644 index 0000000000..8cb778eea3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [82] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [82] ) +Code span at (1:0,1 [81] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [82] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.stree.txt new file mode 100644 index 0000000000..416c7e02e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..82)::82 - [@if(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] + MarkupBlock - [0..82)::82 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..82)::82 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..82)::81 - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.cspans.txt new file mode 100644 index 0000000000..1db0bcc1b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [162] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [162] ) +Code span at (1:0,1 [161] ) (Accepts:None) - Parent: Statement block at (0:0,0 [162] ) +Markup span at (162:11,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [162] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.stree.txt new file mode 100644 index 0000000000..29ee2fa878 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword.stree.txt @@ -0,0 +1,62 @@ +RazorDocument - [0..162)::162 - [@switch(foo) {LF case 0:LF break;LF case 1:LF {LF break;LF }LF case 2:LF return;LF default:LF return;LF}] + MarkupBlock - [0..162)::162 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..162)::162 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..162)::161 - [switch(foo) {LF case 0:LF break;LF case 1:LF {LF break;LF }LF case 2:LF return;LF default:LF return;LF}] - Gen - SpanEditHandler;Accepts:None + Keyword;[switch]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Colon;[:]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[break]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Colon;[:]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[break]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Colon;[:]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[return]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[default]; + Colon;[:]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[return]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + MarkupTextLiteral - [162..162)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.cspans.txt new file mode 100644 index 0000000000..ca0b546f9e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +Code span at (1:0,1 [84] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +Markup span at (85:0,85 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.stree.txt new file mode 100644 index 0000000000..7c1f988f74 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..85)::85 - [@while(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] + MarkupBlock - [0..85)::85 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..85)::85 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..85)::84 - [while(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [85..85)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.cspans.txt new file mode 100644 index 0000000000..ca0b546f9e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +Code span at (1:0,1 [84] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +Markup span at (85:0,85 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.stree.txt new file mode 100644 index 0000000000..348596ed7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..85)::85 - [@using(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] + MarkupBlock - [0..85)::85 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..85)::85 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..85)::84 - [using(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[using]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [85..85)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.cspans.txt new file mode 100644 index 0000000000..aa0c099c06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Code span at (1:0,1 [55] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Markup span at (56:0,56 [23] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.stree.txt new file mode 100644 index 0000000000..591939c74e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCatchClausesAfterFinallyBlock.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..79)::79 - [@try { var foo = new { } } finally { var foo = new { } } catch(Foo Bar Baz) { }] + MarkupBlock - [0..79)::79 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..56)::56 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..56)::55 - [try { var foo = new { } } finally { var foo = new { } }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [56..79)::23 - [ catch(Foo Bar Baz) { }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[catch(Foo]; + Whitespace;[ ]; + Text;[Bar]; + Whitespace;[ ]; + Text;[Baz)]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.cspans.txt new file mode 100644 index 0000000000..be831c60b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [314] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [221] ) +Code span at (1:0,1 [220] ) (Accepts:None) - Parent: Statement block at (0:0,0 [221] ) +Markup span at (221:4,41 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [314] ) +Markup span at (243:4,63 [1] ) (Accepts:Any) - Parent: Tag block at (243:4,63 [71] ) +Markup span at (244:4,64 [4] ) (Accepts:Any) - Parent: Markup block at (244:4,64 [4] ) +Markup span at (248:4,68 [4] ) (Accepts:Any) - Parent: Markup block at (248:4,68 [4] ) +Markup span at (252:4,72 [4] ) (Accepts:Any) - Parent: Markup block at (252:4,72 [4] ) +Markup span at (256:4,76 [2] ) (Accepts:Any) - Parent: Markup block at (256:4,76 [2] ) +Markup span at (258:4,78 [8] ) (Accepts:Any) - Parent: Markup block at (258:4,78 [12] ) +Markup span at (266:4,86 [3] ) (Accepts:Any) - Parent: Markup block at (258:4,78 [12] ) +Markup span at (269:4,89 [1] ) (Accepts:Any) - Parent: Markup block at (258:4,78 [12] ) +Markup span at (270:4,90 [3] ) (Accepts:Any) - Parent: Markup block at (270:4,90 [3] ) +Markup span at (273:4,93 [2] ) (Accepts:Any) - Parent: Markup block at (273:4,93 [2] ) +Markup span at (275:4,95 [27] ) (Accepts:Any) - Parent: Markup block at (275:4,95 [27] ) +Markup span at (302:5,25 [2] ) (Accepts:Any) - Parent: Markup block at (302:5,25 [2] ) +Markup span at (304:5,27 [7] ) (Accepts:Any) - Parent: Markup block at (304:5,27 [7] ) +Markup span at (311:5,34 [3] ) (Accepts:Any) - Parent: Markup block at (311:5,34 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.stree.txt new file mode 100644 index 0000000000..f4dfa89174 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingCodeAfterElseBranch.stree.txt @@ -0,0 +1,207 @@ +RazorDocument - [0..314)::314 - [@if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else { Debug.WriteLine(@"bar } baz"); } else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] + MarkupBlock - [0..314)::314 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..221)::221 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..221)::220 - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF} else if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF} else { Debug.WriteLine(@"bar } baz"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"bar } baz"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [221..243)::22 - [ else if(int i = 0; i ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[else]; + Whitespace;[ ]; + Text;[if(int]; + Whitespace;[ ]; + Text;[i]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[0;]; + Whitespace;[ ]; + Text;[i]; + Whitespace;[ ]; + MarkupElement - [243..314)::71 + MarkupStartTag - [243..314)::71 - [< 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"bar } baz");LF}] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMinimizedAttributeBlock - [244..248)::4 - [ 10;] + MarkupTextLiteral - [244..245)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [245..248)::3 - [10;] - Gen - SpanEditHandler;Accepts:Any + Text;[10;]; + MarkupMinimizedAttributeBlock - [248..252)::4 - [ new] + MarkupTextLiteral - [248..249)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [249..252)::3 - [new] - Gen - SpanEditHandler;Accepts:Any + Text;[new]; + MarkupMinimizedAttributeBlock - [252..256)::4 - [ Foo] + MarkupTextLiteral - [252..253)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [253..256)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupMinimizedAttributeBlock - [256..258)::2 - [ {] + MarkupTextLiteral - [256..257)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [257..258)::1 - [{] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + MarkupAttributeBlock - [258..270)::12 - [ Bar = "baz"] + MarkupTextLiteral - [258..259)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [259..262)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [262..263)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Equals;[=]; + MarkupTextLiteral - [264..266)::2 - [ "] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + DoubleQuote;["]; + GenericBlock - [266..269)::3 + MarkupLiteralAttributeValue - [266..269)::3 - [baz] + MarkupTextLiteral - [266..269)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + MarkupTextLiteral - [269..270)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMinimizedAttributeBlock - [270..273)::3 - [ })] + MarkupTextLiteral - [270..271)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [271..273)::2 - [})] - Gen - SpanEditHandler;Accepts:Any + Text;[})]; + MarkupMinimizedAttributeBlock - [273..275)::2 - [ {] + MarkupTextLiteral - [273..274)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [274..275)::1 - [{] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + MarkupMinimizedAttributeBlock - [275..302)::27 - [LF Debug.WriteLine(@"bar] + MarkupTextLiteral - [275..281)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [281..302)::21 - [Debug.WriteLine(@"bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Debug.WriteLine(]; + Transition;[@]; + DoubleQuote;["]; + Text;[bar]; + MarkupMinimizedAttributeBlock - [302..304)::2 - [ }] + MarkupTextLiteral - [302..303)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [303..304)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + MarkupMinimizedAttributeBlock - [304..311)::7 - [ baz");] + MarkupTextLiteral - [304..305)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [305..311)::6 - [baz");] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + DoubleQuote;["]; + Text;[);]; + MarkupMinimizedAttributeBlock - [311..314)::3 - [LF}] + MarkupTextLiteral - [311..313)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [313..314)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.cspans.txt new file mode 100644 index 0000000000..fe1c982289 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [88] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [88] ) +Code span at (1:0,1 [87] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [88] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.stree.txt new file mode 100644 index 0000000000..bc5f1923c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/StopsParsingIfIfStatementNotFollowedByElse.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..88)::88 - [@if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF}] + MarkupBlock - [0..88)::88 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..88)::88 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..88)::87 - [if(int i = 0; i < 10; new Foo { Bar = "baz" }) {LF Debug.WriteLine(@"foo } bar");LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..6e4685336b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] ) +Code span at (1:0,1 [75] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] ) +Markup span at (76:0,76 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.stree.txt new file mode 100644 index 0000000000..96e3f6e83c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenCatchAndFinallyClause.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..76)::76 - [@try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }] + MarkupBlock - [0..76)::76 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..76)::76 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..76)::75 - [try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + CSharpComment;[/* Foo */]; + Whitespace;[ ]; + CSharpComment;[/* Bar */]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[biz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [76..76)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.cspans.txt new file mode 100644 index 0000000000..ad7d618e3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [54] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Markup span at (55:0,55 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.stree.txt new file mode 100644 index 0000000000..fce6e868c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenDoAndWhileClause.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..55)::55 - [@do { var foo = bar; } /* Foo */ /* Bar */ while(true);] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..55)::54 - [do { var foo = bar; } /* Foo */ /* Bar */ while(true);] - Gen - SpanEditHandler;Accepts:None + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + CSharpComment;[/* Foo */]; + Whitespace;[ ]; + CSharpComment;[/* Bar */]; + Whitespace;[ ]; + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [55..55)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..ab49157b04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [79] ) +Code span at (1:0,1 [78] ) (Accepts:None) - Parent: Statement block at (0:0,0 [79] ) +Markup span at (79:0,79 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.stree.txt new file mode 100644 index 0000000000..a3ef08830e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenElseIfAndElseClause.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..79)::79 - [@if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }] + MarkupBlock - [0..79)::79 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..79)::79 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..79)::78 - [if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + CSharpComment;[/* Foo */]; + Whitespace;[ ]; + CSharpComment;[/* Bar */]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[biz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [79..79)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..ad7d618e3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [54] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Markup span at (55:0,55 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.stree.txt new file mode 100644 index 0000000000..caa9d72231 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseClause.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..55)::55 - [@if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..55)::54 - [if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + CSharpComment;[/* Foo */]; + Whitespace;[ ]; + CSharpComment;[/* Bar */]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [55..55)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.cspans.txt new file mode 100644 index 0000000000..9308e1a86a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [62] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [62] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.stree.txt new file mode 100644 index 0000000000..4d4572d8e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenIfAndElseIfClause.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..62)::62 - [if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }] + MarkupBlock - [0..62)::62 + MarkupTextLiteral - [0..62)::62 - [if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }] - Gen - SpanEditHandler;Accepts:Any + Text;[if(foo)]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + Text;[bar();]; + Whitespace;[ ]; + Text;[}]; + Whitespace;[ ]; + ForwardSlash;[/]; + Text;[*]; + Whitespace;[ ]; + Text;[Foo]; + Whitespace;[ ]; + Text;[*]; + ForwardSlash;[/]; + Whitespace;[ ]; + ForwardSlash;[/]; + Text;[*]; + Whitespace;[ ]; + Text;[Bar]; + Whitespace;[ ]; + Text;[*]; + ForwardSlash;[/]; + Whitespace;[ ]; + Text;[else]; + Whitespace;[ ]; + Text;[if(bar)]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + Text;[baz();]; + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.cspans.txt new file mode 100644 index 0000000000..160fbdc681 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Code span at (1:0,1 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.stree.txt new file mode 100644 index 0000000000..2385e04a83 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndCatchClause.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..57)::57 - [@try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..57)::56 - [try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + CSharpComment;[/* Foo */]; + Whitespace;[ ]; + CSharpComment;[/* Bar */]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..d203f657ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Code span at (1:0,1 [53] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Markup span at (54:0,54 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.stree.txt new file mode 100644 index 0000000000..b260d25664 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsBlockCommentBetweenTryAndFinallyClause.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..54)::54 - [@try { bar(); } /* Foo */ /* Bar */ finally { baz(); }] + MarkupBlock - [0..54)::54 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..54)::54 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..54)::53 - [try { bar(); } /* Foo */ /* Bar */ finally { baz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + CSharpComment;[/* Foo */]; + Whitespace;[ ]; + CSharpComment;[/* Bar */]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [54..54)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.cspans.txt new file mode 100644 index 0000000000..c6237e0e8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Code span at (1:0,1 [53] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.stree.txt new file mode 100644 index 0000000000..32c77551fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsExceptionLessCatchClauses.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..54)::54 - [@try { var foo = new { } } catch { var foo = new { } }] + MarkupBlock - [0..54)::54 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..54)::54 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..54)::53 - [try { var foo = new { } } catch { var foo = new { } }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..62b7ff3aa5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [73] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [73] ) +Code span at (1:0,1 [72] ) (Accepts:None) - Parent: Statement block at (0:0,0 [73] ) +Markup span at (73:3,18 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [73] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.stree.txt new file mode 100644 index 0000000000..2171dd644d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenCatchAndFinallyClause.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..73)::73 - [@try { bar(); } catch(bar) { baz(); }LF// FooLF// BarLFfinally { biz(); }] + MarkupBlock - [0..73)::73 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..73)::73 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..73)::72 - [try { bar(); } catch(bar) { baz(); }LF// FooLF// BarLFfinally { biz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[biz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [73..73)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.cspans.txt new file mode 100644 index 0000000000..9cf3e2b219 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) +Code span at (1:0,1 [51] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) +Markup span at (52:3,12 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.stree.txt new file mode 100644 index 0000000000..6e8cbb886a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenDoAndWhileClause.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..52)::52 - [@do { var foo = bar; }LF// FooLF// BarLFwhile(true);] + MarkupBlock - [0..52)::52 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..52)::52 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..52)::51 - [do { var foo = bar; }LF// FooLF// BarLFwhile(true);] - Gen - SpanEditHandler;Accepts:None + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [52..52)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..e5f45fe9ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] ) +Code span at (1:0,1 [75] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] ) +Markup span at (76:3,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.stree.txt new file mode 100644 index 0000000000..e7bad5b4ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenElseIfAndElseClause.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..76)::76 - [@if(foo) { bar(); } else if(bar) { baz(); }LF// FooLF// BarLFelse { biz(); }] + MarkupBlock - [0..76)::76 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..76)::76 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..76)::75 - [if(foo) { bar(); } else if(bar) { baz(); }LF// FooLF// BarLFelse { biz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[biz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [76..76)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..566e454573 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) +Code span at (1:0,1 [51] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) +Markup span at (52:3,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.stree.txt new file mode 100644 index 0000000000..d167b6dbe2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseClause.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..52)::52 - [@if(foo) { bar(); }LF// FooLF// BarLFelse { baz(); }] + MarkupBlock - [0..52)::52 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..52)::52 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..52)::51 - [if(foo) { bar(); }LF// FooLF// BarLFelse { baz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [52..52)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.cspans.txt new file mode 100644 index 0000000000..8985fc4d32 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [60] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [60] ) +Code span at (1:0,1 [59] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [60] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.stree.txt new file mode 100644 index 0000000000..a0ca426d84 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenIfAndElseIfClause.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..60)::60 - [@if(foo) { bar(); }LF// FooLF// BarLFelse if(bar) { baz(); }] + MarkupBlock - [0..60)::60 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..60)::60 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..60)::59 - [if(foo) { bar(); }LF// FooLF// BarLFelse if(bar) { baz(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.cspans.txt new file mode 100644 index 0000000000..c6237e0e8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Code span at (1:0,1 [53] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.stree.txt new file mode 100644 index 0000000000..62b181f49f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndCatchClause.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..54)::54 - [@try { bar(); }LF// FooLF// BarLFcatch(bar) { baz(); }] + MarkupBlock - [0..54)::54 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..54)::54 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..54)::53 - [try { bar(); }LF// FooLF// BarLFcatch(bar) { baz(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..4ea9b5e4ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Code span at (1:0,1 [50] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Markup span at (51:3,18 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.stree.txt new file mode 100644 index 0000000000..ed023e9a58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsLineCommentBetweenTryAndFinallyClause.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..51)::51 - [@try { bar(); }LF// FooLF// BarLFfinally { baz(); }] + MarkupBlock - [0..51)::51 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..51)::51 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..51)::50 - [try { bar(); }LF// FooLF// BarLFfinally { baz(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + CSharpComment;[// Foo]; + NewLine;[LF]; + CSharpComment;[// Bar]; + NewLine;[LF]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [51..51)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.cspans.txt new file mode 100644 index 0000000000..c85c3644c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [142] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [142] ) +Code span at (1:0,1 [128] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [142] ) +Markup span at (129:0,129 [1] ) (Accepts:Any) - Parent: Markup block at (129:0,129 [12] ) +Markup span at (130:0,130 [3] ) (Accepts:None) - Parent: Tag block at (130:0,130 [3] ) +Markup span at (133:0,133 [3] ) (Accepts:Any) - Parent: Markup block at (129:0,129 [12] ) +Markup span at (136:0,136 [4] ) (Accepts:None) - Parent: Tag block at (136:0,136 [4] ) +Markup span at (140:0,140 [1] ) (Accepts:None) - Parent: Markup block at (129:0,129 [12] ) +Code span at (141:0,141 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [142] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.stree.txt new file mode 100644 index 0000000000..8c4bba87e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinAdditionalCatchClauses.stree.txt @@ -0,0 +1,105 @@ +RazorDocument - [0..142)::142 - [@try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) {

                    Foo

                    }] + MarkupBlock - [0..142)::142 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..142)::142 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..129)::128 - [try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [129..141)::12 + MarkupTextLiteral - [129..130)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [130..140)::10 + MarkupStartTag - [130..133)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [133..136)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [136..140)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [140..141)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [141..142)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.cspans.txt new file mode 100644 index 0000000000..f5eacad8c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [60] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [60] ) +Code span at (1:0,1 [46] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [60] ) +Markup span at (47:0,47 [1] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [12] ) +Markup span at (48:0,48 [3] ) (Accepts:None) - Parent: Tag block at (48:0,48 [3] ) +Markup span at (51:0,51 [3] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [12] ) +Markup span at (54:0,54 [4] ) (Accepts:None) - Parent: Tag block at (54:0,54 [4] ) +Markup span at (58:0,58 [1] ) (Accepts:None) - Parent: Markup block at (47:0,47 [12] ) +Code span at (59:0,59 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [60] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.stree.txt new file mode 100644 index 0000000000..c3f718b548 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinCatchClause.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..60)::60 - [@try { var foo = new { } } catch(Foo Bar Baz) {

                    Foo

                    }] + MarkupBlock - [0..60)::60 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..60)::60 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..47)::46 - [try { var foo = new { } } catch(Foo Bar Baz) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [47..59)::12 + MarkupTextLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [48..58)::10 + MarkupStartTag - [48..51)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [51..54)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [54..58)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [58..59)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [59..60)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.cspans.txt new file mode 100644 index 0000000000..4fd893b6ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Code span at (1:0,1 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) +Markup span at (36:0,36 [1] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [12] ) +Markup span at (37:0,37 [3] ) (Accepts:None) - Parent: Tag block at (37:0,37 [3] ) +Markup span at (40:0,40 [3] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [12] ) +Markup span at (43:0,43 [4] ) (Accepts:None) - Parent: Tag block at (43:0,43 [4] ) +Markup span at (47:0,47 [1] ) (Accepts:None) - Parent: Markup block at (36:0,36 [12] ) +Code span at (48:0,48 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Markup span at (49:0,49 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.stree.txt new file mode 100644 index 0000000000..41cfa89c2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinFinallyClause.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..49)::49 - [@try { var foo = new { } } finally {

                    Foo

                    }] + MarkupBlock - [0..49)::49 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..49)::49 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..36)::35 - [try { var foo = new { } } finally {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [36..48)::12 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [37..47)::10 + MarkupStartTag - [37..40)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [40..43)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [43..47)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [48..49)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [49..49)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.cspans.txt new file mode 100644 index 0000000000..93ffe7cfe8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (6:0,6 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (7:0,7 [3] ) (Accepts:None) - Parent: Tag block at (7:0,7 [3] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [12] ) +Markup span at (13:0,13 [4] ) (Accepts:None) - Parent: Tag block at (13:0,13 [4] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (6:0,6 [12] ) +Code span at (18:0,18 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.stree.txt new file mode 100644 index 0000000000..996f278e09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsMarkupWithinTryClause.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..19)::19 - [@try {

                    Foo

                    }] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..6)::5 - [try {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [6..18)::12 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [7..17)::10 + MarkupStartTag - [7..10)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [10..13)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [13..17)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [18..19)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..93426c20ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] ) +Code span at (1:0,1 [37] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [76] ) +Transition span at (38:0,38 [1] ) (Accepts:None) - Parent: Comment block at (38:0,38 [9] ) +MetaCode span at (39:0,39 [1] ) (Accepts:None) - Parent: Comment block at (38:0,38 [9] ) +Comment span at (40:0,40 [5] ) (Accepts:Any) - Parent: Comment block at (38:0,38 [9] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Comment block at (38:0,38 [9] ) +Transition span at (46:0,46 [1] ) (Accepts:None) - Parent: Comment block at (38:0,38 [9] ) +Code span at (47:0,47 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [76] ) +Transition span at (48:0,48 [1] ) (Accepts:None) - Parent: Comment block at (48:0,48 [9] ) +MetaCode span at (49:0,49 [1] ) (Accepts:None) - Parent: Comment block at (48:0,48 [9] ) +Comment span at (50:0,50 [5] ) (Accepts:Any) - Parent: Comment block at (48:0,48 [9] ) +MetaCode span at (55:0,55 [1] ) (Accepts:None) - Parent: Comment block at (48:0,48 [9] ) +Transition span at (56:0,56 [1] ) (Accepts:None) - Parent: Comment block at (48:0,48 [9] ) +Code span at (57:0,57 [19] ) (Accepts:None) - Parent: Statement block at (0:0,0 [76] ) +Markup span at (76:0,76 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.stree.txt new file mode 100644 index 0000000000..2637f539e7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenCatchAndFinallyClause.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..76)::76 - [@try { bar(); } catch(bar) { baz(); } @* Foo *@ @* Bar *@ finally { biz(); }] + MarkupBlock - [0..76)::76 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..76)::76 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..38)::37 - [try { bar(); } catch(bar) { baz(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorComment - [38..47)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [48..57)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [57..76)::19 - [ finally { biz(); }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[biz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [76..76)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.cspans.txt new file mode 100644 index 0000000000..bc25d70006 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [22] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Comment block at (23:0,23 [9] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Comment block at (23:0,23 [9] ) +Comment span at (25:0,25 [5] ) (Accepts:Any) - Parent: Comment block at (23:0,23 [9] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (23:0,23 [9] ) +Transition span at (31:0,31 [1] ) (Accepts:None) - Parent: Comment block at (23:0,23 [9] ) +Code span at (32:0,32 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) +Transition span at (33:0,33 [1] ) (Accepts:None) - Parent: Comment block at (33:0,33 [9] ) +MetaCode span at (34:0,34 [1] ) (Accepts:None) - Parent: Comment block at (33:0,33 [9] ) +Comment span at (35:0,35 [5] ) (Accepts:Any) - Parent: Comment block at (33:0,33 [9] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Comment block at (33:0,33 [9] ) +Transition span at (41:0,41 [1] ) (Accepts:None) - Parent: Comment block at (33:0,33 [9] ) +Code span at (42:0,42 [13] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Markup span at (55:0,55 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.stree.txt new file mode 100644 index 0000000000..381862b355 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenDoAndWhileClause.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..55)::55 - [@do { var foo = bar; } @* Foo *@ @* Bar *@ while(true);] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..23)::22 - [do { var foo = bar; } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorComment - [23..32)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [32..33)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [33..42)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [42..55)::13 - [ while(true);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [55..55)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..18ad30afaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [79] ) +Code span at (1:0,1 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [79] ) +Transition span at (44:0,44 [1] ) (Accepts:None) - Parent: Comment block at (44:0,44 [9] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Comment block at (44:0,44 [9] ) +Comment span at (46:0,46 [5] ) (Accepts:Any) - Parent: Comment block at (44:0,44 [9] ) +MetaCode span at (51:0,51 [1] ) (Accepts:None) - Parent: Comment block at (44:0,44 [9] ) +Transition span at (52:0,52 [1] ) (Accepts:None) - Parent: Comment block at (44:0,44 [9] ) +Code span at (53:0,53 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [79] ) +Transition span at (54:0,54 [1] ) (Accepts:None) - Parent: Comment block at (54:0,54 [9] ) +MetaCode span at (55:0,55 [1] ) (Accepts:None) - Parent: Comment block at (54:0,54 [9] ) +Comment span at (56:0,56 [5] ) (Accepts:Any) - Parent: Comment block at (54:0,54 [9] ) +MetaCode span at (61:0,61 [1] ) (Accepts:None) - Parent: Comment block at (54:0,54 [9] ) +Transition span at (62:0,62 [1] ) (Accepts:None) - Parent: Comment block at (54:0,54 [9] ) +Code span at (63:0,63 [16] ) (Accepts:None) - Parent: Statement block at (0:0,0 [79] ) +Markup span at (79:0,79 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.stree.txt new file mode 100644 index 0000000000..dcf81bd443 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenElseIfAndElseClause.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..79)::79 - [@if(foo) { bar(); } else if(bar) { baz(); } @* Foo *@ @* Bar *@ else { baz(); }] + MarkupBlock - [0..79)::79 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..79)::79 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..44)::43 - [if(foo) { bar(); } else if(bar) { baz(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorComment - [44..53)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [54..63)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [63..79)::16 - [ else { baz(); }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [79..79)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.cspans.txt new file mode 100644 index 0000000000..988b9312cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) +Transition span at (20:0,20 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +Comment span at (22:0,22 [5] ) (Accepts:Any) - Parent: Comment block at (20:0,20 [9] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +Transition span at (28:0,28 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +Code span at (29:0,29 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) +Transition span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +Comment span at (32:0,32 [5] ) (Accepts:Any) - Parent: Comment block at (30:0,30 [9] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +Transition span at (38:0,38 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +Code span at (39:0,39 [16] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Markup span at (55:0,55 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.stree.txt new file mode 100644 index 0000000000..4d0ae9df0d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseClause.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..55)::55 - [@if(foo) { bar(); } @* Foo *@ @* Bar *@ else { baz(); }] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..20)::19 - [if(foo) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorComment - [20..29)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [30..39)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [39..55)::16 - [ else { baz(); }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [55..55)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.cspans.txt new file mode 100644 index 0000000000..7884e3972d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [63] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [63] ) +Transition span at (20:0,20 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +Comment span at (22:0,22 [5] ) (Accepts:Any) - Parent: Comment block at (20:0,20 [9] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +Transition span at (28:0,28 [1] ) (Accepts:None) - Parent: Comment block at (20:0,20 [9] ) +Code span at (29:0,29 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [63] ) +Transition span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +Comment span at (32:0,32 [5] ) (Accepts:Any) - Parent: Comment block at (30:0,30 [9] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +Transition span at (38:0,38 [1] ) (Accepts:None) - Parent: Comment block at (30:0,30 [9] ) +Code span at (39:0,39 [24] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [63] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.stree.txt new file mode 100644 index 0000000000..9e6d75fb2e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenIfAndElseIfClause.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..63)::63 - [@if(foo) { bar(); } @* Foo *@ @* Bar *@ else if(bar) { baz(); }] + MarkupBlock - [0..63)::63 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..63)::63 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..20)::19 - [if(foo) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorComment - [20..29)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [30..39)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [39..63)::24 - [ else if(bar) { baz(); }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.cspans.txt new file mode 100644 index 0000000000..4c91176796 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +Comment span at (17:0,17 [5] ) (Accepts:Any) - Parent: Comment block at (15:0,15 [9] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Comment block at (15:0,15 [9] ) +Code span at (24:0,24 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) +Transition span at (25:0,25 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +Comment span at (27:0,27 [5] ) (Accepts:Any) - Parent: Comment block at (25:0,25 [9] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +Transition span at (33:0,33 [1] ) (Accepts:None) - Parent: Comment block at (25:0,25 [9] ) +Code span at (34:0,34 [22] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.stree.txt new file mode 100644 index 0000000000..16457cd82d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndCatchClause.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..56)::56 - [@try { bar(); }@* Foo *@ @* Bar *@ catch(bar) { baz(); }] + MarkupBlock - [0..56)::56 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..56)::56 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..15)::14 - [try { bar(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + RazorComment - [15..24)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [25..34)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [34..56)::22 - [ catch(bar) { baz(); }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.cspans.txt new file mode 100644 index 0000000000..404343ecca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Code span at (1:0,1 [15] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) +Transition span at (16:0,16 [1] ) (Accepts:None) - Parent: Comment block at (16:0,16 [9] ) +MetaCode span at (17:0,17 [1] ) (Accepts:None) - Parent: Comment block at (16:0,16 [9] ) +Comment span at (18:0,18 [5] ) (Accepts:Any) - Parent: Comment block at (16:0,16 [9] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Comment block at (16:0,16 [9] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Comment block at (16:0,16 [9] ) +Code span at (25:0,25 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) +Transition span at (26:0,26 [1] ) (Accepts:None) - Parent: Comment block at (26:0,26 [9] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Comment block at (26:0,26 [9] ) +Comment span at (28:0,28 [5] ) (Accepts:Any) - Parent: Comment block at (26:0,26 [9] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Comment block at (26:0,26 [9] ) +Transition span at (34:0,34 [1] ) (Accepts:None) - Parent: Comment block at (26:0,26 [9] ) +Code span at (35:0,35 [19] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Markup span at (54:0,54 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.stree.txt new file mode 100644 index 0000000000..0cc98a8834 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsRazorCommentBetweenTryAndFinallyClause.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..54)::54 - [@try { bar(); } @* Foo *@ @* Bar *@ finally { biz(); }] + MarkupBlock - [0..54)::54 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..54)::54 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..16)::15 - [try { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorComment - [16..25)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Foo ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [26..35)::9 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Bar ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [35..54)::19 - [ finally { biz(); }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[biz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [54..54)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.cspans.txt new file mode 100644 index 0000000000..eef6075fd7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Code span at (1:0,1 [55] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Markup span at (56:0,56 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.stree.txt new file mode 100644 index 0000000000..0ce89b760f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithFinallyClause.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..56)::56 - [@try { var foo = new { } } finally { var foo = new { } }] + MarkupBlock - [0..56)::56 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..56)::56 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..56)::55 - [try { var foo = new { } } finally { var foo = new { } }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [56..56)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.cspans.txt new file mode 100644 index 0000000000..3c1c9fd7ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [149] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [149] ) +Code span at (1:0,1 [148] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [149] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.stree.txt new file mode 100644 index 0000000000..54504a9e05 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithMultipleCatchClause.stree.txt @@ -0,0 +1,100 @@ +RazorDocument - [0..149)::149 - [@try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }] + MarkupBlock - [0..149)::149 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..149)::149 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..149)::148 - [try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.cspans.txt new file mode 100644 index 0000000000..6f701b216f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (1:0,1 [25] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.stree.txt new file mode 100644 index 0000000000..944a321a80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithNoAdditionalClauses.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..26)::26 - [@try { var foo = new { } }] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..26)::25 - [try { var foo = new { } }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.cspans.txt new file mode 100644 index 0000000000..2d883a5590 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [67] ) +Code span at (1:0,1 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [67] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.stree.txt new file mode 100644 index 0000000000..976171e701 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsTryStatementWithOneCatchClause.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..67)::67 - [@try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }] + MarkupBlock - [0..67)::67 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..67)::67 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..67)::66 - [try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Identifier;[Baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.cspans.txt new file mode 100644 index 0000000000..40ccbbdea5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [97] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [97] ) +Code span at (1:0,1 [96] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [97] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.stree.txt new file mode 100644 index 0000000000..5632b74d2f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SupportsUsingsNestedWithinOtherBlocks.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..97)::97 - [@if(foo) { using(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); } }] + MarkupBlock - [0..97)::97 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..97)::97 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..97)::96 - [if(foo) { using(int i = 0; i < 10; new Foo { Bar = "baz" }) { Debug.WriteLine(@"foo } bar"); } }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Keyword;[using]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["baz"]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..2ed26af598 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Code span at (1:0,1 [38] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.diag.txt new file mode 100644 index 0000000000..98a67406d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,26): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.stree.txt new file mode 100644 index 0000000000..6a21bad8d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesBlockCommentAtEndOfFile.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..39)::39 - [@foreach(var f in Foo) { /* foo bar baz] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..39)::38 - [foreach(var f in Foo) { /* foo bar baz] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[f]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpComment;[/* foo bar baz];RZ1001(25:0,25 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.cspans.txt new file mode 100644 index 0000000000..3f873f6ea4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.diag.txt new file mode 100644 index 0000000000..a40df1a410 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.stree.txt new file mode 100644 index 0000000000..c52a1189f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesParenBalancingAtEOF.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..15)::15 - [@Html.En(code()] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpImplicitExpression - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..15)::14 + CSharpCodeBlock - [1..15)::14 + CSharpExpressionLiteral - [1..15)::14 - [Html.En(code()] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[En]; + LeftParenthesis;[(]; + Identifier;[code]; + LeftParenthesis;[(]; + RightParenthesis;[)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..2ed26af598 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Code span at (1:0,1 [38] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.diag.txt new file mode 100644 index 0000000000..06bf6f2dca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.stree.txt new file mode 100644 index 0000000000..256845d49c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleLineCommentAtEndOfFile.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..39)::39 - [@foreach(var f in Foo) { // foo bar baz] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..39)::38 - [foreach(var f in Foo) { // foo bar baz] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[f]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpComment;[// foo bar baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..7326485a95 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Code span at (1:0,1 [37] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.diag.txt new file mode 100644 index 0000000000..06bf6f2dca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.stree.txt new file mode 100644 index 0000000000..106b2c81a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesSingleSlashAtEndOfFile.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..38)::38 - [@foreach(var f in Foo) { / foo bar baz] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..38)::37 - [foreach(var f in Foo) { / foo bar baz] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[f]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Slash;[/]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + Whitespace;[ ]; + Identifier;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.cspans.txt new file mode 100644 index 0000000000..6f701b216f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (1:0,1 [25] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.stree.txt new file mode 100644 index 0000000000..7d0351183f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock.stree.txt @@ -0,0 +1,10 @@ +RazorDocument - [0..26)::26 - [@using ] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..26)::25 - [using ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[using]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.cspans.txt new file mode 100644 index 0000000000..3b430f9f07 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +Code span at (1:0,1 [44] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +Markup span at (45:0,45 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.stree.txt new file mode 100644 index 0000000000..0f6a422fa2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/ThenBalancesBracesIfFirstIdentifierIsLockKeyword.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..45)::45 - [@lock(foo) { Debug.WriteLine(@"foo } bar"); }] + MarkupBlock - [0..45)::45 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..45)::45 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..45)::44 - [lock(foo) { Debug.WriteLine(@"foo } bar"); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[lock]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Debug]; + Dot;[.]; + Identifier;[WriteLine]; + LeftParenthesis;[(]; + StringLiteral;[@"foo } bar"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.cspans.txt new file mode 100644 index 0000000000..bb6bc45bc9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +Code span at (11:0,11 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +Code span at (12:0,12 [16] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.stree.txt new file mode 100644 index 0000000000..a47868ef01 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..28)::28 - [@if(foo) { @@@@class.Foo() }] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..11)::10 - [if(foo) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpEphemeralTextLiteral - [11..12)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + CSharpStatementLiteral - [12..28)::16 - [@@@class.Foo() }] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Transition;[@]; + Transition;[@]; + Keyword;[class]; + Dot;[.]; + Identifier;[Foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.cspans.txt new file mode 100644 index 0000000000..74119a5b92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Code span at (11:0,11 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Code span at (12:0,12 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.stree.txt new file mode 100644 index 0000000000..3996000291 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..26)::26 - [@if(foo) { @@class.Foo() }] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..11)::10 - [if(foo) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpEphemeralTextLiteral - [11..12)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + CSharpStatementLiteral - [12..26)::14 - [@class.Foo() }] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Keyword;[class]; + Dot;[.]; + Identifier;[Foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..867c9d5eae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [20] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [12] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (14:0,14 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [12] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [12] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [20] ) +Code span at (22:0,22 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..b08e365411 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..23)::23 - [@{}] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupElement - [2..22)::20 + MarkupStartTag - [2..22)::20 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..19)::12 - [ foo='@@def'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..18)::5 + MarkupBlock - [13..15)::2 + MarkupTextLiteral - [13..14)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [14..15)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [15..18)::3 - [def] + MarkupTextLiteral - [15..18)::3 - [def] - Gen - SpanEditHandler;Accepts:Any + Text;[def]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..2af0b84813 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [20] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Markup block at (16:0,16 [2] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (16:0,16 [2] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [12] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [20] ) +Code span at (22:0,22 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..439763c3fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..23)::23 - [@{}] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupElement - [2..22)::20 + MarkupStartTag - [2..22)::20 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..19)::12 - [ foo='abc@@'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..18)::5 + MarkupLiteralAttributeValue - [13..16)::3 - [abc] + MarkupTextLiteral - [13..16)::3 - [abc] - Gen - SpanEditHandler;Accepts:Any + Text;[abc]; + MarkupBlock - [16..18)::2 + MarkupTextLiteral - [16..17)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [17..18)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..7af2be2c26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [25] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (16:0,16 [2] ) (Accepts:None) - Parent: Markup block at (16:0,16 [3] ) +Markup span at (18:0,18 [1] ) (Accepts:None) - Parent: Markup block at (16:0,16 [3] ) +Markup span at (19:0,19 [4] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (24:0,24 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [25] ) +Code span at (27:0,27 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..b32d5a6822 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionBetweenAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..28)::28 - [@{}] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + CSharpStatement - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..28)::27 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..27)::25 + MarkupBlock - [2..27)::25 + MarkupElement - [2..27)::25 + MarkupStartTag - [2..27)::25 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..24)::17 - [ foo='abc @@ def'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..23)::10 + MarkupLiteralAttributeValue - [13..16)::3 - [abc] + MarkupTextLiteral - [13..16)::3 - [abc] - Gen - SpanEditHandler;Accepts:Any + Text;[abc]; + MarkupBlock - [16..19)::3 + MarkupTextLiteral - [16..18)::2 - [ @] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Transition;[@]; + MarkupEphemeralTextLiteral - [18..19)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [19..23)::4 - [ def] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..23)::3 - [def] - Gen - SpanEditHandler;Accepts:Any + Text;[def]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [24..25)::1 + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [27..28)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..391706d146 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [17] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [9] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (14:0,14 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [9] ) +Markup span at (16:0,16 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [17] ) +Code span at (19:0,19 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (19:0,19 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..9a403936c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInAttributeValue_DoesNotThrow.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..20)::20 - [@{}] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..19)::17 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..16)::9 - [ foo='@@'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..15)::2 + MarkupBlock - [13..15)::2 + MarkupTextLiteral - [13..14)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [14..15)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [19..20)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..26e0bdca06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [42] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [34] ) +Markup span at (13:0,13 [11] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [34] ) +Markup span at (24:0,24 [4] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [34] ) +Markup span at (28:0,28 [1] ) (Accepts:None) - Parent: Markup block at (28:0,28 [2] ) +Markup span at (29:0,29 [1] ) (Accepts:None) - Parent: Markup block at (28:0,28 [2] ) +Markup span at (30:0,30 [7] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [34] ) +Markup span at (37:0,37 [2] ) (Accepts:None) - Parent: Markup block at (37:0,37 [3] ) +Markup span at (39:0,39 [1] ) (Accepts:None) - Parent: Markup block at (37:0,37 [3] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [34] ) +Markup span at (41:0,41 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [42] ) +Code span at (44:0,44 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [45] ) +MetaCode span at (44:0,44 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +Markup span at (45:0,45 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..480eaf7a51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInEmail_DoesNotThrow.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..45)::45 - [@{}] + MarkupBlock - [0..45)::45 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..45)::45 + CSharpStatement - [0..45)::45 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..45)::44 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..44)::42 + MarkupBlock - [2..44)::42 + MarkupElement - [2..44)::42 + MarkupStartTag - [2..44)::42 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..41)::34 - [ foo='abc@def.com abc@@def.com @@'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..40)::27 + MarkupLiteralAttributeValue - [13..24)::11 - [abc@def.com] + MarkupTextLiteral - [13..24)::11 - [abc@def.com] - Gen - SpanEditHandler;Accepts:Any + Text;[abc@def.com]; + MarkupLiteralAttributeValue - [24..28)::4 - [ abc] + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [25..28)::3 - [abc] - Gen - SpanEditHandler;Accepts:Any + Text;[abc]; + MarkupBlock - [28..30)::2 + MarkupTextLiteral - [28..29)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [29..30)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [30..37)::7 - [def.com] + MarkupTextLiteral - [30..37)::7 - [def.com] - Gen - SpanEditHandler;Accepts:Any + Text;[def.com]; + MarkupBlock - [37..40)::3 + MarkupTextLiteral - [37..39)::2 - [ @] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Transition;[@]; + MarkupEphemeralTextLiteral - [39..40)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [40..41)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [41..42)::1 + MarkupTextLiteral - [41..42)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..bc10454e41 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [118] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [118] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [118] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [115] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [107] ) +Markup span at (13:0,13 [32] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [107] ) +Markup span at (45:0,45 [1] ) (Accepts:None) - Parent: Markup block at (45:0,45 [2] ) +Markup span at (46:0,46 [1] ) (Accepts:None) - Parent: Markup block at (45:0,45 [2] ) +Markup span at (47:0,47 [66] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [107] ) +Markup span at (113:0,113 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [107] ) +Markup span at (114:0,114 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [115] ) +Code span at (117:0,117 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [118] ) +MetaCode span at (117:0,117 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [118] ) +Markup span at (118:0,118 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [118] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..3f25fa1782 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionInRegex_DoesNotThrow.stree.txt @@ -0,0 +1,92 @@ +RazorDocument - [0..118)::118 - [@{}] + MarkupBlock - [0..118)::118 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..118)::118 + CSharpStatement - [0..118)::118 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..118)::117 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..117)::115 + MarkupBlock - [2..117)::115 + MarkupElement - [2..117)::115 + MarkupStartTag - [2..117)::115 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..114)::107 - [ foo="/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..113)::100 + MarkupLiteralAttributeValue - [13..45)::32 - [/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+] + MarkupTextLiteral - [13..45)::32 - [/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + Text;[^]; + LeftBracket;[[]; + Text;[a-z0-9]; + Bang;[!]; + Text;[#$%&]; + SingleQuote;[']; + Text;[*+\]; + ForwardSlash;[/]; + Equals;[=]; + QuestionMark;[?]; + Text;[^_`{|}~.-]; + RightBracket;[]]; + Text;[+]; + MarkupBlock - [45..47)::2 + MarkupTextLiteral - [45..46)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [46..47)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [47..113)::66 - [[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i] + MarkupTextLiteral - [47..113)::66 - [[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[a-z0-9]; + RightBracket;[]]; + Text;[(]; + LeftBracket;[[]; + Text;[a-z0-9-]; + RightBracket;[]]; + Text;[*]; + LeftBracket;[[]; + Text;[a-z0-9]; + RightBracket;[]]; + Text;[)]; + QuestionMark;[?]; + Text;[\.(]; + LeftBracket;[[]; + Text;[a-z0-9]; + RightBracket;[]]; + Text;[(]; + LeftBracket;[[]; + Text;[a-z0-9-]; + RightBracket;[]]; + Text;[*]; + LeftBracket;[[]; + Text;[a-z0-9]; + RightBracket;[]]; + Text;[)]; + QuestionMark;[?]; + Text;[)*$]; + ForwardSlash;[/]; + Text;[i]; + MarkupTextLiteral - [113..114)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [114..115)::1 + MarkupTextLiteral - [114..115)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [117..117)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [117..118)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [118..118)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..cac77c7065 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.cspans.txt @@ -0,0 +1,47 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [121] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [121] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [121] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [118] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [15] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (14:0,14 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (15:0,15 [0] ) (Accepts:Any) - Parent: Markup block at (15:0,15 [6] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +Code span at (17:0,17 [3] ) (Accepts:Any) - Parent: Expression block at (15:0,15 [6] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +Markup span at (21:0,21 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [15] ) +Markup span at (22:0,22 [6] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [28] ) +Transition span at (28:0,28 [1] ) (Accepts:None) - Parent: Expression block at (28:0,28 [6] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Expression block at (28:0,28 [6] ) +Code span at (30:0,30 [3] ) (Accepts:Any) - Parent: Expression block at (28:0,28 [6] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Expression block at (28:0,28 [6] ) +Markup span at (34:0,34 [1] ) (Accepts:None) - Parent: Markup block at (34:0,34 [2] ) +Markup span at (35:0,35 [1] ) (Accepts:None) - Parent: Markup block at (34:0,34 [2] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [13] ) +Transition span at (36:0,36 [1] ) (Accepts:None) - Parent: Expression block at (36:0,36 [13] ) +Code span at (37:0,37 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (36:0,36 [13] ) +Markup span at (49:0,49 [1] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [28] ) +Markup span at (50:0,50 [6] ) (Accepts:Any) - Parent: Markup block at (50:0,50 [22] ) +Transition span at (56:0,56 [1] ) (Accepts:None) - Parent: Expression block at (56:0,56 [13] ) +Code span at (57:0,57 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (56:0,56 [13] ) +Markup span at (69:0,69 [1] ) (Accepts:None) - Parent: Markup block at (69:0,69 [2] ) +Markup span at (70:0,70 [1] ) (Accepts:None) - Parent: Markup block at (69:0,69 [2] ) +Markup span at (71:0,71 [1] ) (Accepts:Any) - Parent: Markup block at (50:0,50 [22] ) +Markup span at (72:0,72 [6] ) (Accepts:Any) - Parent: Markup block at (72:0,72 [23] ) +Transition span at (78:0,78 [1] ) (Accepts:None) - Parent: Expression block at (78:0,78 [13] ) +Code span at (79:0,79 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (78:0,78 [13] ) +Markup span at (91:0,91 [2] ) (Accepts:None) - Parent: Markup block at (91:0,91 [3] ) +Markup span at (93:0,93 [1] ) (Accepts:None) - Parent: Markup block at (91:0,91 [3] ) +Markup span at (94:0,94 [1] ) (Accepts:Any) - Parent: Markup block at (72:0,72 [23] ) +Markup span at (95:0,95 [6] ) (Accepts:Any) - Parent: Markup block at (95:0,95 [22] ) +Markup span at (101:0,101 [1] ) (Accepts:None) - Parent: Markup block at (101:0,101 [2] ) +Markup span at (102:0,102 [1] ) (Accepts:None) - Parent: Markup block at (101:0,101 [2] ) +Markup span at (103:0,103 [0] ) (Accepts:Any) - Parent: Markup block at (103:0,103 [13] ) +Transition span at (103:0,103 [1] ) (Accepts:None) - Parent: Expression block at (103:0,103 [13] ) +Code span at (104:0,104 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (103:0,103 [13] ) +Markup span at (116:0,116 [1] ) (Accepts:Any) - Parent: Markup block at (95:0,95 [22] ) +Markup span at (117:0,117 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [118] ) +Code span at (120:0,120 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [121] ) +MetaCode span at (120:0,120 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [121] ) +Markup span at (121:0,121 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [121] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..9b4efd9401 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransitionWithExpressionBlock_DoesNotThrow.stree.txt @@ -0,0 +1,195 @@ +RazorDocument - [0..121)::121 - [@{}] + MarkupBlock - [0..121)::121 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..121)::121 + CSharpStatement - [0..121)::121 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..121)::120 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..120)::118 + MarkupBlock - [2..120)::118 + MarkupElement - [2..120)::118 + MarkupStartTag - [2..120)::118 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..22)::15 - [ foo='@@@(2+3)'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..21)::8 + MarkupBlock - [13..15)::2 + MarkupTextLiteral - [13..14)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [14..15)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupDynamicAttributeValue - [15..21)::6 - [@(2+3)] + GenericBlock - [15..21)::6 + MarkupTextLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [15..21)::6 + CSharpExplicitExpression - [15..21)::6 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [16..21)::5 + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [17..20)::3 + CSharpExpressionLiteral - [17..20)::3 - [2+3] - Gen - SpanEditHandler;Accepts:Any + IntegerLiteral;[2]; + Plus;[+]; + IntegerLiteral;[3]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [22..50)::28 - [ bar='@(2+3)@@@DateTime.Now'] + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [23..26)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [28..49)::21 + MarkupDynamicAttributeValue - [28..34)::6 - [@(2+3)] + GenericBlock - [28..34)::6 + CSharpCodeBlock - [28..34)::6 + CSharpExplicitExpression - [28..34)::6 + CSharpTransition - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [29..34)::5 + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [30..33)::3 + CSharpExpressionLiteral - [30..33)::3 - [2+3] - Gen - SpanEditHandler;Accepts:Any + IntegerLiteral;[2]; + Plus;[+]; + IntegerLiteral;[3]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupBlock - [34..36)::2 + MarkupTextLiteral - [34..35)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [35..36)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupDynamicAttributeValue - [36..49)::13 - [@DateTime.Now] + GenericBlock - [36..49)::13 + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [36..49)::13 + CSharpImplicitExpression - [36..49)::13 + CSharpTransition - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [37..49)::12 + CSharpCodeBlock - [37..49)::12 + CSharpExpressionLiteral - [37..49)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [49..50)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [50..72)::22 - [ baz='@DateTime.Now@@'] + MarkupTextLiteral - [50..51)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [51..54)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + Equals;[=]; + MarkupTextLiteral - [55..56)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [56..71)::15 + MarkupDynamicAttributeValue - [56..69)::13 - [@DateTime.Now] + GenericBlock - [56..69)::13 + CSharpCodeBlock - [56..69)::13 + CSharpImplicitExpression - [56..69)::13 + CSharpTransition - [56..57)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [57..69)::12 + CSharpCodeBlock - [57..69)::12 + CSharpExpressionLiteral - [57..69)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupBlock - [69..71)::2 + MarkupTextLiteral - [69..70)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [70..71)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [71..72)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [72..95)::23 - [ bat='@DateTime.Now @@'] + MarkupTextLiteral - [72..73)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [73..76)::3 - [bat] - Gen - SpanEditHandler;Accepts:Any + Text;[bat]; + Equals;[=]; + MarkupTextLiteral - [77..78)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [78..94)::16 + MarkupDynamicAttributeValue - [78..91)::13 - [@DateTime.Now] + GenericBlock - [78..91)::13 + CSharpCodeBlock - [78..91)::13 + CSharpImplicitExpression - [78..91)::13 + CSharpTransition - [78..79)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [79..91)::12 + CSharpCodeBlock - [79..91)::12 + CSharpExpressionLiteral - [79..91)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupBlock - [91..94)::3 + MarkupTextLiteral - [91..93)::2 - [ @] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Transition;[@]; + MarkupEphemeralTextLiteral - [93..94)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [94..95)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [95..117)::22 - [ zoo='@@@DateTime.Now'] + MarkupTextLiteral - [95..96)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [96..99)::3 - [zoo] - Gen - SpanEditHandler;Accepts:Any + Text;[zoo]; + Equals;[=]; + MarkupTextLiteral - [100..101)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [101..116)::15 + MarkupBlock - [101..103)::2 + MarkupTextLiteral - [101..102)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [102..103)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupDynamicAttributeValue - [103..116)::13 - [@DateTime.Now] + GenericBlock - [103..116)::13 + MarkupTextLiteral - [103..103)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [103..116)::13 + CSharpImplicitExpression - [103..116)::13 + CSharpTransition - [103..104)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [104..116)::12 + CSharpCodeBlock - [104..116)::12 + CSharpExpressionLiteral - [104..116)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [116..117)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [117..118)::1 + MarkupTextLiteral - [117..118)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [120..120)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [120..121)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [121..121)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.cspans.txt new file mode 100644 index 0000000000..833ee8ad8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [13] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [8] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) +Markup span at (14:0,14 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.diag.txt new file mode 100644 index 0000000000..a4e40cedd4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "span" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                    ") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.stree.txt new file mode 100644 index 0000000000..da26fe2d8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithDoubleTransition_EndOfFile_Throws.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..15)::15 - [@{ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..15)::8 - [ foo='@@] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..15)::2 + MarkupBlock - [13..15)::2 + MarkupTextLiteral - [13..14)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [14..15)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CloseAngle;[]; + RazorMetaCode - [15..15)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.cspans.txt new file mode 100644 index 0000000000..00335db4a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [10] ) +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Expression block at (13:0,13 [1] ) +Code span at (14:0,14 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (13:0,13 [1] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [2] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [1] ) +Code span at (16:0,16 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (15:0,15 [1] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [10] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [18] ) +Code span at (20:0,20 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.diag.txt new file mode 100644 index 0000000000..4f60a724cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.diag.txt @@ -0,0 +1,2 @@ +(1,15): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. +(1,17): Error RZ1005: "' />}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt new file mode 100644 index 0000000000..b869f26632 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..21)::21 - [@{}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..20)::18 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..17)::10 - [ foo='@ @'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..16)::3 + MarkupDynamicAttributeValue - [13..14)::1 - [@] + GenericBlock - [13..14)::1 + CSharpCodeBlock - [13..14)::1 + CSharpImplicitExpression - [13..14)::1 + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [14..14)::0 + CSharpCodeBlock - [14..14)::0 + CSharpExpressionLiteral - [14..14)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupDynamicAttributeValue - [14..16)::2 - [ @] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + GenericBlock - [15..16)::1 + CSharpCodeBlock - [15..16)::1 + CSharpImplicitExpression - [15..16)::1 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [16..16)::0 + CSharpCodeBlock - [16..16)::0 + CSharpExpressionLiteral - [16..16)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.cspans.txt new file mode 100644 index 0000000000..e0217056a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +Code span at (1:0,1 [17] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (18:1,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.stree.txt new file mode 100644 index 0000000000..813ee4da1e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..20)::20 - [@using LFLF] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..18)::17 - [using LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[using]; + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [18..20)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.cspans.txt new file mode 100644 index 0000000000..d1b305fbf1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:1,0 [4] ) (Accepts:Any) - Parent: Tag block at (8:1,0 [4] ) +Transition span at (12:1,4 [1] ) (Accepts:None) - Parent: Expression block at (12:1,4 [14] ) +Code span at (13:1,5 [13] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:1,4 [14] ) +Markup span at (26:1,18 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Markup span at (27:1,19 [5] ) (Accepts:Any) - Parent: Tag block at (27:1,19 [5] ) +Markup span at (32:1,24 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diag.txt new file mode 100644 index 0000000000..6cb7c82385 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.stree.txt new file mode 100644 index 0000000000..e576a17c44 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..34)::34 - [@Href(LF

                    @Html.Foo(Bar);

                    LF] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [Href(LF] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Href]; + LeftParenthesis;[(]; + NewLine;[LF]; + MarkupElement - [8..32)::24 + MarkupStartTag - [8..12)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[h1]; + CloseAngle;[>]; + CSharpCodeBlock - [12..26)::14 + CSharpImplicitExpression - [12..26)::14 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..26)::13 + CSharpCodeBlock - [13..26)::13 + CSharpExpressionLiteral - [13..26)::13 - [Html.Foo(Bar)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Foo]; + LeftParenthesis;[(]; + Identifier;[Bar]; + RightParenthesis;[)]; + MarkupTextLiteral - [26..27)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; + MarkupEndTag - [27..32)::5 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[h1]; + CloseAngle;[>]; + MarkupTextLiteral - [32..34)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.cspans.txt new file mode 100644 index 0000000000..1ee270f4e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [47] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [47] ) +Code span at (2:0,2 [44] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [47] ) +MetaCode span at (46:0,46 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [47] ) +Markup span at (47:0,47 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.stree.txt new file mode 100644 index 0000000000..5825be2c7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesAtSignInDelimitedBlock.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..47)::47 - [@(Request["description"] ?? @photo.Description)] + MarkupBlock - [0..47)::47 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..47)::47 + CSharpExplicitExpression - [0..47)::47 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..47)::46 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..46)::44 + CSharpExpressionLiteral - [2..46)::44 - [Request["description"] ?? @photo.Description] - Gen - SpanEditHandler;Accepts:Any + Identifier;[Request]; + LeftBracket;[[]; + StringLiteral;["description"]; + RightBracket;[]]; + Whitespace;[ ]; + NullCoalesce;[??]; + Whitespace;[ ]; + Transition;[@]; + Identifier;[photo]; + Dot;[.]; + Identifier;[Description]; + RazorMetaCode - [46..47)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.cspans.txt new file mode 100644 index 0000000000..c8c6ac23dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [65] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [65] ) +Code span at (1:0,1 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [65] ) +Markup span at (44:2,4 [3] ) (Accepts:None) - Parent: Tag block at (44:2,4 [3] ) +Markup span at (47:2,7 [7] ) (Accepts:Any) - Parent: Markup block at (44:2,4 [20] ) +Transition span at (54:2,14 [1] ) (Accepts:None) - Parent: Expression block at (54:2,14 [4] ) +Code span at (55:2,15 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (54:2,14 [4] ) +Markup span at (58:2,18 [4] ) (Accepts:None) - Parent: Tag block at (58:2,18 [4] ) +Markup span at (62:2,22 [2] ) (Accepts:None) - Parent: Markup block at (44:2,4 [20] ) +Code span at (64:3,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [65] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diag.txt new file mode 100644 index 0000000000..749c29cf56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diag.txt @@ -0,0 +1 @@ +(2,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.stree.txt new file mode 100644 index 0000000000..57d38b45fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..65)::65 - [@if(foo) {LF var foo = "foo bar bazLF

                    Foo is @foo

                    LF}] + MarkupBlock - [0..65)::65 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..65)::65 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..44)::43 - [if(foo) {LF var foo = "foo bar bazLF ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["foo bar baz];RZ1000(26:1,14 [1] ) + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [44..64)::20 + MarkupElement - [44..62)::18 + MarkupStartTag - [44..47)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [47..54)::7 - [Foo is ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[is]; + Whitespace;[ ]; + CSharpCodeBlock - [54..58)::4 + CSharpImplicitExpression - [54..58)::4 + CSharpTransition - [54..55)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [55..58)::3 + CSharpCodeBlock - [55..58)::3 + CSharpExpressionLiteral - [55..58)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupEndTag - [58..62)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [62..64)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [64..65)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.cspans.txt new file mode 100644 index 0000000000..7faf3199b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Code span at (2:0,2 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (16:0,16 [6] ) (Accepts:None) - Parent: Tag block at (16:0,16 [6] ) +Markup span at (22:0,22 [7] ) (Accepts:None) - Parent: Tag block at (22:0,22 [7] ) +Code span at (29:0,29 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diag.txt new file mode 100644 index 0000000000..b356fede3b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.stree.txt new file mode 100644 index 0000000000..96792af995 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..30)::30 - [@{string.Format(}] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpStatement - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..30)::29 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..29)::27 + CSharpStatementLiteral - [2..16)::14 - [string.Format(] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Keyword;[string]; + Dot;[.]; + Identifier;[Format]; + LeftParenthesis;[(]; + MarkupBlock - [16..29)::13 + MarkupElement - [16..29)::13 + MarkupStartTag - [16..22)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; + MarkupEndTag - [22..29)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[html]; + CloseAngle;[>]; + CSharpStatementLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.cspans.txt new file mode 100644 index 0000000000..d06a3a71b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.diag.txt new file mode 100644 index 0000000000..0179da5b14 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: """ is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.stree.txt new file mode 100644 index 0000000000..585e50aec9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/HandlesQuotesAfterTransition.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..2)::2 - [@"] + MarkupBlock - [0..2)::2 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..2)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.cspans.txt new file mode 100644 index 0000000000..4607de5bf4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:0,10 [18] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.stree.txt new file mode 100644 index 0000000000..ee3891e335 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..28)::28 - [@if(foo)) { var bar = foo; }] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..10)::9 - [if(foo)) ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + RightParenthesis;[)]; + Whitespace;[ ]; + MarkupTextLiteral - [10..28)::18 - [{ var bar = foo; }] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[bar]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[foo;]; + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.cspans.txt new file mode 100644 index 0000000000..5f99762a70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [2] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.stree.txt new file mode 100644 index 0000000000..4a57c97b59 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..2)::2 - [@{] + MarkupBlock - [0..2)::2 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..2)::2 + CSharpStatement - [0..2)::2 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..2)::1 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..2)::0 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + Marker;[]; + RazorMetaCode - [2..2)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.cspans.txt new file mode 100644 index 0000000000..48059498d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [3] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [3] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [3] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [3] ) +MetaCode span at (2:0,2 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [3] ) +Markup span at (3:0,3 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.stree.txt new file mode 100644 index 0000000000..0c76b47c33 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..3)::3 - [@{}] + MarkupBlock - [0..3)::3 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..3)::3 + CSharpStatement - [0..3)::3 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..3)::2 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..2)::0 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + RazorMetaCode - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [3..3)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.cspans.txt new file mode 100644 index 0000000000..31bcda0391 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diag.txt new file mode 100644 index 0000000000..84fe5838bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.stree.txt new file mode 100644 index 0000000000..80bf05811c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..4)::4 - [@!!!] + MarkupBlock - [0..4)::4 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..4)::3 - [!!!] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + Bang;[!]; + Bang;[!]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.cspans.txt new file mode 100644 index 0000000000..609209cd3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [9] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [9] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [9] ) +Transition span at (8:1,4 [1] ) (Accepts:None) - Parent: Expression block at (8:1,4 [1] ) +Code span at (9:1,5 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (8:1,4 [1] ) +Code span at (9:1,5 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diag.txt new file mode 100644 index 0000000000..5e816e75b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(2,6): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.stree.txt new file mode 100644 index 0000000000..7d98cc9690 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..9)::9 - [@{LF @] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..9)::9 + CSharpStatement - [0..9)::9 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..9)::8 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + CSharpCodeBlock - [8..9)::1 + CSharpImplicitExpression - [8..9)::1 + CSharpTransition - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [9..9)::0 + CSharpCodeBlock - [9..9)::0 + CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Marker;[]; + CSharpStatementLiteral - [9..9)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [9..9)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.cspans.txt new file mode 100644 index 0000000000..ab0be729ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [3] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.diag.txt new file mode 100644 index 0000000000..1a4e7725a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.stree.txt new file mode 100644 index 0000000000..178b2eab31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfNewlineFollowsTransition.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..3)::3 - [@LF] + MarkupBlock - [0..3)::3 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..3)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.cspans.txt new file mode 100644 index 0000000000..4b4aec9b7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) +Transition span at (8:1,4 [1] ) (Accepts:None) - Parent: Expression block at (8:1,4 [1] ) +Code span at (9:1,5 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (8:1,4 [1] ) +Code span at (9:1,5 [7] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (16:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (17:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.diag.txt new file mode 100644 index 0000000000..a8f6dc0930 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.diag.txt @@ -0,0 +1 @@ +(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt new file mode 100644 index 0000000000..5dbe63612f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..17)::17 - [@{LF @ {}LF}] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpStatement - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..17)::16 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..16)::14 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + CSharpCodeBlock - [8..9)::1 + CSharpImplicitExpression - [8..9)::1 + CSharpTransition - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [9..9)::0 + CSharpCodeBlock - [9..9)::0 + CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Marker;[]; + CSharpStatementLiteral - [9..16)::7 - [ {}LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + LeftBrace;[{]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.cspans.txt new file mode 100644 index 0000000000..448f2a72aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [13] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Markup block at (10:0,10 [13] ) +Markup span at (12:0,12 [3] ) (Accepts:None) - Parent: Tag block at (12:0,12 [3] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [13] ) +Markup span at (18:0,18 [4] ) (Accepts:None) - Parent: Tag block at (18:0,18 [4] ) +Markup span at (22:0,22 [1] ) (Accepts:None) - Parent: Markup block at (10:0,10 [13] ) +Code span at (23:0,23 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diag.txt new file mode 100644 index 0000000000..ef1b3502c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diag.txt @@ -0,0 +1,5 @@ +(1,12): Error RZ1009: The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + +@if(isLoggedIn) { +

                    Hello, @user!

                    +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.stree.txt new file mode 100644 index 0000000000..a60288cf5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..24)::24 - [@if(foo) { @

                    Bar

                    }] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..10)::9 - [if(foo) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [10..23)::13 + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [12..22)::10 + MarkupStartTag - [12..15)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [15..18)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [18..22)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [23..24)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..c989a85034 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [71] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [71] ) +Code span at (1:0,1 [70] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [71] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..f6ab309156 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,17): Error RZ1006: The catch block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..50d37af8cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfCatchBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..71)::71 - [@try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..71)::71 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..71)::71 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..71)::70 - [try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..229a40e9e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [55] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [55] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [55] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [55] ) +Code span at (12:0,12 [43] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..7a30f21cb3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,12): Error RZ1006: The functions block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..5cadb1566b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfClassBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..55)::55 - [@functions { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + RazorDirective - [0..55)::55 - Directive:{functions;CodeBlock;Unrestricted} [RZ1006(11:0,11 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..55)::54 + RazorMetaCode - [1..10)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [10..55)::45 + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [12..55)::43 + CSharpStatementLiteral - [12..55)::43 - [ var foo = bar; if(foo != null) { bar(); } ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [55..55)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..0e6427508a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +Code span at (1:0,1 [47] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..3edd08db12 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The do block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..f7c8702df0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfDoBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..48)::48 - [@do { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..48)::48 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..48)::48 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..48)::47 - [do { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..2812db06fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) +Code span at (1:0,1 [68] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [69] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..1304e018e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,21): Error RZ1006: The else block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..4d6a99b223 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..69)::69 - [@if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..69)::69 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..69)::69 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..69)::68 - [if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..a0e62028ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [72] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [72] ) +Code span at (1:0,1 [71] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [72] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..d936a1e08f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,21): Error RZ1006: The else if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..bea3035aeb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfElseIfBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..72)::72 - [@if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..72)::72 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..72)::72 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..72)::71 - [if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..7ce34a75dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [45] ) +Code span at (2:0,2 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..9f3ebb874b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..45)::45 - [@{ var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..45)::45 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..45)::45 + CSharpStatement - [0..45)::45 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..45)::44 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + CSharpStatementLiteral - [2..45)::43 - [ var foo = bar; if(foo != null) { bar(); } ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [45..45)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..efb98ce332 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Code span at (1:0,1 [67] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [68] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..c4ee5afb66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,17): Error RZ1006: The finally block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..7ce1b48905 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfFinallyBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..68)::68 - [@try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..68)::68 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..68)::68 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..68)::67 - [try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[baz]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..5c2cb28925 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [54] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..2b762aec63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The for block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..205adf9089 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..55)::55 - [@for (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..55)::54 - [for (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[for]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..1c6ed575ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [59] ) +Code span at (1:0,1 [58] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..06bf6f2dca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The foreach block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..0572c5b99d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfForeachBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..59)::59 - [@foreach (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..59)::59 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..59)::59 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..59)::58 - [foreach (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..c6237e0e8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [54] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [54] ) +Code span at (1:0,1 [53] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [54] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..2742101ffc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..aa89143967 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfIfBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..54)::54 - [@if (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..54)::54 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..54)::54 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..54)::53 - [if (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..3ac1ad9b09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Code span at (1:0,1 [55] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..08db663674 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The lock block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..759e96286c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfLockBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..56)::56 - [@lock (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..56)::56 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..56)::56 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..56)::55 - [lock (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[lock]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..e601a12186 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [58] ) +Code span at (1:0,1 [57] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [58] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..65ca04a2b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The switch block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..a54583efbf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfSwitchBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..58)::58 - [@switch (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..58)::58 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..58)::58 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..58)::57 - [switch (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[switch]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..ee11c5c511 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Code span at (1:0,1 [48] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..1b9bc8df7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The try block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..7c5b8b4d7d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfTryBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..49)::49 - [@try { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..49)::49 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..49)::49 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..49)::48 - [try { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..160fbdc681 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Code span at (1:0,1 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..1a15e5d491 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The using block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..82d612293e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfUsingBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..57)::57 - [@using (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..57)::56 - [using (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[using]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.cspans.txt new file mode 100644 index 0000000000..160fbdc681 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Code span at (1:0,1 [56] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.diag.txt new file mode 100644 index 0000000000..8eb38d8911 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The while block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.stree.txt new file mode 100644 index 0000000000..fc413e23b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ReportsErrorIfWhileBlockUnterminatedAtEOF.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..57)::57 - [@while (foo) { var foo = bar; if(foo != null) { bar(); } ] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..57)::56 - [while (foo) { var foo = bar; if(foo != null) { bar(); } ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.cspans.txt new file mode 100644 index 0000000000..ab58e6a89e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [59] ) +Code span at (1:0,1 [8] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) +Markup span at (9:0,9 [3] ) (Accepts:None) - Parent: Tag block at (9:0,9 [3] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Markup block at (9:0,9 [11] ) +Markup span at (15:0,15 [4] ) (Accepts:None) - Parent: Tag block at (15:0,15 [4] ) +Markup span at (19:0,19 [1] ) (Accepts:None) - Parent: Markup block at (9:0,9 [11] ) +Code span at (20:0,20 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) +Markup span at (33:0,33 [3] ) (Accepts:None) - Parent: Tag block at (33:0,33 [3] ) +Markup span at (36:0,36 [3] ) (Accepts:Any) - Parent: Markup block at (33:0,33 [11] ) +Markup span at (39:0,39 [4] ) (Accepts:None) - Parent: Tag block at (39:0,39 [4] ) +Markup span at (43:0,43 [1] ) (Accepts:None) - Parent: Markup block at (33:0,33 [11] ) +Code span at (44:0,44 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) +Markup span at (49:0,49 [3] ) (Accepts:None) - Parent: Tag block at (49:0,49 [3] ) +Markup span at (52:0,52 [3] ) (Accepts:Any) - Parent: Markup block at (49:0,49 [10] ) +Markup span at (55:0,55 [4] ) (Accepts:None) - Parent: Tag block at (55:0,55 [4] ) +Code span at (59:0,59 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [59] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt new file mode 100644 index 0000000000..c18bec89a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.diag.txt @@ -0,0 +1,3 @@ +(1,10): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +(1,34): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +(1,50): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.stree.txt new file mode 100644 index 0000000000..8d4a69e823 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/RequiresControlFlowStatementsToHaveBraces.stree.txt @@ -0,0 +1,69 @@ +RazorDocument - [0..59)::59 - [@if(foo)

                    Bar

                    else if(bar)

                    Baz

                    else

                    Boz

                    ] + MarkupBlock - [0..59)::59 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..59)::59 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..9)::8 - [if(foo) ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + MarkupBlock - [9..20)::11 + MarkupElement - [9..19)::10 + MarkupStartTag - [9..12)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [12..15)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [15..19)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [20..33)::13 - [else if(bar) ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + MarkupBlock - [33..44)::11 + MarkupElement - [33..43)::10 + MarkupStartTag - [33..36)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [36..39)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupEndTag - [39..43)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [44..49)::5 - [else ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[else]; + Whitespace;[ ]; + MarkupBlock - [49..59)::10 + MarkupElement - [49..59)::10 + MarkupStartTag - [49..52)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [52..55)::3 - [Boz] - Gen - SpanEditHandler;Accepts:Any + Text;[Boz]; + MarkupEndTag - [55..59)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [59..59)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.cspans.txt new file mode 100644 index 0000000000..326a340872 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Code span at (1:0,1 [11] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (12:1,6 [1] ) (Accepts:Any) - Parent: Markup block at (12:1,6 [12] ) +Markup span at (13:1,7 [3] ) (Accepts:None) - Parent: Tag block at (13:1,7 [3] ) +Markup span at (16:1,10 [3] ) (Accepts:Any) - Parent: Markup block at (12:1,6 [12] ) +Markup span at (19:1,13 [4] ) (Accepts:None) - Parent: Tag block at (19:1,13 [4] ) +Markup span at (23:1,17 [1] ) (Accepts:None) - Parent: Markup block at (12:1,6 [12] ) +Code span at (24:1,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:1,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.diag.txt new file mode 100644 index 0000000000..a08a836e65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.stree.txt new file mode 100644 index 0000000000..15e925d411 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ResumesIfStatementAfterOpenParen.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..25)::25 - [@if(LFelse {

                    Foo

                    }] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..12)::11 - [if(LFelse {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + NewLine;[LF]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [12..24)::12 + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [13..23)::10 + MarkupStartTag - [13..16)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [16..19)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [19..23)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [24..25)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.cspans.txt new file mode 100644 index 0000000000..ac4d17eea7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diag.txt new file mode 100644 index 0000000000..5df09fd668 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.stree.txt new file mode 100644 index 0000000000..aaccbd8bc2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..23)::23 - [@Foo[Bar[Baz]LFBizLFBoz] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpImplicitExpression - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..23)::22 + CSharpCodeBlock - [1..23)::22 + CSharpExpressionLiteral - [1..23)::22 - [Foo[Bar[Baz]LFBizLFBoz] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + LeftBracket;[[]; + Identifier;[Bar]; + LeftBracket;[[]; + Identifier;[Baz]; + RightBracket;[]]; + NewLine;[LF]; + Identifier;[Biz]; + NewLine;[LF]; + Identifier;[Boz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..65434a2d4c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (2:0,2 [12] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..0b063402e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..1780ed95e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..14)::14 - [@(foo barLFbaz] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpExplicitExpression - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..14)::13 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..14)::12 + CSharpExpressionLiteral - [2..14)::12 - [foo barLFbaz] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + NewLine;[LF]; + Identifier;[baz]; + RazorMetaCode - [14..14)::0 - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..ac4d17eea7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..13233f5339 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..23)::23 - [@Foo(Bar(Baz)LFBizLFBoz] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpImplicitExpression - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..23)::22 + CSharpCodeBlock - [1..23)::22 + CSharpExpressionLiteral - [1..23)::22 - [Foo(Bar(Baz)LFBizLFBoz] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + LeftParenthesis;[(]; + Identifier;[Bar]; + LeftParenthesis;[(]; + Identifier;[Baz]; + RightParenthesis;[)]; + NewLine;[LF]; + Identifier;[Biz]; + NewLine;[LF]; + Identifier;[Boz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..fb4c14a8e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [20] ) +Markup span at (20:2,0 [3] ) (Accepts:Any) - Parent: Tag block at (20:2,0 [3] ) +Markup span at (23:2,3 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Markup span at (30:4,0 [4] ) (Accepts:Any) - Parent: Tag block at (30:4,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..5df09fd668 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..d1f2934008 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..34)::34 - [@Foo[Bar[Baz]LFBizLFLFBozLF] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpImplicitExpression - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..20)::19 + CSharpCodeBlock - [1..20)::19 + CSharpExpressionLiteral - [1..20)::19 - [Foo[Bar[Baz]LFBizLF] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + LeftBracket;[[]; + Identifier;[Bar]; + LeftBracket;[[]; + Identifier;[Baz]; + RightBracket;[]]; + NewLine;[LF]; + Identifier;[Biz]; + NewLine;[LF]; + MarkupElement - [20..34)::14 + MarkupStartTag - [20..23)::3 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[b]; + CloseAngle;[>]; + MarkupTextLiteral - [23..30)::7 - [LFBozLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[Boz]; + NewLine;[LF]; + MarkupEndTag - [30..34)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[b]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.cspans.txt new file mode 100644 index 0000000000..e7181851fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [11] ) +Code span at (2:0,2 [9] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [11] ) +Markup span at (11:1,0 [6] ) (Accepts:Any) - Parent: Tag block at (11:1,0 [6] ) +Markup span at (17:1,6 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (24:3,0 [6] ) (Accepts:Any) - Parent: Tag block at (24:3,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.diag.txt new file mode 100644 index 0000000000..0b063402e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.stree.txt new file mode 100644 index 0000000000..0698d6ddec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..30)::30 - [@(foo barLFLFbazLF - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpExplicitExpression - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..11)::9 + CSharpExpressionLiteral - [2..11)::9 - [foo barLF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + NewLine;[LF]; + RazorMetaCode - [11..11)::0 - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[]; + MarkupElement - [11..30)::19 + MarkupStartTag - [11..17)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; + MarkupTextLiteral - [17..24)::7 - [LFbazLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[baz]; + NewLine;[LF]; + MarkupEndTag - [24..30)::6 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[html]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.cspans.txt new file mode 100644 index 0000000000..0d8a457d26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [20] ) +Markup span at (20:2,0 [6] ) (Accepts:Any) - Parent: Tag block at (20:2,0 [6] ) +Markup span at (26:2,6 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Markup span at (33:4,0 [7] ) (Accepts:Any) - Parent: Tag block at (33:4,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.stree.txt new file mode 100644 index 0000000000..bb1196c88e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..40)::40 - [@Foo(Bar(Baz)LFBizLFLFBozLF] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpImplicitExpression - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..20)::19 + CSharpCodeBlock - [1..20)::19 + CSharpExpressionLiteral - [1..20)::19 - [Foo(Bar(Baz)LFBizLF] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + LeftParenthesis;[(]; + Identifier;[Bar]; + LeftParenthesis;[(]; + Identifier;[Baz]; + RightParenthesis;[)]; + NewLine;[LF]; + Identifier;[Biz]; + NewLine;[LF]; + MarkupElement - [20..40)::20 + MarkupStartTag - [20..26)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; + MarkupTextLiteral - [26..33)::7 - [LFBozLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[Boz]; + NewLine;[LF]; + MarkupEndTag - [33..40)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..6e9d765553 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +Code span at (1:0,1 [17] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (18:1,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..a40df1a410 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..6e28bbcdf9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..21)::21 - [@foreach(foo barLFbaz] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..18)::17 - [foreach(foo barLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + NewLine;[LF]; + MarkupTextLiteral - [18..21)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..9ca26d65c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +Code span at (1:0,1 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [13] ) +Markup span at (13:1,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..a08a836e65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..581e95bb66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..16)::16 - [@if(foo barLFbaz] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..13)::12 - [if(foo barLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + NewLine;[LF]; + MarkupTextLiteral - [13..16)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.cspans.txt new file mode 100644 index 0000000000..451037e71b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Code span at (1:0,1 [41] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diag.txt new file mode 100644 index 0000000000..73d5e27b67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diag.txt @@ -0,0 +1 @@ +(2,13): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.stree.txt new file mode 100644 index 0000000000..272bf0ce6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..42)::42 - [@if(foo) {LF var p = "foo bar bazLF;LF}] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..42)::41 - [if(foo) {LF var p = "foo bar bazLF;LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[p]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["foo bar baz];RZ1000(24:1,12 [1] ) + NewLine;[LF]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..70b420119b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Code span at (1:0,1 [45] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.diag.txt new file mode 100644 index 0000000000..a49f840204 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,22): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.stree.txt new file mode 100644 index 0000000000..2116937472 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesNormalStringAtEndOfFile.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..46)::46 - [@if(foo) { var foo = "blah blah blah blah blah] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..46)::45 - [if(foo) { var foo = "blah blah blah blah blah] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["blah blah blah blah blah];RZ1000(21:0,21 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..baf2c5c1f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Code span at (1:0,1 [15] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (16:1,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..a8733967de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..2d8984304f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..19)::19 - [@using(foo barLFbaz] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..16)::15 - [using(foo barLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[using]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + NewLine;[LF]; + MarkupTextLiteral - [16..19)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..cd8e624ee1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [61] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [61] ) +Code span at (1:0,1 [60] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [61] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.diag.txt new file mode 100644 index 0000000000..a49f840204 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,22): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.stree.txt new file mode 100644 index 0000000000..67afb3874b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesVerbatimStringAtEndOfFile.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..61)::61 - [@if(foo) { var foo = @"blah LFblah; LF

                    Foo

                    LFblah LFblah] + MarkupBlock - [0..61)::61 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..61)::61 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..61)::60 - [if(foo) { var foo = @"blah LFblah; LF

                    Foo

                    LFblah LFblah] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;[@"blah LFblah; LF

                    Foo

                    LFblah LFblah];RZ1000(21:0,21 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt new file mode 100644 index 0000000000..afd9a6256e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:1,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.diag.txt new file mode 100644 index 0000000000..0d2c452b13 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.stree.txt new file mode 100644 index 0000000000..01f031ed08 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..26)::26 - [@do { } while(foo barLFbaz] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..23)::22 - [do { } while(foo barLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Identifier;[bar]; + NewLine;[LF]; + MarkupTextLiteral - [23..26)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.cspans.txt new file mode 100644 index 0000000000..e6cc0f0ab4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [7] ) +Markup span at (7:0,7 [14] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.diag.txt new file mode 100644 index 0000000000..dafdc8f2e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1002: The helper directive is not supported. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.stree.txt new file mode 100644 index 0000000000..2edf3b29c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithHelperDirectiveProducesError.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..21)::21 - [@helper fooHelper { }] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpImplicitExpression - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..7)::6 + CSharpCodeBlock - [1..7)::6 + CSharpExpressionLiteral - [1..7)::6 - [helper] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[helper]; + MarkupTextLiteral - [7..21)::14 - [ fooHelper { }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[fooHelper]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.cspans.txt new file mode 100644 index 0000000000..c9fe98a849 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +Transition span at (6:0,6 [1] ) (Accepts:None) - Parent: Statement block at (6:0,6 [3] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Statement block at (6:0,6 [3] ) +Code span at (8:0,8 [0] ) (Accepts:Any) - Parent: Statement block at (6:0,6 [3] ) +MetaCode span at (8:0,8 [1] ) (Accepts:None) - Parent: Statement block at (6:0,6 [3] ) +Code span at (9:0,9 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.diag.txt new file mode 100644 index 0000000000..302b641580 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ1010: Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.stree.txt new file mode 100644 index 0000000000..7b55422dd6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/WithNestedCodeBlockProducesError.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..11)::11 - [@if { @{} }] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..6)::5 - [if { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [6..9)::3 + CSharpStatement - [6..9)::3 + CSharpTransition - [6..7)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [7..9)::2 + RazorMetaCode - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [8..8)::0 + CSharpStatementLiteral - [8..8)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + RazorMetaCode - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + CSharpStatementLiteral - [9..11)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..a09a5507a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [9] ) +MetaCode span at (8:0,8 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +Markup span at (9:0,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.stree.txt new file mode 100644 index 0000000000..b32100887b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..9)::9 - [@("\"\"")] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..9)::9 + CSharpExplicitExpression - [0..9)::9 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..9)::8 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..8)::6 + CSharpExpressionLiteral - [2..8)::6 - ["\"\""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;["\"\""]; + RazorMetaCode - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [9..9)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..b867104f46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (2:0,2 [7] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..4e2a0d3ee8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..10)::10 - [@(@"""""")] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpExplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..9)::7 + CSharpExpressionLiteral - [2..9)::7 - [@""""""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;[@""""""]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..00911f1902 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (2:0,2 [4] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Markup span at (7:0,7 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.stree.txt new file mode 100644 index 0000000000..f6b8e38665 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInNonVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..7)::7 - [@("\"")] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpExplicitExpression - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..7)::6 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..6)::4 + CSharpExpressionLiteral - [2..6)::4 - ["\""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;["\""]; + RazorMetaCode - [6..7)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [7..7)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..a8175e85d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (2:0,2 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [8] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..3103f0223f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptEscapedQuoteInVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..8)::8 - [@(@"""")] + MarkupBlock - [0..8)::8 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpExplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..8)::7 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..7)::5 + CSharpExpressionLiteral - [2..7)::5 - [@""""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;[@""""]; + RazorMetaCode - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [8..8)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..1f223ecaf0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +Code span at (2:0,2 [20] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [23] ) +MetaCode span at (22:4,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [23] ) +Markup span at (23:4,2 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.stree.txt new file mode 100644 index 0000000000..4120fe5a0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultiLineVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..23)::23 - [@(@"LFFooLFBarLFBazLF")] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpExplicitExpression - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..22)::20 + CSharpExpressionLiteral - [2..22)::20 - [@"LFFooLFBarLFBazLF"] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;[@"LFFooLFBarLFBazLF"]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..e40d184265 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +Code span at (2:0,2 [18] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.stree.txt new file mode 100644 index 0000000000..6444a0ba44 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..21)::21 - [@("\"hello, world\"")] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpExplicitExpression - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..20)::18 + CSharpExpressionLiteral - [2..20)::18 - ["\"hello, world\""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;["\"hello, world\""]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..a45c531d17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (2:0,2 [19] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..d68a700afc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleEscapedQuotesInVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..22)::22 - [@(@"""hello, world""")] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpExplicitExpression - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..21)::19 + CSharpExpressionLiteral - [2..21)::19 - [@"""hello, world"""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;[@"""hello, world"""]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.cspans.txt new file mode 100644 index 0000000000..b867104f46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (2:0,2 [7] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.stree.txt new file mode 100644 index 0000000000..4e2a0d3ee8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..10)::10 - [@(@"""""")] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpExplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..9)::7 + CSharpExpressionLiteral - [2..9)::7 - [@""""""] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;[@""""""]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.cspans.txt new file mode 100644 index 0000000000..db00568920 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [2] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.diag.txt new file mode 100644 index 0000000000..0b063402e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.stree.txt new file mode 100644 index 0000000000..7aa4d7138c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..2)::2 - [@(] + MarkupBlock - [0..2)::2 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..2)::2 + CSharpExplicitExpression - [0..2)::2 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..2)::1 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..2)::0 + CSharpExpressionLiteral - [2..2)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [2..2)::0 - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.cspans.txt new file mode 100644 index 0000000000..65a3c41a92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [3] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [3] ) +MetaCode span at (2:0,2 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +Markup span at (3:0,3 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.stree.txt new file mode 100644 index 0000000000..07a566bf89 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..3)::3 - [@()] + MarkupBlock - [0..3)::3 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..3)::3 + CSharpExplicitExpression - [0..3)::3 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..3)::2 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..2)::0 + CSharpExpressionLiteral - [2..2)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [3..3)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.cspans.txt new file mode 100644 index 0000000000..ad756e73a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [147] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [145] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] ) +Code span at (14:1,12 [130] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [145] ) +MetaCode span at (144:6,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [145] ) +Markup span at (147:7,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [147] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.stree.txt new file mode 100644 index 0000000000..96b51d354b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement.stree.txt @@ -0,0 +1,62 @@ +RazorDocument - [0..147)::147 - [LF@functions {LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) return "Anouncement: " + message;LF }LF}LF] + MarkupBlock - [0..147)::147 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..147)::145 + RazorDirective - [2..147)::145 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..147)::144 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..147)::135 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..144)::130 + CSharpStatementLiteral - [14..144)::130 - [LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) return "Anouncement: " + message;LF }LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[GetAnnouncmentText]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[message]; + Dot;[.]; + Identifier;[Length]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[return]; + Whitespace;[ ]; + StringLiteral;["Anouncement: "]; + Whitespace;[ ]; + Plus;[+]; + Whitespace;[ ]; + Identifier;[message]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [144..147)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [147..147)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.cspans.txt new file mode 100644 index 0000000000..223c39f5de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.cspans.txt @@ -0,0 +1,36 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [408] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [406] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] ) +Code span at (14:1,12 [88] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +Markup span at (102:4,32 [3] ) (Accepts:None) - Parent: Tag block at (102:4,32 [3] ) +Markup span at (105:4,35 [9] ) (Accepts:Any) - Parent: Markup block at (102:4,32 [26] ) +Transition span at (114:4,44 [1] ) (Accepts:None) - Parent: Expression block at (114:4,44 [8] ) +Code span at (115:4,45 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (114:4,44 [8] ) +Markup span at (122:4,52 [4] ) (Accepts:None) - Parent: Tag block at (122:4,52 [4] ) +Markup span at (126:4,56 [2] ) (Accepts:None) - Parent: Markup block at (102:4,32 [26] ) +Code span at (128:5,0 [78] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +Markup span at (206:8,12 [3] ) (Accepts:None) - Parent: Tag block at (206:8,12 [3] ) +Markup span at (209:8,15 [16] ) (Accepts:Any) - Parent: Markup block at (206:8,12 [25] ) +Markup span at (225:8,31 [4] ) (Accepts:None) - Parent: Tag block at (225:8,31 [4] ) +Markup span at (229:8,35 [2] ) (Accepts:None) - Parent: Markup block at (206:8,12 [25] ) +Code span at (231:9,0 [61] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +Transition span at (292:11,12 [1] ) (Accepts:None) - Parent: Markup block at (292:11,12 [27] ) +MetaCode span at (293:11,13 [1] ) (Accepts:Any) - Parent: Markup block at (292:11,12 [27] ) +Markup span at (294:11,14 [14] ) (Accepts:Any) - Parent: Markup block at (292:11,12 [27] ) +Transition span at (308:11,28 [1] ) (Accepts:None) - Parent: Expression block at (308:11,28 [5] ) +Code span at (309:11,29 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (308:11,28 [5] ) +Markup span at (313:11,33 [6] ) (Accepts:None) - Parent: Markup block at (292:11,12 [27] ) +Code span at (319:12,0 [31] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +Code span at (350:13,29 [1] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +Code span at (351:13,30 [20] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +Markup span at (371:13,50 [8] ) (Accepts:None) - Parent: Tag block at (371:13,50 [8] ) +Markup span at (379:13,58 [0] ) (Accepts:Any) - Parent: Markup block at (371:13,50 [27] ) +Transition span at (379:13,58 [1] ) (Accepts:None) - Parent: Expression block at (379:13,58 [8] ) +Code span at (380:13,59 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (379:13,58 [8] ) +Markup span at (387:13,66 [9] ) (Accepts:None) - Parent: Tag block at (387:13,66 [9] ) +Markup span at (396:13,75 [2] ) (Accepts:None) - Parent: Markup block at (371:13,50 [27] ) +Code span at (398:14,0 [7] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [391] ) +MetaCode span at (405:15,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [406] ) +Markup span at (408:16,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [408] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.diag.txt new file mode 100644 index 0000000000..f661098862 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.diag.txt @@ -0,0 +1,4 @@ +(5,33): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +(9,13): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +(12,13): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". +(14,30): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.stree.txt new file mode 100644 index 0000000000..03065213c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/Functions_SingleLineControlFlowStatement_Error.stree.txt @@ -0,0 +1,208 @@ +RazorDocument - [0..408)::408 - [LF@functions {LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0)

                    Message: @message

                    LFLF if (message == null)LF // Nothing to renderLF

                    Message was null

                    LFLF if (DateTime.Now.ToBinary() % 2 == 0)LF @:

                    The time: @time

                    LFLF if (message != null) @@SomeGitHubUserName @messageLF }LF}LF] + MarkupBlock - [0..408)::408 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..408)::406 + RazorDirective - [2..408)::406 - Directive:{functions;CodeBlock;Unrestricted} [RZ1008(102:4,32 [1] ), RZ1008(206:8,12 [1] ), RZ1008(292:11,12 [2] ), RZ1008(350:13,29 [2] )] + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..408)::405 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..408)::396 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..405)::391 + CSharpStatementLiteral - [14..102)::88 - [LF string GetAnnouncmentText(string message)LF {LF if (message.Length > 0) ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[GetAnnouncmentText]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[message]; + Dot;[.]; + Identifier;[Length]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + Whitespace;[ ]; + MarkupBlock - [102..128)::26 + MarkupElement - [102..126)::24 + MarkupStartTag - [102..105)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [105..114)::9 - [Message: ] - Gen - SpanEditHandler;Accepts:Any + Text;[Message:]; + Whitespace;[ ]; + CSharpCodeBlock - [114..122)::8 + CSharpImplicitExpression - [114..122)::8 + CSharpTransition - [114..115)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [115..122)::7 + CSharpCodeBlock - [115..122)::7 + CSharpExpressionLiteral - [115..122)::7 - [message] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[message]; + MarkupEndTag - [122..126)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [126..128)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [128..206)::78 - [LF if (message == null)LF // Nothing to renderLF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[message]; + Whitespace;[ ]; + Equals;[==]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + CSharpComment;[// Nothing to render]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [206..231)::25 + MarkupElement - [206..229)::23 + MarkupStartTag - [206..209)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [209..225)::16 - [Message was null] - Gen - SpanEditHandler;Accepts:Any + Text;[Message]; + Whitespace;[ ]; + Text;[was]; + Whitespace;[ ]; + Text;[null]; + MarkupEndTag - [225..229)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [229..231)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [231..292)::61 - [LF if (DateTime.Now.ToBinary() % 2 == 0)LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + Dot;[.]; + Identifier;[ToBinary]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + Modulo;[%]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Whitespace;[ ]; + Equals;[==]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [292..319)::27 + MarkupTransition - [292..293)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [293..294)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [294..308)::14 - [

                    The time: ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + Text;[The]; + Whitespace;[ ]; + Text;[time:]; + Whitespace;[ ]; + CSharpCodeBlock - [308..313)::5 + CSharpImplicitExpression - [308..313)::5 + CSharpTransition - [308..309)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [309..313)::4 + CSharpCodeBlock - [309..313)::4 + CSharpExpressionLiteral - [309..313)::4 - [time] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[time]; + MarkupTextLiteral - [313..319)::6 - [

                    LF] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + NewLine;[LF]; + CSharpStatementLiteral - [319..350)::31 - [LF if (message != null) ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[message]; + Whitespace;[ ]; + NotEqual;[!=]; + Whitespace;[ ]; + Keyword;[null]; + RightParenthesis;[)]; + Whitespace;[ ]; + CSharpEphemeralTextLiteral - [350..351)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + CSharpStatementLiteral - [351..371)::20 - [@SomeGitHubUserName ] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Identifier;[SomeGitHubUserName]; + Whitespace;[ ]; + MarkupBlock - [371..398)::27 + MarkupElement - [371..396)::25 + MarkupStartTag - [371..379)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [379..379)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [379..387)::8 + CSharpImplicitExpression - [379..387)::8 + CSharpTransition - [379..380)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [380..387)::7 + CSharpCodeBlock - [380..387)::7 + CSharpExpressionLiteral - [380..387)::7 - [message] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[message]; + MarkupEndTag - [387..396)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [396..398)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [398..405)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [405..408)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [408..408)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_CanContainCurlyBraces.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_CanContainCurlyBraces.cspans.txt new file mode 100644 index 0000000000..8253b1a0b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_CanContainCurlyBraces.cspans.txt @@ -0,0 +1,26 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [210] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [208] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [208] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [208] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [208] ) +Code span at (14:1,12 [47] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [193] ) +Markup span at (61:4,0 [8] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [139] ) +Markup span at (69:4,8 [5] ) (Accepts:None) - Parent: Tag block at (69:4,8 [5] ) +Markup span at (74:4,13 [2] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [139] ) +Code span at (76:5,0 [12] ) (Accepts:Any) - Parent: Statement block at (76:5,0 [108] ) +Transition span at (88:5,12 [1] ) (Accepts:None) - Parent: Statement block at (76:5,0 [108] ) +Code span at (89:5,13 [40] ) (Accepts:Any) - Parent: Statement block at (76:5,0 [108] ) +Markup span at (129:7,0 [16] ) (Accepts:Any) - Parent: Markup block at (129:7,0 [40] ) +Markup span at (145:7,16 [3] ) (Accepts:None) - Parent: Tag block at (145:7,16 [3] ) +Markup span at (148:7,19 [0] ) (Accepts:Any) - Parent: Markup block at (129:7,0 [40] ) +Transition span at (148:7,19 [1] ) (Accepts:None) - Parent: Expression block at (148:7,19 [15] ) +Code span at (149:7,20 [14] ) (Accepts:NonWhitespace) - Parent: Expression block at (148:7,19 [15] ) +Markup span at (163:7,34 [4] ) (Accepts:None) - Parent: Tag block at (163:7,34 [4] ) +Markup span at (167:7,38 [2] ) (Accepts:None) - Parent: Markup block at (129:7,0 [40] ) +Code span at (169:8,0 [15] ) (Accepts:Any) - Parent: Statement block at (76:5,0 [108] ) +Markup span at (184:9,0 [8] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [139] ) +Markup span at (192:9,8 [6] ) (Accepts:None) - Parent: Tag block at (192:9,8 [6] ) +Markup span at (198:9,14 [2] ) (Accepts:None) - Parent: Markup block at (61:4,0 [139] ) +Code span at (200:10,0 [7] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [193] ) +MetaCode span at (207:11,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [208] ) +Markup span at (210:12,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [210] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_CanContainCurlyBraces.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_CanContainCurlyBraces.stree.txt new file mode 100644 index 0000000000..f0ad4cc26c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_CanContainCurlyBraces.stree.txt @@ -0,0 +1,112 @@ +RazorDocument - [0..210)::210 - [LF@functions {LF void Announcment(string message)LF {LF
                    LF @if (message.Length > 0)LF {LF

                    @message.Length

                    LF }LF
                    LF }LF}LF] + MarkupBlock - [0..210)::210 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..210)::208 + RazorDirective - [2..210)::208 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..210)::207 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..210)::198 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..207)::193 + CSharpStatementLiteral - [14..61)::47 - [LF void Announcment(string message)LF {LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [61..200)::139 + MarkupTextLiteral - [61..69)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [69..198)::129 + MarkupStartTag - [69..74)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [74..76)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [76..184)::108 + CSharpStatementLiteral - [76..88)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpTransition - [88..89)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [89..129)::40 - [if (message.Length > 0)LF {LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[message]; + Dot;[.]; + Identifier;[Length]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [129..169)::40 + MarkupTextLiteral - [129..145)::16 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [145..167)::22 + MarkupStartTag - [145..148)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [148..148)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [148..163)::15 + CSharpImplicitExpression - [148..163)::15 + CSharpTransition - [148..149)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [149..163)::14 + CSharpCodeBlock - [149..163)::14 + CSharpExpressionLiteral - [149..163)::14 - [message.Length] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[message]; + Dot;[.]; + Identifier;[Length]; + MarkupEndTag - [163..167)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [167..169)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [169..184)::15 - [ }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [184..192)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [192..198)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [198..200)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [200..207)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [207..210)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [210..210)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInString.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInString.cspans.txt new file mode 100644 index 0000000000..e4bcfd4f62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInString.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [81] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [79] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [79] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [79] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [79] ) +Code span at (14:1,12 [64] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [79] ) +MetaCode span at (78:3,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [79] ) +Markup span at (81:4,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [81] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInString.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInString.stree.txt new file mode 100644 index 0000000000..ac779ab034 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInString.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..81)::81 - [LF@functions {LF void Announcment(string message) => "

                    @message

                    ";LF}LF] + MarkupBlock - [0..81)::81 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..81)::79 + RazorDirective - [2..81)::79 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..81)::78 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..81)::69 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..78)::64 + CSharpStatementLiteral - [14..78)::64 - [LF void Announcment(string message) => "

                    @message

                    ";LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + Whitespace;[ ]; + GreaterThanEqual;[=>]; + Whitespace;[ ]; + StringLiteral;["

                    @message

                    "]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [78..81)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [81..81)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString.cspans.txt new file mode 100644 index 0000000000..c908ca70cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [82] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [80] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [80] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [80] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [80] ) +Code span at (14:1,12 [65] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [80] ) +MetaCode span at (79:3,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [80] ) +Markup span at (82:4,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [82] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString.stree.txt new file mode 100644 index 0000000000..262c18d238 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseMarkupInVerbatimString.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..82)::82 - [LF@functions {LF void Announcment(string message) => @"

                    @message

                    ";LF}LF] + MarkupBlock - [0..82)::82 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..82)::80 + RazorDirective - [2..82)::80 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..82)::79 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..82)::70 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..79)::65 + CSharpStatementLiteral - [14..79)::65 - [LF void Announcment(string message) => @"

                    @message

                    ";LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + Whitespace;[ ]; + GreaterThanEqual;[=>]; + Whitespace;[ ]; + StringLiteral;[@"

                    @message

                    "]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [79..82)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [82..82)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseWhenNotSupported.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseWhenNotSupported.cspans.txt new file mode 100644 index 0000000000..3ff26adf1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseWhenNotSupported.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [96] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +Code span at (14:1,12 [81] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [96] ) +MetaCode span at (95:6,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +Markup span at (98:7,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseWhenNotSupported.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseWhenNotSupported.stree.txt new file mode 100644 index 0000000000..c3d51822e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_DoesNotParseWhenNotSupported.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..98)::98 - [LF@functions {LF void Announcment(string message)LF {LF

                    @message

                    LF }LF}LF] + MarkupBlock - [0..98)::98 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..98)::96 + RazorDirective - [2..98)::96 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..98)::95 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..98)::86 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..95)::81 + CSharpStatementLiteral - [14..95)::81 - [LF void Announcment(string message)LF {LF

                    @message

                    LF }LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + LessThan;[<]; + Identifier;[h3]; + GreaterThan;[>]; + Transition;[@]; + Identifier;[message]; + LessThan;[<]; + Slash;[/]; + Identifier;[h3]; + GreaterThan;[>]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [95..98)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [98..98)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_MarkupCanContainTemplate.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_MarkupCanContainTemplate.cspans.txt new file mode 100644 index 0000000000..fd4fc97ed3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_MarkupCanContainTemplate.cspans.txt @@ -0,0 +1,25 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [220] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [218] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [218] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [218] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [218] ) +Code span at (14:1,12 [47] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [203] ) +Markup span at (61:4,0 [8] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [149] ) +Markup span at (69:4,8 [5] ) (Accepts:None) - Parent: Tag block at (69:4,8 [5] ) +Markup span at (74:4,13 [2] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [149] ) +Code span at (76:5,0 [12] ) (Accepts:Any) - Parent: Statement block at (76:5,0 [118] ) +Transition span at (88:5,12 [1] ) (Accepts:None) - Parent: Statement block at (76:5,0 [118] ) +Code span at (89:5,13 [63] ) (Accepts:Any) - Parent: Statement block at (76:5,0 [118] ) +Transition span at (152:7,23 [1] ) (Accepts:None) - Parent: Markup block at (152:7,23 [23] ) +Markup span at (153:7,24 [3] ) (Accepts:None) - Parent: Tag block at (153:7,24 [3] ) +Markup span at (156:7,27 [0] ) (Accepts:Any) - Parent: Markup block at (152:7,23 [23] ) +Transition span at (156:7,27 [1] ) (Accepts:None) - Parent: Expression block at (156:7,27 [15] ) +Code span at (157:7,28 [14] ) (Accepts:NonWhitespace) - Parent: Expression block at (156:7,27 [15] ) +Markup span at (171:7,42 [4] ) (Accepts:None) - Parent: Tag block at (171:7,42 [4] ) +Code span at (175:7,46 [19] ) (Accepts:Any) - Parent: Statement block at (76:5,0 [118] ) +Markup span at (194:9,0 [8] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [149] ) +Markup span at (202:9,8 [6] ) (Accepts:None) - Parent: Tag block at (202:9,8 [6] ) +Markup span at (208:9,14 [2] ) (Accepts:None) - Parent: Markup block at (61:4,0 [149] ) +Code span at (210:10,0 [7] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [203] ) +MetaCode span at (217:11,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [218] ) +Markup span at (220:12,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [220] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_MarkupCanContainTemplate.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_MarkupCanContainTemplate.stree.txt new file mode 100644 index 0000000000..e6319cb686 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_MarkupCanContainTemplate.stree.txt @@ -0,0 +1,117 @@ +RazorDocument - [0..220)::220 - [LF@functions {LF void Announcment(string message)LF {LF
                    LF @if (message.Length > 0)LF {LF Repeat(@

                    @message.Length

                    );LF }LF
                    LF }LF}LF] + MarkupBlock - [0..220)::220 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..220)::218 + RazorDirective - [2..220)::218 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..220)::217 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..220)::208 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..217)::203 + CSharpStatementLiteral - [14..61)::47 - [LF void Announcment(string message)LF {LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [61..210)::149 + MarkupTextLiteral - [61..69)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [69..208)::139 + MarkupStartTag - [69..74)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [74..76)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [76..194)::118 + CSharpStatementLiteral - [76..88)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpTransition - [88..89)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [89..152)::63 - [if (message.Length > 0)LF {LF Repeat(] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[message]; + Dot;[.]; + Identifier;[Length]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + CSharpTemplateBlock - [152..175)::23 + MarkupBlock - [152..175)::23 + MarkupTransition - [152..153)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [153..175)::22 + MarkupStartTag - [153..156)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [156..156)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [156..171)::15 + CSharpImplicitExpression - [156..171)::15 + CSharpTransition - [156..157)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [157..171)::14 + CSharpCodeBlock - [157..171)::14 + CSharpExpressionLiteral - [157..171)::14 - [message.Length] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[message]; + Dot;[.]; + Identifier;[Length]; + MarkupEndTag - [171..175)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [175..194)::19 - [);LF }LF] - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [194..202)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [202..208)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [208..210)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [210..217)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [217..220)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [220..220)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupInsideMethod.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupInsideMethod.cspans.txt new file mode 100644 index 0000000000..4a14010156 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupInsideMethod.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [96] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +Code span at (14:1,12 [47] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [81] ) +Markup span at (61:4,0 [8] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [27] ) +Markup span at (69:4,8 [4] ) (Accepts:None) - Parent: Tag block at (69:4,8 [4] ) +Markup span at (73:4,12 [0] ) (Accepts:Any) - Parent: Markup block at (61:4,0 [27] ) +Transition span at (73:4,12 [1] ) (Accepts:None) - Parent: Expression block at (73:4,12 [8] ) +Code span at (74:4,13 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (73:4,12 [8] ) +Markup span at (81:4,20 [5] ) (Accepts:None) - Parent: Tag block at (81:4,20 [5] ) +Markup span at (86:4,25 [2] ) (Accepts:None) - Parent: Markup block at (61:4,0 [27] ) +Code span at (88:5,0 [7] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [81] ) +MetaCode span at (95:6,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [96] ) +Markup span at (98:7,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupInsideMethod.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupInsideMethod.stree.txt new file mode 100644 index 0000000000..45946374fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupInsideMethod.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..98)::98 - [LF@functions {LF void Announcment(string message)LF {LF

                    @message

                    LF }LF}LF] + MarkupBlock - [0..98)::98 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..98)::96 + RazorDirective - [2..98)::96 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..98)::95 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..98)::86 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..95)::81 + CSharpStatementLiteral - [14..61)::47 - [LF void Announcment(string message)LF {LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [61..88)::27 + MarkupTextLiteral - [61..69)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [69..86)::17 + MarkupStartTag - [69..73)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[h3]; + CloseAngle;[>]; + MarkupTextLiteral - [73..73)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [73..81)::8 + CSharpImplicitExpression - [73..81)::8 + CSharpTransition - [73..74)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [74..81)::7 + CSharpCodeBlock - [74..81)::7 + CSharpExpressionLiteral - [74..81)::7 - [message] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[message]; + MarkupEndTag - [81..86)::5 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[h3]; + CloseAngle;[>]; + MarkupTextLiteral - [86..88)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [88..95)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [95..98)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [98..98)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod.cspans.txt new file mode 100644 index 0000000000..fbc728c657 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [78] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [76] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [76] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [76] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [76] ) +Code span at (14:1,12 [42] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [61] ) +Markup span at (56:2,40 [4] ) (Accepts:None) - Parent: Tag block at (56:2,40 [4] ) +Markup span at (60:2,44 [0] ) (Accepts:Any) - Parent: Markup block at (56:2,40 [19] ) +Transition span at (60:2,44 [1] ) (Accepts:None) - Parent: Expression block at (60:2,44 [8] ) +Code span at (61:2,45 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (60:2,44 [8] ) +Markup span at (68:2,52 [5] ) (Accepts:None) - Parent: Tag block at (68:2,52 [5] ) +Markup span at (73:2,57 [2] ) (Accepts:None) - Parent: Markup block at (56:2,40 [19] ) +Code span at (75:3,0 [0] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [61] ) +MetaCode span at (75:3,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [76] ) +Markup span at (78:4,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [78] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod.stree.txt new file mode 100644 index 0000000000..e22da882cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/MarkupInFunctionsBlock_ParsesMarkupWithExpressionsMethod.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..78)::78 - [LF@functions {LF void Announcment(string message) =>

                    @message

                    LF}LF] + MarkupBlock - [0..78)::78 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..78)::76 + RazorDirective - [2..78)::76 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..78)::75 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..78)::66 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..75)::61 + CSharpStatementLiteral - [14..56)::42 - [LF void Announcment(string message) => ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Announcment]; + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[message]; + RightParenthesis;[)]; + Whitespace;[ ]; + GreaterThanEqual;[=>]; + Whitespace;[ ]; + MarkupBlock - [56..75)::19 + MarkupElement - [56..73)::17 + MarkupStartTag - [56..60)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[h3]; + CloseAngle;[>]; + MarkupTextLiteral - [60..60)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [60..68)::8 + CSharpImplicitExpression - [60..68)::8 + CSharpTransition - [60..61)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [61..68)::7 + CSharpCodeBlock - [61..68)::7 + CSharpExpressionLiteral - [61..68)::7 - [message] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[message]; + MarkupEndTag - [68..73)::5 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[h3]; + CloseAngle;[>]; + MarkupTextLiteral - [73..75)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [75..75)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [75..78)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [78..78)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/ReservedKeywordsInFunctionsBlock_WithMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/ReservedKeywordsInFunctionsBlock_WithMarkup.cspans.txt new file mode 100644 index 0000000000..356e5dbb5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/ReservedKeywordsInFunctionsBlock_WithMarkup.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [140] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [138] ) +MetaCode span at (3:1,1 [9] ) (Accepts:None) - Parent: Directive block at (2:1,0 [138] ) +None span at (12:1,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:1,0 [138] ) +MetaCode span at (13:1,11 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [138] ) +Code span at (14:1,12 [73] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [123] ) +Markup span at (87:6,0 [12] ) (Accepts:Any) - Parent: Markup block at (87:6,0 [32] ) +Markup span at (99:6,12 [3] ) (Accepts:None) - Parent: Tag block at (99:6,12 [3] ) +Markup span at (102:6,15 [11] ) (Accepts:Any) - Parent: Markup block at (87:6,0 [32] ) +Markup span at (113:6,26 [4] ) (Accepts:None) - Parent: Tag block at (113:6,26 [4] ) +Markup span at (117:6,30 [2] ) (Accepts:None) - Parent: Markup block at (87:6,0 [32] ) +Code span at (119:7,0 [18] ) (Accepts:Any) - Parent: Statement block at (14:1,12 [123] ) +MetaCode span at (137:9,0 [3] ) (Accepts:None) - Parent: Directive block at (2:1,0 [138] ) +Markup span at (140:10,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [140] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/ReservedKeywordsInFunctionsBlock_WithMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/ReservedKeywordsInFunctionsBlock_WithMarkup.stree.txt new file mode 100644 index 0000000000..f994fcb86d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpFunctionsTest/ReservedKeywordsInFunctionsBlock_WithMarkup.stree.txt @@ -0,0 +1,73 @@ +RazorDocument - [0..140)::140 - [LF@functions {LF class PersonLF {LF public void DoSomething()LF {LF

                    Just do it!

                    LF }LF }LF}LF] + MarkupBlock - [0..140)::140 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..140)::138 + RazorDirective - [2..140)::138 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..140)::137 + RazorMetaCode - [3..12)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [12..140)::128 + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [14..137)::123 + CSharpStatementLiteral - [14..87)::73 - [LF class PersonLF {LF public void DoSomething()LF {LF] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[class]; + Whitespace;[ ]; + Identifier;[Person]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[public]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[DoSomething]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [87..119)::32 + MarkupTextLiteral - [87..99)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [99..117)::18 + MarkupStartTag - [99..102)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [102..113)::11 - [Just do it!] - Gen - SpanEditHandler;Accepts:Any + Text;[Just]; + Whitespace;[ ]; + Text;[do]; + Whitespace;[ ]; + Text;[it]; + Bang;[!]; + MarkupEndTag - [113..117)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [117..119)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [119..137)::18 - [ }LF }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [137..140)::3 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [140..140)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.cspans.txt new file mode 100644 index 0000000000..9811c622e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.stree.txt new file mode 100644 index 0000000000..754aaddfac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/AcceptsNonEnglishCharactersThatAreValidIdentifiers.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..9)::9 - [@हळूँजद॔.] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [हळूँजद॔] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[हळूँजद॔]; + MarkupTextLiteral - [8..9)::1 - [.] - Gen - SpanEditHandler;Accepts:Any + Text;[.]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.cspans.txt new file mode 100644 index 0000000000..3af48c1d82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.stree.txt new file mode 100644 index 0000000000..4c51ced51e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..6)::6 - [@foo ;] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [4..6)::2 - [ ;] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[;]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.cspans.txt new file mode 100644 index 0000000000..9811c622e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.stree.txt new file mode 100644 index 0000000000..9aeb491366 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotAtEOFInImplicitExpression.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..9)::9 - [@foo.bar.] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [foo.bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + MarkupTextLiteral - [8..9)::1 - [.] - Gen - SpanEditHandler;Accepts:Any + Text;[.]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.cspans.txt new file mode 100644 index 0000000000..fcb828addc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.stree.txt new file mode 100644 index 0000000000..6c80edc56e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..10)::10 - [@foo.bar.0] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [foo.bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + MarkupTextLiteral - [8..10)::2 - [.0] - Gen - SpanEditHandler;Accepts:Any + Text;[.0]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.cspans.txt new file mode 100644 index 0000000000..3da06726a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Markup span at (9:0,9 [4] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.stree.txt new file mode 100644 index 0000000000..ab3a3eaa71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..13)::13 - [@foo.bar.

                    ] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [foo.bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + MarkupTextLiteral - [8..9)::1 - [.] - Gen - SpanEditHandler;Accepts:Any + Text;[.]; + MarkupElement - [9..13)::4 + MarkupEndTag - [9..13)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.cspans.txt new file mode 100644 index 0000000000..fcb828addc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.stree.txt new file mode 100644 index 0000000000..8bcb3320d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/DoesNotIncludeSemicolonAfterDot.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..10)::10 - [@foo.bar.;] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [foo.bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + MarkupTextLiteral - [8..10)::2 - [.;] - Gen - SpanEditHandler;Accepts:Any + Text;[.;]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.cspans.txt new file mode 100644 index 0000000000..26a7df601b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [12] ) +Code span at (1:0,1 [11] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [12] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.stree.txt new file mode 100644 index 0000000000..81dce166d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfDottedIdentifiers.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..13)::13 - [@foo.bar.baz;] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + CSharpImplicitExpression - [0..12)::12 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..12)::11 + CSharpCodeBlock - [1..12)::11 + CSharpExpressionLiteral - [1..12)::11 - [foo.bar.baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + Dot;[.]; + Identifier;[baz]; + MarkupTextLiteral - [12..13)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.cspans.txt new file mode 100644 index 0000000000..2bb1fc91e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.stree.txt new file mode 100644 index 0000000000..d0b3494b53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/IgnoresSemicolonAtEndOfSimpleImplicitExpression.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..5)::5 - [@foo;] + MarkupBlock - [0..5)::5 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [4..5)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.cspans.txt new file mode 100644 index 0000000000..ec56fd948c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [12] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [4] ) +Code span at (13:0,13 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [4] ) +Markup span at (16:0,16 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.stree.txt new file mode 100644 index 0000000000..183ab53d22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/NestedImplicitExpression.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..18)::18 - [if (true) { @foo }] + MarkupBlock - [0..18)::18 + MarkupTextLiteral - [0..12)::12 - [if (true) { ] - Gen - SpanEditHandler;Accepts:Any + Text;[if]; + Whitespace;[ ]; + Text;[(true)]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [12..16)::4 + CSharpImplicitExpression - [12..16)::4 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..16)::3 + CSharpCodeBlock - [13..16)::3 + CSharpExpressionLiteral - [13..16)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [16..18)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.cspans.txt new file mode 100644 index 0000000000..4b7b3ba3f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [13] ) +Code span at (1:0,1 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [13] ) +Markup span at (13:0,13 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.stree.txt new file mode 100644 index 0000000000..d3500903b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputExpressionIfModuleTokenNotFollowedByBrace.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..13)::13 - [@module.foo()] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + CSharpImplicitExpression - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..13)::12 + CSharpCodeBlock - [1..13)::12 + CSharpExpressionLiteral - [1..13)::12 - [module.foo()] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[module]; + Dot;[.]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + MarkupTextLiteral - [13..13)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.cspans.txt new file mode 100644 index 0000000000..cd03a1193c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [1] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.diag.txt new file mode 100644 index 0000000000..c6d6925451 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.stree.txt new file mode 100644 index 0000000000..1b3a186cb6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..1)::1 - [@] + MarkupBlock - [0..1)::1 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..1)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.cspans.txt new file mode 100644 index 0000000000..d06a3a71b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.diag.txt new file mode 100644 index 0000000000..6d8d0cd1bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "/" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.stree.txt new file mode 100644 index 0000000000..b5a86255d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..2)::2 - [@/] + MarkupBlock - [0..2)::2 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..2)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.cspans.txt new file mode 100644 index 0000000000..f22755e950 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [12] ) +Code span at (1:0,1 [11] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [12] ) +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.stree.txt new file mode 100644 index 0000000000..705a500244 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesDottedIdentifiersAsImplicitExpression.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..12)::12 - [@foo.bar.baz] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + CSharpImplicitExpression - [0..12)::12 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..12)::11 + CSharpCodeBlock - [1..12)::11 + CSharpExpressionLiteral - [1..12)::11 - [foo.bar.baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + Dot;[.]; + Identifier;[baz]; + MarkupTextLiteral - [12..12)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.cspans.txt new file mode 100644 index 0000000000..9449b5a267 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.stree.txt new file mode 100644 index 0000000000..2a973adbb8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket1.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..7)::7 - [@val??[] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..7)::3 - [??[] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; + LeftBracket;[[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.cspans.txt new file mode 100644 index 0000000000..aaa7127537 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +Code span at (1:0,1 [8] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [9] ) +Markup span at (9:0,9 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.stree.txt new file mode 100644 index 0000000000..f4956e6999 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket10.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..10)::10 - [@val?[-1]?] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..9)::9 + CSharpImplicitExpression - [0..9)::9 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..9)::8 + CSharpCodeBlock - [1..9)::8 + CSharpExpressionLiteral - [1..9)::8 - [val?[-1]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Minus;[-]; + IntegerLiteral;[1]; + RightBracket;[]]; + MarkupTextLiteral - [9..10)::1 - [?] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.cspans.txt new file mode 100644 index 0000000000..3f873f6ea4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.diag.txt new file mode 100644 index 0000000000..a6129d65d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.diag.txt @@ -0,0 +1 @@ +(1,12): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.stree.txt new file mode 100644 index 0000000000..8ccf243709 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket11.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..15)::15 - [@val?[abc]?[def] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpImplicitExpression - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..15)::14 + CSharpCodeBlock - [1..15)::14 + CSharpExpressionLiteral - [1..15)::14 - [val?[abc]?[def] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[def]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.cspans.txt new file mode 100644 index 0000000000..92bb2a9863 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [14] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.stree.txt new file mode 100644 index 0000000000..bb2ddfa496 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket12.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..14)::14 - [@val?[abc]?[2]] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpImplicitExpression - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..14)::13 + CSharpCodeBlock - [1..14)::13 + CSharpExpressionLiteral - [1..14)::13 - [val?[abc]?[2]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + QuestionMark;[?]; + LeftBracket;[[]; + IntegerLiteral;[2]; + RightBracket;[]]; + MarkupTextLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.cspans.txt new file mode 100644 index 0000000000..4afe3fa1bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.stree.txt new file mode 100644 index 0000000000..483a875a7d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket13.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..22)::22 - [@val?[abc]?.more?[def]] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpImplicitExpression - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..22)::21 + CSharpCodeBlock - [1..22)::21 + CSharpExpressionLiteral - [1..22)::21 - [val?[abc]?.more?[def]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[def]; + RightBracket;[]]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.cspans.txt new file mode 100644 index 0000000000..03103a61c2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +Code span at (1:0,1 [20] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.stree.txt new file mode 100644 index 0000000000..e484ae74f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket14.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..21)::21 - [@val?[abc]?.more?.abc] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpImplicitExpression - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..21)::20 + CSharpCodeBlock - [1..21)::20 + CSharpExpressionLiteral - [1..21)::20 - [val?[abc]?.more?.abc] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[abc]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.cspans.txt new file mode 100644 index 0000000000..bb0defcc69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [19] ) +Code span at (1:0,1 [18] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.stree.txt new file mode 100644 index 0000000000..49f0bd7d07 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket15.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..19)::19 - [@val?[null ?? true]] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpImplicitExpression - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..19)::18 + CSharpCodeBlock - [1..19)::18 + CSharpExpressionLiteral - [1..19)::18 - [val?[null ?? true]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Keyword;[null]; + Whitespace;[ ]; + NullCoalesce;[??]; + Whitespace;[ ]; + Keyword;[true]; + RightBracket;[]]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.cspans.txt new file mode 100644 index 0000000000..0b32c2fccc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.stree.txt new file mode 100644 index 0000000000..ef28b6255c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket16.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..20)::20 - [@val?[abc?.gef?[-1]]] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpImplicitExpression - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..20)::19 + CSharpCodeBlock - [1..20)::19 + CSharpExpressionLiteral - [1..20)::19 - [val?[abc?.gef?[-1]]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[abc]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[gef]; + QuestionMark;[?]; + LeftBracket;[[]; + Minus;[-]; + IntegerLiteral;[1]; + RightBracket;[]]; + RightBracket;[]]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.cspans.txt new file mode 100644 index 0000000000..b01f990159 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.stree.txt new file mode 100644 index 0000000000..a09cafb40e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket2.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..8)::8 - [@val??[0] + MarkupBlock - [0..8)::8 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..8)::4 - [??[0] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; + LeftBracket;[[]; + Text;[0]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.cspans.txt new file mode 100644 index 0000000000..f1cf24e281 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.stree.txt new file mode 100644 index 0000000000..c65cad563b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket3.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..6)::6 - [@val?[] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val?[] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.cspans.txt new file mode 100644 index 0000000000..3af48c1d82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.stree.txt new file mode 100644 index 0000000000..8591aa3eb2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket4.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..6)::6 - [@val?(] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..6)::2 - [?(] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + Text;[(]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.cspans.txt new file mode 100644 index 0000000000..540927e7d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.stree.txt new file mode 100644 index 0000000000..8071369d6a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket5.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..10)::10 - [@val?[more] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [val?[more] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[more]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.cspans.txt new file mode 100644 index 0000000000..685d604d5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.stree.txt new file mode 100644 index 0000000000..dad9336067 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket6.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..8)::8 - [@val?[0]] + MarkupBlock - [0..8)::8 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [val?[0]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + IntegerLiteral;[0]; + RightBracket;[]]; + MarkupTextLiteral - [8..8)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.cspans.txt new file mode 100644 index 0000000000..8ecc8ebeba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) +Markup span at (6:0,6 [3] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.stree.txt new file mode 100644 index 0000000000..a6ce27255a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket7.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..9)::9 - [@val?[

                    ] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val?[] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + MarkupElement - [6..9)::3 + MarkupStartTag - [6..9)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.cspans.txt new file mode 100644 index 0000000000..5890f7654d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [11] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [11] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.stree.txt new file mode 100644 index 0000000000..5e458aa0e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket8.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..14)::14 - [@val?[more.

                    ] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpImplicitExpression - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..11)::10 + CSharpCodeBlock - [1..11)::10 + CSharpExpressionLiteral - [1..11)::10 - [val?[more.] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + LeftBracket;[[]; + Identifier;[more]; + Dot;[.]; + MarkupElement - [11..14)::3 + MarkupStartTag - [11..14)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.cspans.txt new file mode 100644 index 0000000000..b93ef2adc4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.stree.txt new file mode 100644 index 0000000000..72be12795a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Bracket9.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..14)::14 - [@val??[more

                    ] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..11)::7 - [??[more] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; + LeftBracket;[[]; + Text;[more]; + MarkupElement - [11..14)::3 + MarkupStartTag - [11..14)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.cspans.txt new file mode 100644 index 0000000000..2bb1fc91e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.stree.txt new file mode 100644 index 0000000000..4ccc4619af --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot1.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..5)::5 - [@val?] + MarkupBlock - [0..5)::5 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..5)::1 - [?] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.cspans.txt new file mode 100644 index 0000000000..0013e6c6e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.stree.txt new file mode 100644 index 0000000000..3804d990ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot10.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..13)::13 - [@val?.more

                    ] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [val?.more] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + MarkupElement - [10..13)::3 + MarkupStartTag - [10..13)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.cspans.txt new file mode 100644 index 0000000000..b93ef2adc4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.stree.txt new file mode 100644 index 0000000000..ce8be23cef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot11.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..14)::14 - [@val??.more

                    ] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..11)::7 - [??.more] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; + Text;[.more]; + MarkupElement - [11..14)::3 + MarkupStartTag - [11..14)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.cspans.txt new file mode 100644 index 0000000000..41f5f8c0d4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [19] ) +Code span at (1:0,1 [18] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [19] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.stree.txt new file mode 100644 index 0000000000..01eccdf9f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot12.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..22)::22 - [@val?.more(false)?.

                    ] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpImplicitExpression - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..19)::18 + CSharpCodeBlock - [1..19)::18 + CSharpExpressionLiteral - [1..19)::18 - [val?.more(false)?.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + QuestionMark;[?]; + Dot;[.]; + MarkupElement - [19..22)::3 + MarkupStartTag - [19..22)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.cspans.txt new file mode 100644 index 0000000000..4afe3fa1bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.stree.txt new file mode 100644 index 0000000000..193c9dbc4e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot13.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..22)::22 - [@val?.more(false)?.abc] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpImplicitExpression - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..22)::21 + CSharpCodeBlock - [1..22)::21 + CSharpExpressionLiteral - [1..22)::21 - [val?.more(false)?.abc] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[abc]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.cspans.txt new file mode 100644 index 0000000000..3df6aca276 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [29] ) +Code span at (1:0,1 [28] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.stree.txt new file mode 100644 index 0000000000..c70700ff24 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot14.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..29)::29 - [@val?.more(null ?? true)?.abc] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpImplicitExpression - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..29)::28 + CSharpCodeBlock - [1..29)::28 + CSharpExpressionLiteral - [1..29)::28 - [val?.more(null ?? true)?.abc] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + LeftParenthesis;[(]; + Keyword;[null]; + Whitespace;[ ]; + NullCoalesce;[??]; + Whitespace;[ ]; + Keyword;[true]; + RightParenthesis;[)]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[abc]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.cspans.txt new file mode 100644 index 0000000000..3af48c1d82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.stree.txt new file mode 100644 index 0000000000..37455f2956 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot2.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..6)::6 - [@val??] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..6)::2 - [??] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.cspans.txt new file mode 100644 index 0000000000..ad423cd178 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.stree.txt new file mode 100644 index 0000000000..6ea6455932 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot3.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..10)::10 - [@val??more] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..10)::6 - [??more] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; + Text;[more]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.cspans.txt new file mode 100644 index 0000000000..3af48c1d82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.stree.txt new file mode 100644 index 0000000000..e90d2caa25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot4.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..6)::6 - [@val?!] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..6)::2 - [?!] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + Bang;[!]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.cspans.txt new file mode 100644 index 0000000000..fb74b137cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [6] ) +Markup span at (6:0,6 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.stree.txt new file mode 100644 index 0000000000..cb4ae61a45 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot5.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..6)::6 - [@val?.] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val?.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + MarkupTextLiteral - [6..6)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.cspans.txt new file mode 100644 index 0000000000..9449b5a267 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.stree.txt new file mode 100644 index 0000000000..aaa2a274fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot6.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..7)::7 - [@val??.] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..7)::3 - [??.] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + QuestionMark;[?]; + Text;[.]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.cspans.txt new file mode 100644 index 0000000000..922c9aa28d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [6] ) +Markup span at (6:0,6 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.stree.txt new file mode 100644 index 0000000000..6c7496a3a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot7.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..11)::11 - [@val?.(abc)] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val?.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + MarkupTextLiteral - [6..11)::5 - [(abc)] - Gen - SpanEditHandler;Accepts:Any + Text;[(abc)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.cspans.txt new file mode 100644 index 0000000000..f39a70eff8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [6] ) +Markup span at (6:0,6 [3] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.stree.txt new file mode 100644 index 0000000000..f47f2c3137 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot8.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..9)::9 - [@val?.

                    ] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val?.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + MarkupElement - [6..9)::3 + MarkupStartTag - [6..9)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.cspans.txt new file mode 100644 index 0000000000..a325887027 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.stree.txt new file mode 100644 index 0000000000..3f147507dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullConditionalOperatorImplicitExpression_Dot9.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..10)::10 - [@val?.more] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [val?.more] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Bracket15.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Bracket15.cspans.txt new file mode 100644 index 0000000000..0b32c2fccc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Bracket15.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Bracket15.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Bracket15.stree.txt new file mode 100644 index 0000000000..ad5651fb87 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Bracket15.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..20)::20 - [@val![null! ?? true]] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpImplicitExpression - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..20)::19 + CSharpCodeBlock - [1..20)::19 + CSharpExpressionLiteral - [1..20)::19 - [val![null! ?? true]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Keyword;[null]; + Not;[!]; + Whitespace;[ ]; + NullCoalesce;[??]; + Whitespace;[ ]; + Keyword;[true]; + RightBracket;[]]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Brackets.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Brackets.cspans.txt new file mode 100644 index 0000000000..685d604d5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Brackets.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Brackets.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Brackets.stree.txt new file mode 100644 index 0000000000..4921828163 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Brackets.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..8)::8 - [@val![0]] + MarkupBlock - [0..8)::8 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [val![0]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + IntegerLiteral;[0]; + RightBracket;[]]; + MarkupTextLiteral - [8..8)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Combined.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Combined.cspans.txt new file mode 100644 index 0000000000..d438935c6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Combined.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [11] ) +Code span at (1:0,1 [10] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [11] ) +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Combined.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Combined.stree.txt new file mode 100644 index 0000000000..5b1b99423f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Combined.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..11)::11 - [@val!?.more] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpImplicitExpression - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..11)::10 + CSharpCodeBlock - [1..11)::10 + CSharpExpressionLiteral - [1..11)::10 - [val!?.more] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[more]; + MarkupTextLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding.cspans.txt new file mode 100644 index 0000000000..34db8ba1e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [7] ) +Markup span at (7:0,7 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding.stree.txt new file mode 100644 index 0000000000..0851177da5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedEnding.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..7)::7 - [@val!?.] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpImplicitExpression - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..7)::6 + CSharpCodeBlock - [1..7)::6 + CSharpExpressionLiteral - [1..7)::6 - [val!?.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + QuestionMark;[?]; + Dot;[.]; + MarkupTextLiteral - [7..7)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional.cspans.txt new file mode 100644 index 0000000000..980b0da319 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [5] ) +Code span at (1:0,1 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [5] ) +Markup span at (5:0,5 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional.stree.txt new file mode 100644 index 0000000000..3a965aba80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_CombinedWithNullConditional.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..6)::6 - [@val!?] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpImplicitExpression - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..5)::4 + CSharpCodeBlock - [1..5)::4 + CSharpExpressionLiteral - [1..5)::4 - [val!] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + MarkupTextLiteral - [5..6)::1 - [?] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Complex.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Complex.cspans.txt new file mode 100644 index 0000000000..47ad9f2cb0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Complex.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [17] ) +Code span at (1:0,1 [16] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [17] ) +Markup span at (17:0,17 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Complex.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Complex.stree.txt new file mode 100644 index 0000000000..4a747ee7d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Complex.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..22)::22 - [@val!.more(false)!.

                    ] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpImplicitExpression - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..17)::16 + CSharpCodeBlock - [1..17)::16 + CSharpExpressionLiteral - [1..17)::16 - [val!.more(false)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + Dot;[.]; + Identifier;[more]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + MarkupTextLiteral - [17..19)::2 - [!.] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + Text;[.]; + MarkupElement - [19..22)::3 + MarkupStartTag - [19..22)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock.cspans.txt new file mode 100644 index 0000000000..6a164b65bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [59] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [59] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [59] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [59] ) +Code span at (12:0,12 [21] ) (Accepts:Any) - Parent: Statement block at (12:0,12 [46] ) +Transition span at (33:0,33 [1] ) (Accepts:None) - Parent: Expression block at (33:0,33 [22] ) +Code span at (34:0,34 [21] ) (Accepts:NonWhitespace) - Parent: Expression block at (33:0,33 [22] ) +Code span at (55:0,55 [3] ) (Accepts:Any) - Parent: Statement block at (12:0,12 [46] ) +MetaCode span at (58:0,58 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [59] ) +Markup span at (59:0,59 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock.stree.txt new file mode 100644 index 0000000000..7aaf996a80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DirectiveCodeBlock.stree.txt @@ -0,0 +1,56 @@ +RazorDocument - [0..59)::59 - [@functions { public void Foo() { @Model!.Name![0]!?.Bar } }] + MarkupBlock - [0..59)::59 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..59)::59 + RazorDirective - [0..59)::59 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..59)::58 + RazorMetaCode - [1..10)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [10..59)::49 + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [12..58)::46 + CSharpStatementLiteral - [12..33)::21 - [ public void Foo() { ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + Whitespace;[ ]; + Keyword;[public]; + Whitespace;[ ]; + Keyword;[void]; + Whitespace;[ ]; + Identifier;[Foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [33..55)::22 + CSharpImplicitExpression - [33..55)::22 + CSharpTransition - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [34..55)::21 + CSharpCodeBlock - [34..55)::21 + CSharpExpressionLiteral - [34..55)::21 - [Model!.Name![0]!?.Bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K15 + Identifier;[Model]; + Not;[!]; + Dot;[.]; + Identifier;[Name]; + Not;[!]; + LeftBracket;[[]; + IntegerLiteral;[0]; + RightBracket;[]]; + Not;[!]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[Bar]; + CSharpStatementLiteral - [55..58)::3 - [ } ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [58..59)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [59..59)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket.cspans.txt new file mode 100644 index 0000000000..9449b5a267 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket.stree.txt new file mode 100644 index 0000000000..e68796a910 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_DoubleBang_IncompleteBracket.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..7)::7 - [@val!![] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..7)::3 - [!![] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + Bang;[!]; + LeftBracket;[[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Ending.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Ending.cspans.txt new file mode 100644 index 0000000000..2bb1fc91e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Ending.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Ending.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Ending.stree.txt new file mode 100644 index 0000000000..3812fb1a91 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Ending.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..5)::5 - [@val!] + MarkupBlock - [0..5)::5 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..5)::1 - [!] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator.cspans.txt new file mode 100644 index 0000000000..3af48c1d82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator.stree.txt new file mode 100644 index 0000000000..38fa5297aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_EndingDotedOperator.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..6)::6 - [@val!.] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..6)::2 - [!.] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + Text;[.]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpression.cspans.txt new file mode 100644 index 0000000000..a325887027 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpression.stree.txt new file mode 100644 index 0000000000..823306d9ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpression.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..10)::10 - [@val!.more] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [val!.more] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + Dot;[.]; + Identifier;[more]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml.cspans.txt new file mode 100644 index 0000000000..0013e6c6e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml.stree.txt new file mode 100644 index 0000000000..1ce31325bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_FullExpressionWithHtml.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..13)::13 - [@val!.more

                    ] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [val!.more] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + Dot;[.]; + Identifier;[more]; + MarkupElement - [10..13)::3 + MarkupStartTag - [10..13)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.cspans.txt new file mode 100644 index 0000000000..f1cf24e281 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.stree.txt new file mode 100644 index 0000000000..98b7a5ba3a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracket.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..6)::6 - [@val![] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val![] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.cspans.txt new file mode 100644 index 0000000000..8ecc8ebeba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) +Markup span at (6:0,6 [3] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.stree.txt new file mode 100644 index 0000000000..3d7d9987fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithHtml.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..9)::9 - [@val![

                    ] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val![] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + MarkupElement - [6..9)::3 + MarkupStartTag - [6..9)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.cspans.txt new file mode 100644 index 0000000000..540927e7d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.stree.txt new file mode 100644 index 0000000000..05644f8d35 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteBracketWithIdentifier.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..10)::10 - [@val![more] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [val![more] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[more]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.cspans.txt new file mode 100644 index 0000000000..f1cf24e281 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [6] ) +Code span at (1:0,1 [5] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.diag.txt new file mode 100644 index 0000000000..6cb7c82385 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.stree.txt new file mode 100644 index 0000000000..d619447c8d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_IncompleteParenthesis.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..6)::6 - [@val!(] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpImplicitExpression - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..6)::5 + CSharpCodeBlock - [1..6)::5 + CSharpExpressionLiteral - [1..6)::5 - [val!(] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftParenthesis;[(]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml.cspans.txt new file mode 100644 index 0000000000..0611081c69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Markup span at (6:0,6 [3] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml.stree.txt new file mode 100644 index 0000000000..e894acb135 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Incomplete_ContinuedHtml.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..9)::9 - [@val!.

                    ] + MarkupBlock - [0..9)::9 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..6)::2 - [!.] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + Text;[.]; + MarkupElement - [6..9)::3 + MarkupStartTag - [6..9)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding.cspans.txt new file mode 100644 index 0000000000..03ee93c780 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding.stree.txt new file mode 100644 index 0000000000..53cac366d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_InvalidMethodEnding.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..11)::11 - [@val!.(abc)] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..11)::7 - [!.(abc)] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + Text;[.(abc)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.cspans.txt new file mode 100644 index 0000000000..5890f7654d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [11] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [11] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.diag.txt new file mode 100644 index 0000000000..34f020b41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.stree.txt new file mode 100644 index 0000000000..c09500e785 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedIncompleteBracket.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..14)::14 - [@val![more.

                    ] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpImplicitExpression - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..11)::10 + CSharpCodeBlock - [1..11)::10 + CSharpExpressionLiteral - [1..11)::10 - [val![more.] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[more]; + Dot;[.]; + MarkupElement - [11..14)::3 + MarkupStartTag - [11..14)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional.cspans.txt new file mode 100644 index 0000000000..b93ef2adc4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional.stree.txt new file mode 100644 index 0000000000..fb74f4160d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MixedNullConditional.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..14)::14 - [@val?![more

                    ] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [val] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + MarkupTextLiteral - [4..11)::7 - [?![more] - Gen - SpanEditHandler;Accepts:Any + QuestionMark;[?]; + Bang;[!]; + LeftBracket;[[]; + Text;[more]; + MarkupElement - [11..14)::3 + MarkupStartTag - [11..14)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple.cspans.txt new file mode 100644 index 0000000000..92bb2a9863 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [14] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple.stree.txt new file mode 100644 index 0000000000..ecec20e374 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..14)::14 - [@val![abc]![2]] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpImplicitExpression - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..14)::13 + CSharpCodeBlock - [1..14)::13 + CSharpExpressionLiteral - [1..14)::13 - [val![abc]![2]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + Not;[!]; + LeftBracket;[[]; + IntegerLiteral;[2]; + RightBracket;[]]; + MarkupTextLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed.cspans.txt new file mode 100644 index 0000000000..4afe3fa1bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed.stree.txt new file mode 100644 index 0000000000..17a068adda --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..22)::22 - [@val![abc]!.more![def]] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpImplicitExpression - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..22)::21 + CSharpCodeBlock - [1..22)::21 + CSharpExpressionLiteral - [1..22)::21 - [val![abc]!.more![def]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + Not;[!]; + Dot;[.]; + Identifier;[more]; + Not;[!]; + LeftBracket;[[]; + Identifier;[def]; + RightBracket;[]]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2.cspans.txt new file mode 100644 index 0000000000..03103a61c2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [21] ) +Code span at (1:0,1 [20] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2.stree.txt new file mode 100644 index 0000000000..d730107178 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_MultipleMixed2.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..21)::21 - [@val![abc]!.more!.abc] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpImplicitExpression - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..21)::20 + CSharpCodeBlock - [1..21)::20 + CSharpExpressionLiteral - [1..21)::20 - [val![abc]!.more!.abc] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + Not;[!]; + Dot;[.]; + Identifier;[more]; + Not;[!]; + Dot;[.]; + Identifier;[abc]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.cspans.txt new file mode 100644 index 0000000000..3f873f6ea4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.diag.txt new file mode 100644 index 0000000000..a6129d65d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.diag.txt @@ -0,0 +1 @@ +(1,12): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.stree.txt new file mode 100644 index 0000000000..0444d87d3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Multiple_Incomplete.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..15)::15 - [@val![abc]![def] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpImplicitExpression - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..15)::14 + CSharpCodeBlock - [1..15)::14 + CSharpExpressionLiteral - [1..15)::14 - [val![abc]![def] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[abc]; + RightBracket;[]]; + Not;[!]; + LeftBracket;[[]; + Identifier;[def]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Nested.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Nested.cspans.txt new file mode 100644 index 0000000000..0b32c2fccc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Nested.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Nested.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Nested.stree.txt new file mode 100644 index 0000000000..cc73e58118 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_Nested.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..20)::20 - [@val![abc!.gef![-1]]] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpImplicitExpression - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..20)::19 + CSharpCodeBlock - [1..20)::19 + CSharpExpressionLiteral - [1..20)::19 - [val![abc!.gef![-1]]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Identifier;[abc]; + Not;[!]; + Dot;[.]; + Identifier;[gef]; + Not;[!]; + LeftBracket;[[]; + Minus;[-]; + IntegerLiteral;[1]; + RightBracket;[]]; + RightBracket;[]]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock.cspans.txt new file mode 100644 index 0000000000..f78a70b341 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Code span at (2:0,2 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Expression block at (3:0,3 [20] ) +Code span at (4:0,4 [19] ) (Accepts:NonWhitespace) - Parent: Expression block at (3:0,3 [20] ) +Code span at (23:0,23 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock.stree.txt new file mode 100644 index 0000000000..691b32aa9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_NestedCodeBlock.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..25)::25 - [@{ @val!.Name![0]!?.Bar }] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + CSharpStatementLiteral - [2..3)::1 - [ ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + CSharpCodeBlock - [3..23)::20 + CSharpImplicitExpression - [3..23)::20 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [4..23)::19 + CSharpCodeBlock - [4..23)::19 + CSharpExpressionLiteral - [4..23)::19 - [val!.Name![0]!?.Bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Identifier;[val]; + Not;[!]; + Dot;[.]; + Identifier;[Name]; + Not;[!]; + LeftBracket;[[]; + IntegerLiteral;[0]; + RightBracket;[]]; + Not;[!]; + QuestionMark;[?]; + Dot;[.]; + Identifier;[Bar]; + CSharpStatementLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_SingleOperator.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_SingleOperator.cspans.txt new file mode 100644 index 0000000000..aaa7127537 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_SingleOperator.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [9] ) +Code span at (1:0,1 [8] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [9] ) +Markup span at (9:0,9 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_SingleOperator.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_SingleOperator.stree.txt new file mode 100644 index 0000000000..96a0b18ef2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesNullForgivenessOperatorImplicitExpression_SingleOperator.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..10)::10 - [@val![-1]!] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..9)::9 + CSharpImplicitExpression - [0..9)::9 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..9)::8 + CSharpCodeBlock - [1..9)::8 + CSharpExpressionLiteral - [1..9)::8 - [val![-1]] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[val]; + Not;[!]; + LeftBracket;[[]; + Minus;[-]; + IntegerLiteral;[1]; + RightBracket;[]]; + MarkupTextLiteral - [9..10)::1 - [!] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.cspans.txt new file mode 100644 index 0000000000..490eb4a82f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.stree.txt new file mode 100644 index 0000000000..5215a83230 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ParsesSingleIdentifierAsImplicitExpression.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..4)::4 - [@foo] + MarkupBlock - [0..4)::4 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [4..4)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.cspans.txt new file mode 100644 index 0000000000..b0120744b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [34] ) +Code span at (1:0,1 [33] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.stree.txt new file mode 100644 index 0000000000..119de13dfa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesBracketsAndBalancesThemInImplicitExpression.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..34)::34 - [@foo.bar[4 * (8 + 7)]["fo\"o"].baz] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpImplicitExpression - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..34)::33 + CSharpCodeBlock - [1..34)::33 + CSharpExpressionLiteral - [1..34)::33 - [foo.bar[4 * (8 + 7)]["fo\"o"].baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + LeftBracket;[[]; + IntegerLiteral;[4]; + Whitespace;[ ]; + Star;[*]; + Whitespace;[ ]; + LeftParenthesis;[(]; + IntegerLiteral;[8]; + Whitespace;[ ]; + Plus;[+]; + Whitespace;[ ]; + IntegerLiteral;[7]; + RightParenthesis;[)]; + RightBracket;[]]; + LeftBracket;[[]; + StringLiteral;["fo\"o"]; + RightBracket;[]]; + Dot;[.]; + Identifier;[baz]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.cspans.txt new file mode 100644 index 0000000000..c32f012803 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [115] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [115] ) +Code span at (1:0,1 [114] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [115] ) +Markup span at (115:0,115 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [115] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.stree.txt new file mode 100644 index 0000000000..da9bcfb36f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/ProperlyParsesParenthesesAndBalancesThemInImplicitExpression.stree.txt @@ -0,0 +1,72 @@ +RazorDocument - [0..115)::115 - [@foo().bar("bi\"z", 4)("chained method; call").baz(@"bo""z", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))] + MarkupBlock - [0..115)::115 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..115)::115 + CSharpImplicitExpression - [0..115)::115 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..115)::114 + CSharpCodeBlock - [1..115)::114 + CSharpExpressionLiteral - [1..115)::114 - [foo().bar("bi\"z", 4)("chained method; call").baz(@"bo""z", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Dot;[.]; + Identifier;[bar]; + LeftParenthesis;[(]; + StringLiteral;["bi\"z"]; + Comma;[,]; + Whitespace;[ ]; + IntegerLiteral;[4]; + RightParenthesis;[)]; + LeftParenthesis;[(]; + StringLiteral;["chained method; call"]; + RightParenthesis;[)]; + Dot;[.]; + Identifier;[baz]; + LeftParenthesis;[(]; + StringLiteral;[@"bo""z"]; + Comma;[,]; + Whitespace;[ ]; + CharacterLiteral;['\'']; + Comma;[,]; + Whitespace;[ ]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + GreaterThanEqual;[=>]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Keyword;[return]; + Whitespace;[ ]; + IntegerLiteral;[4]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Comma;[,]; + Whitespace;[ ]; + LeftParenthesis;[(]; + IntegerLiteral;[4]; + Plus;[+]; + IntegerLiteral;[5]; + Plus;[+]; + Keyword;[new]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + LeftBracket;[[]; + IntegerLiteral;[4]; + RightBracket;[]]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + RightParenthesis;[)]; + MarkupTextLiteral - [115..115)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.cspans.txt new file mode 100644 index 0000000000..fae6fdec1c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [6] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.stree.txt new file mode 100644 index 0000000000..cecb589f6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/StopsBalancingParenthesesAtEOF.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..7)::7 - [@foo(()] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpImplicitExpression - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..7)::6 + CSharpCodeBlock - [1..7)::6 + CSharpExpressionLiteral - [1..7)::6 - [foo(()] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + LeftParenthesis;[(]; + RightParenthesis;[)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.cspans.txt new file mode 100644 index 0000000000..4b9c5f7196 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [103] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [103] ) +Code span at (1:0,1 [102] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [103] ) +Markup span at (103:0,103 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [103] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.stree.txt new file mode 100644 index 0000000000..ec25b4c750 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/SupportsSlashesWithinComplexImplicitExpressions.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..103)::103 - [@DataGridColumn.Template("Years of Service", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))] + MarkupBlock - [0..103)::103 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..103)::103 + CSharpImplicitExpression - [0..103)::103 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..103)::102 + CSharpCodeBlock - [1..103)::102 + CSharpExpressionLiteral - [1..103)::102 - [DataGridColumn.Template("Years of Service", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DataGridColumn]; + Dot;[.]; + Identifier;[Template]; + LeftParenthesis;[(]; + StringLiteral;["Years of Service"]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[e]; + Whitespace;[ ]; + GreaterThanEqual;[=>]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[int]; + RightParenthesis;[)]; + Identifier;[Math]; + Dot;[.]; + Identifier;[Round]; + LeftParenthesis;[(]; + LeftParenthesis;[(]; + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + Whitespace;[ ]; + Minus;[-]; + Whitespace;[ ]; + Identifier;[dt]; + RightParenthesis;[)]; + Dot;[.]; + Identifier;[TotalDays]; + Whitespace;[ ]; + Slash;[/]; + Whitespace;[ ]; + IntegerLiteral;[365]; + RightParenthesis;[)]; + RightParenthesis;[)]; + MarkupTextLiteral - [103..103)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.cspans.txt new file mode 100644 index 0000000000..47ae3df07e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.stree.txt new file mode 100644 index 0000000000..b6f3ffd448 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..12)::12 - [@foo.bar

                    ] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [foo.bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + MarkupElement - [8..12)::4 + MarkupEndTag - [8..12)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.cspans.txt new file mode 100644 index 0000000000..de2f605a48 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [14] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.stree.txt new file mode 100644 index 0000000000..e7f6e17881 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..17)::17 - [@foo().bar.baz.42] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpImplicitExpression - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..14)::13 + CSharpCodeBlock - [1..14)::13 + CSharpExpressionLiteral - [1..14)::13 - [foo().bar.baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Dot;[.]; + Identifier;[bar]; + Dot;[.]; + Identifier;[baz]; + MarkupTextLiteral - [14..17)::3 - [.42] - Gen - SpanEditHandler;Accepts:Any + Text;[.42]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.cspans.txt new file mode 100644 index 0000000000..7e4212394b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [14] ) +Markup span at (14:0,14 [4] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [4] ) +Markup span at (18:0,18 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.stree.txt new file mode 100644 index 0000000000..bd0ea4ac3a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlEndTag.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..22)::22 - [@foo().bar.baz

                    zoop] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpImplicitExpression - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..14)::13 + CSharpCodeBlock - [1..14)::13 + CSharpExpressionLiteral - [1..14)::13 - [foo().bar.baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Dot;[.]; + Identifier;[bar]; + Dot;[.]; + Identifier;[baz]; + MarkupElement - [14..18)::4 + MarkupEndTag - [14..18)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [18..22)::4 - [zoop] - Gen - SpanEditHandler;Accepts:Any + Text;[zoop]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.cspans.txt new file mode 100644 index 0000000000..d1cd526148 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [14] ) +Code span at (1:0,1 [13] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [14] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [3] ) +Markup span at (17:0,17 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.stree.txt new file mode 100644 index 0000000000..c0cc2a6788 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtHtmlStartTag.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..21)::21 - [@foo().bar.baz

                    zoop] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpImplicitExpression - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..14)::13 + CSharpCodeBlock - [1..14)::13 + CSharpExpressionLiteral - [1..14)::13 - [foo().bar.baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Dot;[.]; + Identifier;[bar]; + Dot;[.]; + Identifier;[baz]; + MarkupElement - [14..21)::7 + MarkupStartTag - [14..17)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [17..21)::4 - [zoop] - Gen - SpanEditHandler;Accepts:Any + Text;[zoop]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.cspans.txt new file mode 100644 index 0000000000..d5399075f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.stree.txt new file mode 100644 index 0000000000..53ca571528 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..17)::17 - [@foo. bar() (baz)] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [4..17)::13 - [. bar() (baz)] - Gen - SpanEditHandler;Accepts:Any + Text;[.]; + Whitespace;[ ]; + Text;[bar()]; + Whitespace;[ ]; + Text;[(baz)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.cspans.txt new file mode 100644 index 0000000000..52d6a4d612 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.stree.txt new file mode 100644 index 0000000000..dfaef5653f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..16)::16 - [@foo.bar() (baz)] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [foo.bar()] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + Dot;[.]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + MarkupTextLiteral - [10..16)::6 - [ (baz)] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[(baz)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.cspans.txt new file mode 100644 index 0000000000..d5399075f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.stree.txt new file mode 100644 index 0000000000..baaaa2f435 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpImplicitExpressionTest/TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..17)::17 - [@foo .bar() (baz)] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [4..17)::13 - [ .bar() (baz)] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[.bar()]; + Whitespace;[ ]; + Text;[(baz)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.cspans.txt new file mode 100644 index 0000000000..dce52a5221 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Code span at (1:0,1 [34] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Markup span at (35:0,35 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.stree.txt new file mode 100644 index 0000000000..08c7c801a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedCodeBlock.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..35)::35 - [@while(true) { { { { foo(); } } } }] + MarkupBlock - [0..35)::35 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..35)::35 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..35)::34 - [while(true) { { { { foo(); } } } }] - Gen - SpanEditHandler;Accepts:None + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.cspans.txt new file mode 100644 index 0000000000..67434c2daf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +Code span at (17:0,17 [3] ) (Accepts:Any) - Parent: Expression block at (15:0,15 [6] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [6] ) +Code span at (21:0,21 [2] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.stree.txt new file mode 100644 index 0000000000..b0ff0f1147 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedExplicitExpression.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..23)::23 - [@while(true) { @(foo) }] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..15)::14 - [while(true) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [15..21)::6 + CSharpExplicitExpression - [15..21)::6 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [16..21)::5 + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [17..20)::3 + CSharpExpressionLiteral - [17..20)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + CSharpStatementLiteral - [21..23)::2 - [ }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.cspans.txt new file mode 100644 index 0000000000..4ab605085c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [4] ) +Code span at (16:0,16 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (15:0,15 [4] ) +Code span at (19:0,19 [2] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.stree.txt new file mode 100644 index 0000000000..fa46e8b529 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedImplicitExpression.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..21)::21 - [@while(true) { @foo }] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..15)::14 - [while(true) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [15..19)::4 + CSharpImplicitExpression - [15..19)::4 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [16..19)::3 + CSharpCodeBlock - [16..19)::3 + CSharpExpressionLiteral - [16..19)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Identifier;[foo]; + CSharpStatementLiteral - [19..21)::2 - [ }] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.cspans.txt new file mode 100644 index 0000000000..ad7d618e3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Code span at (1:0,1 [54] ) (Accepts:None) - Parent: Statement block at (0:0,0 [55] ) +Markup span at (55:0,55 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.stree.txt new file mode 100644 index 0000000000..be2365d2d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedKeywordStatement.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..55)::55 - [@while(true) { for(int i = 0; i < 10; i++) { foo(); } }] + MarkupBlock - [0..55)::55 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..55)::55 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..55)::54 - [while(true) { for(int i = 0; i < 10; i++) { foo(); } }] - Gen - SpanEditHandler;Accepts:None + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Keyword;[for]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Increment;[++]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [55..55)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.cspans.txt new file mode 100644 index 0000000000..c56d0fd0f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Code span at (1:0,1 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [14] ) +Markup span at (15:0,15 [3] ) (Accepts:None) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [5] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [14] ) +Markup span at (23:0,23 [4] ) (Accepts:None) - Parent: Tag block at (23:0,23 [4] ) +Markup span at (27:0,27 [1] ) (Accepts:None) - Parent: Markup block at (14:0,14 [14] ) +Code span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.stree.txt new file mode 100644 index 0000000000..93f1331759 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedMarkupBlock.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..29)::29 - [@while(true) {

                    Hello

                    }] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..14)::13 - [while(true) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [14..28)::14 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..27)::12 + MarkupStartTag - [15..18)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [18..23)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupEndTag - [23..27)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [28..29)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.cspans.txt new file mode 100644 index 0000000000..cdeba78164 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.stree.txt new file mode 100644 index 0000000000..4174c105bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpNestedStatementsTest/NestedSimpleStatement.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..23)::23 - [@while(true) { foo(); }] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..23)::22 - [while(true) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.cspans.txt new file mode 100644 index 0000000000..2dcfb49765 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +Comment span at (2:0,2 [0] ) (Accepts:Any) - Parent: Comment block at (0:0,0 [4] ) +MetaCode span at (2:0,2 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [4] ) +Markup span at (4:0,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.stree.txt new file mode 100644 index 0000000000..4ffe83985c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/EmptyRazorComment.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..4)::4 - [@**@] + MarkupBlock - [0..4)::4 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorComment - [0..4)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupTextLiteral - [4..4)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.cspans.txt new file mode 100644 index 0000000000..290c517695 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (5:1,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (7:1,2 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +MetaCode span at (8:1,3 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +Comment span at (9:1,4 [0] ) (Accepts:Any) - Parent: Comment block at (7:1,2 [4] ) +MetaCode span at (9:1,4 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +Transition span at (10:1,5 [1] ) (Accepts:None) - Parent: Comment block at (7:1,2 [4] ) +Markup span at (11:1,6 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (15:2,0 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +MetaCode span at (16:2,1 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +Comment span at (17:2,2 [0] ) (Accepts:Any) - Parent: Comment block at (15:2,0 [4] ) +MetaCode span at (17:2,2 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +Transition span at (18:2,3 [1] ) (Accepts:None) - Parent: Comment block at (15:2,0 [4] ) +Markup span at (19:2,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (21:3,0 [4] ) (Accepts:Any) - Parent: Tag block at (21:3,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.stree.txt new file mode 100644 index 0000000000..ea99cb2206 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentInMarkup.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..25)::25 - [

                    LF @**@ LF@**@LF

                    ] + MarkupBlock - [0..25)::25 + MarkupElement - [0..25)::25 + MarkupStartTag - [0..3)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..5)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEphemeralTextLiteral - [5..7)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [7..11)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [11..15)::4 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + RazorComment - [15..19)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [19..21)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [21..25)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.cspans.txt new file mode 100644 index 0000000000..45659c7dad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (5:1,0 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (6:1,1 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Comment span at (7:1,2 [0] ) (Accepts:Any) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (7:1,2 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Transition span at (8:1,3 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Markup span at (9:1,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Markup span at (9:1,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (11:1,6 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +MetaCode span at (12:1,7 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +Comment span at (13:1,8 [0] ) (Accepts:Any) - Parent: Comment block at (11:1,6 [4] ) +MetaCode span at (13:1,8 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +Transition span at (14:1,9 [1] ) (Accepts:None) - Parent: Comment block at (11:1,6 [4] ) +Markup span at (15:1,10 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Markup span at (17:2,0 [4] ) (Accepts:Any) - Parent: Tag block at (17:2,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.stree.txt new file mode 100644 index 0000000000..4d29f49bef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/MultipleRazorCommentsInSameLineInMarkup.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..21)::21 - [

                    LF@**@ @**@LF

                    ] + MarkupBlock - [0..21)::21 + MarkupElement - [0..21)::21 + MarkupStartTag - [0..3)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..5)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorComment - [5..9)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupTextLiteral - [9..9)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + MarkupEphemeralTextLiteral - [9..11)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [11..15)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [15..17)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [17..21)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentBetweenCodeBlockAndMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentBetweenCodeBlockAndMarkup.cspans.txt new file mode 100644 index 0000000000..c8b487fccb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentBetweenCodeBlockAndMarkup.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +Code span at (2:0,2 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (6:1,0 [1] ) (Accepts:None) - Parent: Comment block at (6:1,0 [17] ) +MetaCode span at (7:1,1 [1] ) (Accepts:None) - Parent: Comment block at (6:1,0 [17] ) +Comment span at (8:1,2 [13] ) (Accepts:Any) - Parent: Comment block at (6:1,0 [17] ) +MetaCode span at (21:1,15 [1] ) (Accepts:None) - Parent: Comment block at (6:1,0 [17] ) +Transition span at (22:1,16 [1] ) (Accepts:None) - Parent: Comment block at (6:1,0 [17] ) +Markup span at (23:1,17 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Markup span at (25:2,0 [5] ) (Accepts:Any) - Parent: Tag block at (25:2,0 [5] ) +Markup span at (30:2,5 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Markup span at (33:2,8 [6] ) (Accepts:Any) - Parent: Tag block at (33:2,8 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentBetweenCodeBlockAndMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentBetweenCodeBlockAndMarkup.stree.txt new file mode 100644 index 0000000000..376b6017f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentBetweenCodeBlockAndMarkup.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..39)::39 - [@{ }LF@* Hello World *@LF
                    Foo
                    ] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpStatement - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..4)::3 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..3)::1 + CSharpStatementLiteral - [2..3)::1 - [ ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [4..6)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorComment - [6..23)::17 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ Hello World ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [23..25)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [25..39)::14 + MarkupStartTag - [25..30)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [30..33)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [33..39)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInClosingTagBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInClosingTagBlock.cspans.txt new file mode 100644 index 0000000000..af3dd82d31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInClosingTagBlock.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [6] ) +Markup span at (6:0,6 [7] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [7] ) +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Comment block at (13:0,13 [19] ) +MetaCode span at (14:0,14 [1] ) (Accepts:None) - Parent: Comment block at (13:0,13 [19] ) +Comment span at (15:0,15 [15] ) (Accepts:Any) - Parent: Comment block at (13:0,13 [19] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Comment block at (13:0,13 [19] ) +Transition span at (31:0,31 [1] ) (Accepts:None) - Parent: Comment block at (13:0,13 [19] ) +Markup span at (32:0,32 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInClosingTagBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInClosingTagBlock.stree.txt new file mode 100644 index 0000000000..32cb55d39e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInClosingTagBlock.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..33)::33 - [] + MarkupBlock - [0..33)::33 + MarkupElement - [0..13)::13 + MarkupStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupEndTag - [6..13)::7 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + MarkupMiscAttributeContent - [12..13)::1 + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + RazorComment - [13..32)::19 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ razor comment ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupTextLiteral - [32..33)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.cspans.txt new file mode 100644 index 0000000000..83bce06d39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [13] ) +Code span at (1:0,1 [6] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [13] ) +Transition span at (7:1,0 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +MetaCode span at (8:1,1 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +Comment span at (9:1,2 [0] ) (Accepts:Any) - Parent: Comment block at (7:1,0 [4] ) +MetaCode span at (9:1,2 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +Transition span at (10:1,3 [1] ) (Accepts:None) - Parent: Comment block at (7:1,0 [4] ) +Code span at (11:1,4 [2] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.diag.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.stree.txt new file mode 100644 index 0000000000..59217177a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInImplicitExpressionMethodCall.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..13)::13 - [@foo(LF@**@LF] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + CSharpImplicitExpression - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..13)::12 + CSharpCodeBlock - [1..13)::12 + CSharpExpressionLiteral - [1..7)::6 - [foo(LF] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + NewLine;[LF]; + RazorComment - [7..11)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpExpressionLiteral - [11..13)::2 - [LF] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.cspans.txt new file mode 100644 index 0000000000..cca88e4c9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (5:1,0 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (6:1,1 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Comment span at (7:1,2 [0] ) (Accepts:Any) - Parent: Comment block at (5:1,0 [4] ) +MetaCode span at (7:1,2 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Transition span at (8:1,3 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [4] ) +Markup span at (9:1,4 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Markup span at (11:2,0 [4] ) (Accepts:Any) - Parent: Tag block at (11:2,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.stree.txt new file mode 100644 index 0000000000..32cc8dface --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInMarkup.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..15)::15 - [

                    LF@**@LF

                    ] + MarkupBlock - [0..15)::15 + MarkupElement - [0..15)::15 + MarkupStartTag - [0..3)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..5)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorComment - [5..9)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [9..11)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [11..15)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInOpeningTagBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInOpeningTagBlock.cspans.txt new file mode 100644 index 0000000000..be8102eb0a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInOpeningTagBlock.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Transition span at (6:0,6 [1] ) (Accepts:None) - Parent: Comment block at (6:0,6 [19] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Comment block at (6:0,6 [19] ) +Comment span at (8:0,8 [15] ) (Accepts:Any) - Parent: Comment block at (6:0,6 [19] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Comment block at (6:0,6 [19] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Comment block at (6:0,6 [19] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (26:0,26 [7] ) (Accepts:Any) - Parent: Tag block at (26:0,26 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInOpeningTagBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInOpeningTagBlock.stree.txt new file mode 100644 index 0000000000..040888e640 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInOpeningTagBlock.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..33)::33 - [] + MarkupBlock - [0..33)::33 + MarkupElement - [0..33)::33 + MarkupStartTag - [0..26)::26 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[text]; + MarkupMiscAttributeContent - [5..25)::20 + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [6..25)::19 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ razor comment ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CloseAngle;[>]; + MarkupEndTag - [26..33)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.cspans.txt new file mode 100644 index 0000000000..f9d1433413 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Transition span at (8:1,4 [5] ) (Accepts:Any) - Parent: Tag block at (8:1,4 [5] ) +Markup span at (13:1,9 [2] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) +Markup span at (15:2,0 [4] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) +Transition span at (19:2,4 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +MetaCode span at (20:2,5 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +Comment span at (21:2,6 [0] ) (Accepts:Any) - Parent: Comment block at (19:2,4 [4] ) +MetaCode span at (21:2,6 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +Transition span at (22:2,7 [1] ) (Accepts:None) - Parent: Comment block at (19:2,4 [4] ) +Markup span at (23:2,8 [2] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) +Markup span at (25:3,0 [1] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.diag.txt new file mode 100644 index 0000000000..728d71fa46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(2,6): Error RZ1023: "" and "" tags cannot contain attributes. +(2,6): Error RZ1025: The "text" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.stree.txt new file mode 100644 index 0000000000..74cfd937ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentInVerbatimBlock.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..26)::26 - [@{LF - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [8..26)::18 + MarkupElement - [8..26)::18 + MarkupStartTag - [8..13)::5 - MarkupTransition - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[text]; + CloseAngle;[]; + MarkupTextLiteral - [13..15)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEphemeralTextLiteral - [15..19)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorComment - [19..23)::4 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [23..25)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [25..26)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [26..26)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.cspans.txt new file mode 100644 index 0000000000..d5a5996abb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (7:2,0 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +MetaCode span at (8:2,1 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +Comment span at (9:2,2 [9] ) (Accepts:Any) - Parent: Comment block at (7:2,0 [13] ) +MetaCode span at (18:2,11 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +Transition span at (19:2,12 [1] ) (Accepts:None) - Parent: Comment block at (7:2,0 [13] ) +Markup span at (20:2,13 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (22:3,0 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +MetaCode span at (23:3,1 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +Comment span at (24:3,2 [11] ) (Accepts:Any) - Parent: Comment block at (22:3,0 [15] ) +MetaCode span at (35:5,0 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +Transition span at (36:5,1 [1] ) (Accepts:None) - Parent: Comment block at (22:3,0 [15] ) +Markup span at (37:5,2 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Markup span at (39:6,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Markup span at (41:7,0 [4] ) (Accepts:Any) - Parent: Tag block at (41:7,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.stree.txt new file mode 100644 index 0000000000..c671706a27 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentWithExtraNewLineInMarkup.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..45)::45 - [

                    LFLF@* content *@LF@*LFcontentLF*@LFLF

                    ] + MarkupBlock - [0..45)::45 + MarkupElement - [0..45)::45 + MarkupStartTag - [0..3)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..7)::4 - [LFLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + NewLine;[LF]; + RazorComment - [7..20)::13 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ content ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [20..22)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorComment - [22..37)::15 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[LFcontentLF]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [37..39)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [39..41)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [41..45)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.cspans.txt new file mode 100644 index 0000000000..4c99d23962 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (5:1,0 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +MetaCode span at (6:1,1 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +Comment span at (7:1,2 [7] ) (Accepts:Any) - Parent: Comment block at (5:1,0 [11] ) +MetaCode span at (14:1,9 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +Transition span at (15:1,10 [1] ) (Accepts:None) - Parent: Comment block at (5:1,0 [11] ) +Markup span at (16:1,11 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (25:1,20 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +MetaCode span at (26:1,21 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +Comment span at (27:1,22 [7] ) (Accepts:Any) - Parent: Comment block at (25:1,20 [11] ) +MetaCode span at (34:1,29 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +Transition span at (35:1,30 [1] ) (Accepts:None) - Parent: Comment block at (25:1,20 [11] ) +Markup span at (36:1,31 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Markup span at (38:2,0 [4] ) (Accepts:Any) - Parent: Tag block at (38:2,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.stree.txt new file mode 100644 index 0000000000..54b44635ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorCommentsSurroundingMarkup.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..42)::42 - [

                    LF@* hello *@ content @* world *@LF

                    ] + MarkupBlock - [0..42)::42 + MarkupElement - [0..42)::42 + MarkupStartTag - [0..3)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..5)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorComment - [5..16)::11 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ hello ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupTextLiteral - [16..25)::9 - [ content ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[content]; + Whitespace;[ ]; + RazorComment - [25..36)::11 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ world ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupTextLiteral - [36..38)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [38..42)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorMultilineCommentInBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorMultilineCommentInBlock.cspans.txt new file mode 100644 index 0000000000..7f93c44b8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorMultilineCommentInBlock.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Statement block at (2:1,0 [40] ) +MetaCode span at (3:1,1 [1] ) (Accepts:None) - Parent: Statement block at (2:1,0 [40] ) +Code span at (4:1,2 [6] ) (Accepts:Any) - Parent: Statement block at (2:1,0 [40] ) +Transition span at (10:2,4 [1] ) (Accepts:None) - Parent: Comment block at (10:2,4 [29] ) +MetaCode span at (11:2,5 [1] ) (Accepts:None) - Parent: Comment block at (10:2,4 [29] ) +Comment span at (12:2,6 [25] ) (Accepts:Any) - Parent: Comment block at (10:2,4 [29] ) +MetaCode span at (37:4,4 [1] ) (Accepts:None) - Parent: Comment block at (10:2,4 [29] ) +Transition span at (38:4,5 [1] ) (Accepts:None) - Parent: Comment block at (10:2,4 [29] ) +Code span at (39:4,6 [2] ) (Accepts:Any) - Parent: Statement block at (2:1,0 [40] ) +MetaCode span at (41:5,0 [1] ) (Accepts:None) - Parent: Statement block at (2:1,0 [40] ) +Markup span at (42:5,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorMultilineCommentInBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorMultilineCommentInBlock.stree.txt new file mode 100644 index 0000000000..fa32dc202e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/RazorMultilineCommentInBlock.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..44)::44 - [LF@{LF @*LFThis is a commentLF *@LF}LF] + MarkupBlock - [0..44)::44 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..42)::40 + CSharpStatement - [2..42)::40 + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [3..42)::39 + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [4..41)::37 + CSharpStatementLiteral - [4..10)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + RazorComment - [10..39)::29 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[LFThis is a commentLF ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + CSharpStatementLiteral - [39..41)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [42..44)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.cspans.txt new file mode 100644 index 0000000000..c75c972a0b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [2] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [2] ) +Comment span at (2:0,2 [0] ) (Accepts:Any) - Parent: Comment block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.diag.txt new file mode 100644 index 0000000000..4f3108141d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ1028: End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.stree.txt new file mode 100644 index 0000000000..60adcc438a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorComment.stree.txt @@ -0,0 +1,10 @@ +RazorDocument - [0..2)::2 - [@*] + MarkupBlock - [0..2)::2 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorComment - [0..2)::2 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[];RZ1028(0:0,0 [2] ) + RazorCommentTransition;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.cspans.txt new file mode 100644 index 0000000000..3b417826e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [7] ) +Code span at (1:0,1 [4] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [7] ) +Transition span at (5:0,5 [1] ) (Accepts:None) - Parent: Comment block at (5:0,5 [2] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Comment block at (5:0,5 [2] ) +Comment span at (7:0,7 [0] ) (Accepts:Any) - Parent: Comment block at (5:0,5 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.diag.txt new file mode 100644 index 0000000000..4369e7d5eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.diag.txt @@ -0,0 +1,2 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". +(1,6): Error RZ1028: End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.stree.txt new file mode 100644 index 0000000000..dc61b63396 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInImplicitExpressionMethodCall.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..7)::7 - [@foo(@*] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpImplicitExpression - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..7)::6 + CSharpCodeBlock - [1..7)::6 + CSharpExpressionLiteral - [1..5)::4 - [foo(] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[foo]; + LeftParenthesis;[(]; + RazorComment - [5..7)::2 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[];RZ1028(5:0,5 [2] ) + RazorCommentTransition;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.cspans.txt new file mode 100644 index 0000000000..3ad5a4a25d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [4] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Comment block at (2:0,2 [2] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Comment block at (2:0,2 [2] ) +Comment span at (4:0,4 [0] ) (Accepts:Any) - Parent: Comment block at (2:0,2 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.diag.txt new file mode 100644 index 0000000000..5ab5182308 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,3): Error RZ1028: End of file was reached before the end of the block comment. All comments that start with the "@*" sequence must be terminated with a matching "*@" sequence. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.stree.txt new file mode 100644 index 0000000000..6e7b2b4057 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpRazorCommentsTest/UnterminatedRazorCommentInVerbatimBlock.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..4)::4 - [@{@*] + MarkupBlock - [0..4)::4 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpStatement - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..4)::3 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..4)::2 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + Marker;[]; + RazorComment - [2..4)::2 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[]; + RazorCommentStar;[];RZ1028(2:0,2 [2] ) + RazorCommentTransition;[]; + RazorMetaCode - [4..4)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.cspans.txt new file mode 100644 index 0000000000..65fa84c6ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.diag.txt new file mode 100644 index 0000000000..a1c584f0d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1007: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.stree.txt new file mode 100644 index 0000000000..76edc37a7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWord.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..10)::10 - [@namespace] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + RazorDirective - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..10)::9 + RazorMetaCode - [1..10)::9 - Gen - SpanEditHandler;Accepts:None + Keyword;[namespace]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.cspans.txt new file mode 100644 index 0000000000..a325887027 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [10] ) +Code span at (1:0,1 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.stree.txt new file mode 100644 index 0000000000..8067d08e58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpReservedWordsTest/ReservedWordIsCaseSensitive.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..10)::10 - [@NameSpace] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpImplicitExpression - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..10)::9 + CSharpCodeBlock - [1..10)::9 + CSharpExpressionLiteral - [1..10)::9 - [NameSpace] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[NameSpace]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.cspans.txt new file mode 100644 index 0000000000..81c6af3935 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [46] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [46] ) +None span at (12:0,12 [18] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [46] ) +MetaCode span at (30:6,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Markup span at (31:6,1 [2] ) (Accepts:Any) - Parent: Markup block at (31:6,1 [14] ) +Markup span at (33:7,0 [3] ) (Accepts:Any) - Parent: Tag block at (33:7,0 [3] ) +Markup span at (36:7,3 [3] ) (Accepts:Any) - Parent: Markup block at (31:6,1 [14] ) +Markup span at (39:7,6 [4] ) (Accepts:Any) - Parent: Tag block at (39:7,6 [4] ) +Markup span at (43:7,10 [2] ) (Accepts:Any) - Parent: Markup block at (31:6,1 [14] ) +MetaCode span at (45:8,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [46] ) +Markup span at (46:8,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.stree.txt new file mode 100644 index 0000000000..bf7aa06f2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AcceptsOpenBraceMultipleLinesBelowSectionName.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..46)::46 - [@section foo LFLFLFLFLFLF{LF

                    Foo

                    LF}] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + RazorDirective - [0..46)::46 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..46)::45 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..46)::38 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..30)::18 - [ LFLFLFLFLFLF] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + NewLine;[LF]; + NewLine;[LF]; + NewLine;[LF]; + NewLine;[LF]; + NewLine;[LF]; + NewLine;[LF]; + RazorMetaCode - [30..31)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [31..45)::14 + MarkupTextLiteral - [31..33)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [33..43)::10 + MarkupStartTag - [33..36)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [36..39)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [39..43)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [43..45)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.cspans.txt new file mode 100644 index 0000000000..c3a621955f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [76] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [76] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [76] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +Markup span at (14:0,14 [54] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [61] ) +Transition span at (68:0,68 [1] ) (Accepts:None) - Parent: Expression block at (68:0,68 [6] ) +MetaCode span at (69:0,69 [1] ) (Accepts:None) - Parent: Expression block at (68:0,68 [6] ) +Code span at (70:0,70 [3] ) (Accepts:Any) - Parent: Expression block at (68:0,68 [6] ) +MetaCode span at (73:0,73 [1] ) (Accepts:None) - Parent: Expression block at (68:0,68 [6] ) +Markup span at (74:0,74 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [61] ) +MetaCode span at (75:0,75 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [76] ) +Markup span at (76:0,76 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [76] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.stree.txt new file mode 100644 index 0000000000..697f0d90a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/AllowsBracesInCSharpExpression.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..76)::76 - [@section foo { I really want to render a close brace, so here I go: @("}") }] + MarkupBlock - [0..76)::76 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..76)::76 + RazorDirective - [0..76)::76 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..76)::75 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..76)::68 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..75)::61 + MarkupTextLiteral - [14..68)::54 - [ I really want to render a close brace, so here I go: ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[I]; + Whitespace;[ ]; + Text;[really]; + Whitespace;[ ]; + Text;[want]; + Whitespace;[ ]; + Text;[to]; + Whitespace;[ ]; + Text;[render]; + Whitespace;[ ]; + Text;[a]; + Whitespace;[ ]; + Text;[close]; + Whitespace;[ ]; + Text;[brace,]; + Whitespace;[ ]; + Text;[so]; + Whitespace;[ ]; + Text;[here]; + Whitespace;[ ]; + Text;[I]; + Whitespace;[ ]; + Text;[go:]; + Whitespace;[ ]; + CSharpCodeBlock - [68..74)::6 + CSharpExplicitExpression - [68..74)::6 + CSharpTransition - [68..69)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [69..74)::5 + RazorMetaCode - [69..70)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [70..73)::3 + CSharpExpressionLiteral - [70..73)::3 - ["}"] - Gen - SpanEditHandler;Accepts:Any + StringLiteral;["}"]; + RazorMetaCode - [73..74)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [74..75)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [75..76)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [76..76)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.cspans.txt new file mode 100644 index 0000000000..72e4322f98 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [67] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [67] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [52] ) +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (23:0,23 [33] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [52] ) +Markup span at (56:0,56 [9] ) (Accepts:Any) - Parent: Tag block at (56:0,56 [9] ) +Markup span at (65:0,65 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [52] ) +MetaCode span at (66:0,66 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Markup span at (67:0,67 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.stree.txt new file mode 100644 index 0000000000..e324726675 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/BalancesBraces.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..67)::67 - [@section foo { }] + MarkupBlock - [0..67)::67 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..67)::67 + RazorDirective - [0..67)::67 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..67)::66 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..67)::59 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..66)::52 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..65)::50 + MarkupStartTag - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTextLiteral - [65..66)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [66..67)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [67..67)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.cspans.txt new file mode 100644 index 0000000000..ebd2ef1994 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.diag.txt new file mode 100644 index 0000000000..f15ab6ffa2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1015: The 'section' directive expects an identifier. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.stree.txt new file mode 100644 index 0000000000..b6a10e2a5e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesNewlineImmediatelyFollowing.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..10)::10 - [@sectionLF] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{section;RazorBlock;Unrestricted} [RZ1015(8:0,8 [2] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..8)::0 + MarkupTextLiteral - [8..10)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.cspans.txt new file mode 100644 index 0000000000..74bcdf61d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [9] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.diag.txt new file mode 100644 index 0000000000..feec72ed8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ1015: The 'section' directive expects an identifier. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.stree.txt new file mode 100644 index 0000000000..7f547e8173 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingName.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..23)::23 - [@section LF ] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 - Directive:{section;RazorBlock;Unrestricted} [RZ1015(17:0,17 [2] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..17)::9 + CSharpStatementLiteral - [8..17)::9 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [17..17)::0 - [] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Marker;[]; + MarkupTextLiteral - [17..23)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.cspans.txt new file mode 100644 index 0000000000..294ddf8df0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [27] ) +None span at (12:0,12 [15] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (27:1,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.diag.txt new file mode 100644 index 0000000000..498cbfed10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.diag.txt @@ -0,0 +1 @@ +(2,5): Error RZ1012: Unexpected end of file following the 'section' directive. Expected '{'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.stree.txt new file mode 100644 index 0000000000..8120e55a8e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..27)::27 - [@section Foo LF ] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + RazorDirective - [0..27)::27 - Directive:{section;RazorBlock;Unrestricted} [RZ1012(27:1,4 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..27)::26 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..27)::19 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Foo]; + UnclassifiedTextLiteral - [12..27)::15 - [ LF ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.cspans.txt new file mode 100644 index 0000000000..00b79335ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [33] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (12:0,12 [2] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [20] ) +Markup span at (14:1,0 [4] ) (Accepts:Any) - Parent: Tag block at (14:1,0 [4] ) +Markup span at (18:2,0 [4] ) (Accepts:None) - Parent: HtmlComment block at (18:2,0 [14] ) +Markup span at (22:2,4 [7] ) (Accepts:Whitespace) - Parent: HtmlComment block at (18:2,0 [14] ) +Markup span at (29:2,11 [3] ) (Accepts:None) - Parent: HtmlComment block at (18:2,0 [14] ) +Markup span at (32:2,14 [0] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [20] ) +MetaCode span at (32:2,14 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (33:2,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.stree.txt new file mode 100644 index 0000000000..6031164f1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CommentRecoversFromUnclosedTag.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..33)::33 - [@section s {LF " '-->}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + RazorDirective - [0..33)::33 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..33)::32 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..33)::25 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..10)::1 - [s] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[s]; + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [12..32)::20 + MarkupTextLiteral - [12..14)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [14..32)::18 + MarkupStartTag - [14..18)::4 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[a]; + MarkupMiscAttributeContent - [16..18)::2 + MarkupTextLiteral - [16..18)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CloseAngle;[]; + MarkupCommentBlock - [18..32)::14 + MarkupTextLiteral - [18..22)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.cspans.txt new file mode 100644 index 0000000000..4373c216a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [24] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [24] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [24] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [9] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.stree.txt new file mode 100644 index 0000000000..f1c5746916 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..24)::24 - [@section foo {something}] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + RazorDirective - [0..24)::24 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..24)::23 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..24)::16 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..23)::9 + MarkupTextLiteral - [14..23)::9 - [something] - Gen - SpanEditHandler;Accepts:Any + Text;[something]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.cspans.txt new file mode 100644 index 0000000000..ecf1378f32 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [26] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [12] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [3] ) +Markup span at (17:0,17 [3] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [12] ) +Markup span at (20:0,20 [4] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [4] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [12] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (26:0,26 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.stree.txt new file mode 100644 index 0000000000..ba64cef43e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/DoesNotRequireSpaceBetweenSectionNameAndOpenBrace.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..26)::26 - [@section foo{

                    Foo

                    }] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + RazorDirective - [0..26)::26 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..26)::25 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..26)::18 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + RazorMetaCode - [12..13)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [13..25)::12 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [14..24)::10 + MarkupStartTag - [14..17)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [20..24)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.cspans.txt new file mode 100644 index 0000000000..074b66bfa3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [14] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [14] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [0] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.diag.txt new file mode 100644 index 0000000000..e1bd35fcb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.stree.txt new file mode 100644 index 0000000000..8ced8d7768 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenBrace.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..14)::14 - [@section foo {] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + RazorDirective - [0..14)::14 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(13:0,13 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..14)::13 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..14)::6 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..14)::0 + MarkupTextLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [14..14)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.cspans.txt new file mode 100644 index 0000000000..c6e2742957 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [15] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [15] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.diag.txt new file mode 100644 index 0000000000..e1bd35fcb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.stree.txt new file mode 100644 index 0000000000..bf96aef353 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent1.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..15)::15 - [@section foo { ] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + RazorDirective - [0..15)::15 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(13:0,13 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..15)::14 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..15)::7 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..15)::1 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [15..15)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.cspans.txt new file mode 100644 index 0000000000..748a7fb61b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [16] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.diag.txt new file mode 100644 index 0000000000..e1bd35fcb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.stree.txt new file mode 100644 index 0000000000..c2addfe73d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent2.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..16)::16 - [@section foo {LF] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + RazorDirective - [0..16)::16 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(13:0,13 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..16)::15 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..16)::8 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..16)::2 + MarkupTextLiteral - [14..16)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [16..16)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.cspans.txt new file mode 100644 index 0000000000..06a080b1a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [17] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.diag.txt new file mode 100644 index 0000000000..e1bd35fcb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.stree.txt new file mode 100644 index 0000000000..291855088b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent3.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..17)::17 - [@section foo {abc] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(13:0,13 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..17)::9 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..17)::3 + MarkupTextLiteral - [14..17)::3 - [abc] - Gen - SpanEditHandler;Accepts:Any + Text;[abc]; + RazorMetaCode - [17..17)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.cspans.txt new file mode 100644 index 0000000000..34f459da77 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [20] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [20] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (14:0,14 [6] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.diag.txt new file mode 100644 index 0000000000..e1bd35fcb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.stree.txt new file mode 100644 index 0000000000..ae074a707f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesEOFAfterOpenContent4.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..20)::20 - [@section foo {LF abc] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + RazorDirective - [0..20)::20 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(13:0,13 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..20)::19 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..20)::12 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..20)::6 + MarkupTextLiteral - [14..20)::6 - [LF abc] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[abc]; + RazorMetaCode - [20..20)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.cspans.txt new file mode 100644 index 0000000000..5d0c1dc0ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [27] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [13] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [5] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [13] ) +Markup span at (23:0,23 [4] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.diag.txt new file mode 100644 index 0000000000..e1bd35fcb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.stree.txt new file mode 100644 index 0000000000..376832ecd9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSection.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..27)::27 - [@section foo {

                    Foo{}

                    ] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + RazorDirective - [0..27)::27 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(13:0,13 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..27)::26 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..27)::19 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..27)::13 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..27)::12 + MarkupStartTag - [15..18)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [18..23)::5 - [Foo{}] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Text;[{]; + Text;[}]; + MarkupEndTag - [23..27)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + RazorMetaCode - [27..27)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.cspans.txt new file mode 100644 index 0000000000..638db09576 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [73] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [73] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [73] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [73] ) +Code span at (9:0,9 [4] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [73] ) +None span at (13:0,13 [2] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [73] ) +MetaCode span at (15:1,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [73] ) +Markup span at (16:1,1 [2] ) (Accepts:Any) - Parent: Markup block at (16:1,1 [57] ) +Code span at (18:2,0 [4] ) (Accepts:Any) - Parent: Statement block at (18:2,0 [55] ) +Transition span at (22:2,4 [1] ) (Accepts:None) - Parent: Statement block at (18:2,0 [55] ) +Code span at (23:2,5 [17] ) (Accepts:Any) - Parent: Statement block at (18:2,0 [55] ) +Markup span at (40:4,0 [8] ) (Accepts:Any) - Parent: Markup block at (40:4,0 [28] ) +Markup span at (48:4,8 [3] ) (Accepts:None) - Parent: Tag block at (48:4,8 [3] ) +Markup span at (51:4,11 [11] ) (Accepts:Any) - Parent: Markup block at (40:4,0 [28] ) +Markup span at (62:4,22 [4] ) (Accepts:None) - Parent: Tag block at (62:4,22 [4] ) +Markup span at (66:4,26 [2] ) (Accepts:None) - Parent: Markup block at (40:4,0 [28] ) +Code span at (68:5,0 [5] ) (Accepts:Any) - Parent: Statement block at (18:2,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.diag.txt new file mode 100644 index 0000000000..e1202f894a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.diag.txt @@ -0,0 +1 @@ +(2,1): Error RZ1006: The section block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.stree.txt new file mode 100644 index 0000000000..7152eb1c54 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/HandlesUnterminatedSectionWithNestedIf.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..73)::73 - [@section TestLF{LF @if(true)LF {LF

                    Hello World

                    LF }] + MarkupBlock - [0..73)::73 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..73)::73 + RazorDirective - [0..73)::73 - Directive:{section;RazorBlock;Unrestricted} [RZ1006(15:1,0 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..73)::72 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..73)::65 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..13)::4 - [Test] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Test]; + UnclassifiedTextLiteral - [13..15)::2 - [LF] - Gen - SpanEditHandler;Accepts:AllWhitespace + NewLine;[LF]; + RazorMetaCode - [15..16)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + MarkupBlock - [16..73)::57 + MarkupTextLiteral - [16..18)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [18..73)::55 + CSharpStatementLiteral - [18..22)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpTransition - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [23..40)::17 - [if(true)LF {LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [40..68)::28 + MarkupTextLiteral - [40..48)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [48..66)::18 + MarkupStartTag - [48..51)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [51..62)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupEndTag - [62..66)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [66..68)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [68..73)::5 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + RazorMetaCode - [73..73)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.cspans.txt new file mode 100644 index 0000000000..500fddb951 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [8] ) +Code span at (1:0,1 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [8] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.stree.txt new file mode 100644 index 0000000000..8f8cb089b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/IgnoresSectionUnlessAllLowerCase.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..12)::12 - [@Section foo] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpImplicitExpression - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..8)::7 + CSharpCodeBlock - [1..8)::7 + CSharpExpressionLiteral - [1..8)::7 - [Section] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[Section]; + MarkupTextLiteral - [8..12)::4 - [ foo] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[foo]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.cspans.txt new file mode 100644 index 0000000000..8e87c7c6c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [30] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [30] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [30] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [15] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [14] ) +MetaCode span at (16:0,16 [8] ) (Accepts:None) - Parent: Directive block at (15:0,15 [14] ) +Code span at (24:0,24 [1] ) (Accepts:Whitespace) - Parent: Directive block at (15:0,15 [14] ) +Code span at (25:0,25 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (15:0,15 [14] ) +None span at (28:0,28 [1] ) (Accepts:Whitespace) - Parent: Directive block at (15:0,15 [14] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [15] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.diag.txt new file mode 100644 index 0000000000..7f29e8edf5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.diag.txt @@ -0,0 +1,2 @@ +(1,17): Error RZ2005: The 'inherits` directive must appear at the start of the line. +(1,30): Error RZ1017: Unexpected literal following the 'inherits' directive. Expected 'line break'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.stree.txt new file mode 100644 index 0000000000..0a06cbca9a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserDoesNotOutputErrorOtherNestedDirectives.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..30)::30 - [@section foo { @inherits Bar }] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + RazorDirective - [0..30)::30 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..30)::29 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..30)::22 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..29)::15 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [15..29)::14 + RazorDirective - [15..29)::14 - Directive:{inherits;SingleLine;FileScopedSinglyOccurring} [RZ2005(16:0,16 [8] ), RZ1017(29:0,29 [1] )] + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [16..29)::13 + RazorMetaCode - [16..24)::8 - Gen - SpanEditHandler;Accepts:None + Identifier;[inherits]; + CSharpCodeBlock - [24..29)::5 + CSharpStatementLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [25..28)::3 - [Bar] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Bar]; + UnclassifiedTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.cspans.txt new file mode 100644 index 0000000000..7b1ac91e41 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.cspans.txt @@ -0,0 +1,32 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [61] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [61] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [61] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [61] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [61] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [61] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [61] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [46] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [44] ) +MetaCode span at (16:0,16 [7] ) (Accepts:None) - Parent: Directive block at (15:0,15 [44] ) +Code span at (23:0,23 [1] ) (Accepts:Whitespace) - Parent: Directive block at (15:0,15 [44] ) +Code span at (24:0,24 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (15:0,15 [44] ) +None span at (27:0,27 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (15:0,15 [44] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [44] ) +Markup span at (29:0,29 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [29] ) +Markup span at (30:0,30 [3] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [3] ) +Markup span at (33:0,33 [3] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [29] ) +Markup span at (36:0,36 [4] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [4] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [29] ) +Transition span at (41:0,41 [1] ) (Accepts:None) - Parent: Directive block at (41:0,41 [16] ) +MetaCode span at (42:0,42 [7] ) (Accepts:None) - Parent: Directive block at (41:0,41 [16] ) +Code span at (49:0,49 [1] ) (Accepts:Whitespace) - Parent: Directive block at (41:0,41 [16] ) +Code span at (50:0,50 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (41:0,41 [16] ) +None span at (53:0,53 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (41:0,41 [16] ) +MetaCode span at (54:0,54 [1] ) (Accepts:None) - Parent: Directive block at (41:0,41 [16] ) +Markup span at (55:0,55 [1] ) (Accepts:Any) - Parent: Markup block at (55:0,55 [1] ) +MetaCode span at (56:0,56 [1] ) (Accepts:None) - Parent: Directive block at (41:0,41 [16] ) +Markup span at (57:0,57 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [29] ) +MetaCode span at (58:0,58 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [44] ) +Markup span at (59:0,59 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [46] ) +MetaCode span at (60:0,60 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [61] ) +Markup span at (61:0,61 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [61] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.diag.txt new file mode 100644 index 0000000000..5ba54f32e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.diag.txt @@ -0,0 +1,4 @@ +(1,16): Error RZ2002: Section blocks ("@section Header { ... }") cannot be nested. Only one level of section blocks are allowed. +(1,17): Error RZ2005: The 'section` directive must appear at the start of the line. +(1,42): Error RZ2002: Section blocks ("@section Header { ... }") cannot be nested. Only one level of section blocks are allowed. +(1,43): Error RZ2005: The 'section` directive must appear at the start of the line. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.stree.txt new file mode 100644 index 0000000000..adfbb5aa6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnMultipleNestedSections.stree.txt @@ -0,0 +1,87 @@ +RazorDocument - [0..61)::61 - [@section foo { @section bar {

                    Foo

                    @section baz { } } }] + MarkupBlock - [0..61)::61 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..61)::61 + RazorDirective - [0..61)::61 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..61)::60 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..61)::53 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..60)::46 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [15..59)::44 + RazorDirective - [15..59)::44 - Directive:{section;RazorBlock;Unrestricted} [RZ2005(16:0,16 [7] ), RZ2002(15:0,15 [8] )] + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [16..59)::43 + RazorMetaCode - [16..23)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [23..59)::36 + CSharpStatementLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [24..27)::3 - [bar] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[bar]; + UnclassifiedTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [28..29)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [29..58)::29 + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [30..40)::10 + MarkupStartTag - [30..33)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [33..36)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [36..40)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [41..57)::16 + RazorDirective - [41..57)::16 - Directive:{section;RazorBlock;Unrestricted} [RZ2005(42:0,42 [7] ), RZ2002(41:0,41 [8] )] + CSharpTransition - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [42..57)::15 + RazorMetaCode - [42..49)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [49..57)::8 + CSharpStatementLiteral - [49..50)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [50..53)::3 - [baz] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[baz]; + UnclassifiedTextLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [54..55)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [55..56)::1 + MarkupTextLiteral - [55..56)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [56..57)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [57..58)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [58..59)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [59..60)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [60..61)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [61..61)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.cspans.txt new file mode 100644 index 0000000000..f4b0f08c70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.cspans.txt @@ -0,0 +1,23 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [44] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [29] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +MetaCode span at (16:0,16 [7] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +Code span at (23:0,23 [1] ) (Accepts:Whitespace) - Parent: Directive block at (15:0,15 [27] ) +Code span at (24:0,24 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (15:0,15 [27] ) +None span at (27:0,27 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (15:0,15 [27] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +Markup span at (29:0,29 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +Markup span at (30:0,30 [3] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [3] ) +Markup span at (33:0,33 [3] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +Markup span at (36:0,36 [4] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [4] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +MetaCode span at (41:0,41 [1] ) (Accepts:None) - Parent: Directive block at (15:0,15 [27] ) +Markup span at (42:0,42 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [29] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:0,44 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.diag.txt new file mode 100644 index 0000000000..756b35bd86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.diag.txt @@ -0,0 +1,2 @@ +(1,16): Error RZ2002: Section blocks ("@section Header { ... }") cannot be nested. Only one level of section blocks are allowed. +(1,17): Error RZ2005: The 'section` directive must appear at the start of the line. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.stree.txt new file mode 100644 index 0000000000..50696e68f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParserOutputsErrorOnNestedSections.stree.txt @@ -0,0 +1,64 @@ +RazorDocument - [0..44)::44 - [@section foo { @section bar {

                    Foo

                    } }] + MarkupBlock - [0..44)::44 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + RazorDirective - [0..44)::44 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..44)::43 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..44)::36 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..43)::29 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [15..42)::27 + RazorDirective - [15..42)::27 - Directive:{section;RazorBlock;Unrestricted} [RZ2005(16:0,16 [7] ), RZ2002(15:0,15 [8] )] + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [16..42)::26 + RazorMetaCode - [16..23)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [23..42)::19 + CSharpStatementLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [24..27)::3 - [bar] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[bar]; + UnclassifiedTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [28..29)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [29..41)::12 + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [30..40)::10 + MarkupStartTag - [30..33)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [33..36)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [36..40)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.cspans.txt new file mode 100644 index 0000000000..3128f77ff8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [21] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [21] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [8] ) +Markup span at (16:0,16 [1] ) (Accepts:Whitespace) - Parent: HtmlComment block at (12:0,12 [8] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [8] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [8] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.stree.txt new file mode 100644 index 0000000000..fe774d1047 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesComment.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..21)::21 - [@section s {}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + RazorDirective - [0..21)::21 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..21)::20 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..21)::13 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..10)::1 - [s] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[s]; + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [12..20)::8 + MarkupCommentBlock - [12..20)::8 + MarkupTextLiteral - [12..16)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.cspans.txt new file mode 100644 index 0000000000..6303d19bff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [26] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [26] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [26] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [13] ) +Markup span at (16:0,16 [6] ) (Accepts:Whitespace) - Parent: HtmlComment block at (12:0,12 [13] ) +Markup span at (22:0,22 [3] ) (Accepts:None) - Parent: HtmlComment block at (12:0,12 [13] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [13] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [26] ) +Markup span at (26:0,26 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.stree.txt new file mode 100644 index 0000000000..3d67883302 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesCommentWithDelimiters.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..26)::26 - [@section s {}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + RazorDirective - [0..26)::26 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..26)::25 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..26)::18 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..10)::1 - [s] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[s]; + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [12..25)::13 + MarkupCommentBlock - [12..25)::13 + MarkupTextLiteral - [12..16)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.cspans.txt new file mode 100644 index 0000000000..288a8a8447 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [27] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [12] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [3] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [12] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [4] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [12] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.stree.txt new file mode 100644 index 0000000000..86825c5816 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesNamedSectionCorrectly.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..27)::27 - [@section foo {

                    Foo

                    }] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + RazorDirective - [0..27)::27 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..27)::26 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..27)::19 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..26)::12 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..25)::10 + MarkupStartTag - [15..18)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [18..21)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [21..25)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.cspans.txt new file mode 100644 index 0000000000..468ea2f186 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [28] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [28] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (12:0,12 [15] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [15] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.stree.txt new file mode 100644 index 0000000000..a18fe82823 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ParsesXmlProcessingInstruction.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..28)::28 - [@section s { }] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + RazorDirective - [0..28)::28 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..28)::27 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..28)::20 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..10)::1 - [s] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[s]; + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [12..27)::15 + MarkupTextLiteral - [12..27)::15 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + OpenAngle;[<]; + QuestionMark;[?]; + Whitespace;[ ]; + Text;[xml]; + Whitespace;[ ]; + Text;[bleh]; + Whitespace;[ ]; + QuestionMark;[?]; + CloseAngle;[>]; + RazorMetaCode - [27..28)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.cspans.txt new file mode 100644 index 0000000000..0b57ebf59f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [20] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [20] ) +None span at (12:0,12 [8] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (20:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.diag.txt new file mode 100644 index 0000000000..079c1c2fda --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.diag.txt @@ -0,0 +1 @@ +(2,1): Error RZ1012: Unexpected end of file following the 'section' directive. Expected '{'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.stree.txt new file mode 100644 index 0000000000..4aaa12bea3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..20)::20 - [@section foo LF] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + RazorDirective - [0..20)::20 - Directive:{section;RazorBlock;Unrestricted} [RZ1012(20:1,0 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..20)::19 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..20)::12 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [12..20)::8 - [ LF] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.cspans.txt new file mode 100644 index 0000000000..1b511f83f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [9] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [9] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [9] ) +Markup span at (9:0,9 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [3] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (19:0,19 [4] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [4] ) +Markup span at (23:0,23 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.diag.txt new file mode 100644 index 0000000000..81ec8bff11 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ1015: The 'section' directive expects an identifier. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.stree.txt new file mode 100644 index 0000000000..7ce390e0b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..25)::25 - [@section 9 {

                    Foo

                    }] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..9)::9 + RazorDirective - [0..9)::9 - Directive:{section;RazorBlock;Unrestricted} [RZ1015(9:0,9 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..9)::8 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..9)::1 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [9..13)::4 - [9 { ] - Gen - SpanEditHandler;Accepts:Any + Text;[9]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + MarkupElement - [13..23)::10 + MarkupStartTag - [13..16)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [16..19)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [19..23)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [23..25)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.cspans.txt new file mode 100644 index 0000000000..b1564f1bc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [12] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [12] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [12] ) +Markup span at (12:0,12 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [3] ) +Markup span at (22:0,22 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (25:0,25 [4] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [4] ) +Markup span at (29:0,29 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.diag.txt new file mode 100644 index 0000000000..fd83ce295e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.diag.txt @@ -0,0 +1 @@ +(1,13): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.stree.txt new file mode 100644 index 0000000000..6ba250ccaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..31)::31 - [@section foo-bar {

                    Foo

                    }] + MarkupBlock - [0..31)::31 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + RazorDirective - [0..12)::12 - Directive:{section;RazorBlock;Unrestricted} [RZ1017(12:0,12 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..12)::11 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..12)::4 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + MarkupTextLiteral - [12..19)::7 - [-bar { ] - Gen - SpanEditHandler;Accepts:Any + Text;[-bar]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + MarkupElement - [19..29)::10 + MarkupStartTag - [19..22)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [22..25)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [25..29)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [29..31)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.cspans.txt new file mode 100644 index 0000000000..713abda61d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [31] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [31] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [31] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [16] ) +Transition span at (16:1,0 [1] ) (Accepts:None) - Parent: Statement block at (16:1,0 [14] ) +Code span at (17:1,1 [13] ) (Accepts:Any) - Parent: Statement block at (16:1,0 [14] ) +MetaCode span at (30:2,1 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [31] ) +Markup span at (31:2,2 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.stree.txt new file mode 100644 index 0000000000..f6f748f944 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..31)::31 - [@section Foo {LF@if(true) {LF}}] + MarkupBlock - [0..31)::31 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + RazorDirective - [0..31)::31 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..31)::30 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..31)::23 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..30)::16 + MarkupTextLiteral - [14..16)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [16..30)::14 + CSharpTransition - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [17..30)::13 - [if(true) {LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.cspans.txt new file mode 100644 index 0000000000..4ef0cf352d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [33] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [18] ) +Transition span at (16:1,0 [1] ) (Accepts:None) - Parent: Statement block at (16:1,0 [16] ) +Code span at (17:1,1 [15] ) (Accepts:Any) - Parent: Statement block at (16:1,0 [16] ) +MetaCode span at (32:3,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (33:3,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.stree.txt new file mode 100644 index 0000000000..1dd0e69729 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlock.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..33)::33 - [@section Foo {LF@if(true) {LF}LF}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + RazorDirective - [0..33)::33 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..33)::32 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..33)::25 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..32)::18 + MarkupTextLiteral - [14..16)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [16..32)::16 + CSharpTransition - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [17..32)::15 - [if(true) {LF}LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.cspans.txt new file mode 100644 index 0000000000..fd7f466680 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [30] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [30] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [30] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (12:0,12 [5] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [17] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [9] ) +Markup span at (23:0,23 [1] ) (Accepts:None) - Parent: Markup block at (23:0,23 [2] ) +Markup span at (24:0,24 [1] ) (Accepts:None) - Parent: Markup block at (23:0,23 [2] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [9] ) +Markup span at (26:0,26 [3] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [17] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.stree.txt new file mode 100644 index 0000000000..bd38826bb7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition1.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..30)::30 - [@section s {}] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + RazorDirective - [0..30)::30 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..30)::29 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..30)::22 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..10)::1 - [s] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[s]; + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [12..29)::17 + MarkupElement - [12..29)::17 + MarkupStartTag - [12..29)::17 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [17..26)::9 - [ foo='@@'] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..21)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [23..25)::2 + MarkupBlock - [23..25)::2 + MarkupTextLiteral - [23..24)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [24..25)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [26..27)::1 + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.cspans.txt new file mode 100644 index 0000000000..0a4a2f665f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (9:0,9 [1] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [44] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (12:0,12 [5] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [31] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [23] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Expression block at (23:0,23 [13] ) +Code span at (24:0,24 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (23:0,23 [13] ) +Markup span at (36:0,36 [2] ) (Accepts:None) - Parent: Markup block at (36:0,36 [3] ) +Markup span at (38:0,38 [1] ) (Accepts:None) - Parent: Markup block at (36:0,36 [3] ) +Markup span at (39:0,39 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [23] ) +Markup span at (40:0,40 [3] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [31] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:0,44 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.stree.txt new file mode 100644 index 0000000000..2bbe5cc9d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSectionTest/_WithDoubleTransition2.stree.txt @@ -0,0 +1,63 @@ +RazorDocument - [0..44)::44 - [@section s {}] + MarkupBlock - [0..44)::44 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + RazorDirective - [0..44)::44 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..44)::43 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..44)::36 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..10)::1 - [s] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[s]; + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [12..43)::31 + MarkupElement - [12..43)::31 + MarkupStartTag - [12..43)::31 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [17..40)::23 - [ foo='@DateTime.Now @@'] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..21)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [23..39)::16 + MarkupDynamicAttributeValue - [23..36)::13 - [@DateTime.Now] + GenericBlock - [23..36)::13 + CSharpCodeBlock - [23..36)::13 + CSharpImplicitExpression - [23..36)::13 + CSharpTransition - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [24..36)::12 + CSharpCodeBlock - [24..36)::12 + CSharpExpressionLiteral - [24..36)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupBlock - [36..39)::3 + MarkupTextLiteral - [36..38)::2 - [ @] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Transition;[@]; + MarkupEphemeralTextLiteral - [38..39)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [39..40)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [40..41)::1 + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + RazorMetaCode - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.cspans.txt new file mode 100644 index 0000000000..58aa7eca66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +Code span at (2:0,2 [50] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) +MetaCode span at (52:0,52 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +Markup span at (53:0,53 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.stree.txt new file mode 100644 index 0000000000..74ff9e617e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..53)::53 - [@{foo"b}ar" if(condition) { string.Format("{0}"); } }] + MarkupBlock - [0..53)::53 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..53)::53 + CSharpStatement - [0..53)::53 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..53)::52 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..52)::50 + CSharpStatementLiteral - [2..52)::50 - [foo"b}ar" if(condition) { string.Format("{0}"); } ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Identifier;[foo]; + StringLiteral;["b}ar"]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[condition]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Keyword;[string]; + Dot;[.]; + Identifier;[Format]; + LeftParenthesis;[(]; + StringLiteral;["{0}"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [53..53)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.cspans.txt new file mode 100644 index 0000000000..9941127366 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [53] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [53] ) +Code span at (2:0,2 [50] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [53] ) +MetaCode span at (52:0,52 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [53] ) +Markup span at (53:0,53 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.stree.txt new file mode 100644 index 0000000000..6304616645 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..53)::53 - [@(foo"b)ar" if(condition) { string.Format("{0}"); } )] + MarkupBlock - [0..53)::53 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..53)::53 + CSharpExplicitExpression - [0..53)::53 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..53)::52 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..52)::50 + CSharpExpressionLiteral - [2..52)::50 - [foo"b)ar" if(condition) { string.Format("{0}"); } ] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + StringLiteral;["b)ar"]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[condition]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Keyword;[string]; + Dot;[.]; + Identifier;[Format]; + LeftParenthesis;[(]; + StringLiteral;["{0}"]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [53..53)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.cspans.txt new file mode 100644 index 0000000000..5d386ce1ba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Code span at (2:0,2 [35] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:0,38 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.stree.txt new file mode 100644 index 0000000000..14cc48739f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NamespaceImportInsideCodeBlockCausesError.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..38)::38 - [@{ using Foo.Bar.Baz; var foo = bar; }] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpStatement - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..37)::35 + CSharpStatementLiteral - [2..37)::35 - [ using Foo.Bar.Baz; var foo = bar; ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[using]; + Whitespace;[ ]; + Identifier;[Foo]; + Dot;[.]; + Identifier;[Bar]; + Dot;[.]; + Identifier;[Baz]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.cspans.txt new file mode 100644 index 0000000000..6e4138ea53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Code span at (2:0,2 [54] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) +MetaCode span at (56:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Markup span at (57:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.stree.txt new file mode 100644 index 0000000000..bf39ca1547 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/NonKeywordStatementInCodeBlockIsHandledCorrectly.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..57)::57 - [@{LF List photos = gallery.Photo.ToList();LF}] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpStatement - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..57)::56 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..56)::54 + CSharpStatementLiteral - [2..56)::54 - [LF List photos = gallery.Photo.ToList();LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[List]; + LessThan;[<]; + Identifier;[dynamic]; + GreaterThan;[>]; + Whitespace;[ ]; + Identifier;[photos]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[gallery]; + Dot;[.]; + Identifier;[Photo]; + Dot;[.]; + Identifier;[ToList]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [56..57)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [57..57)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.cspans.txt new file mode 100644 index 0000000000..320067e579 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.diag.txt new file mode 100644 index 0000000000..6d8d0cd1bb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "/" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.stree.txt new file mode 100644 index 0000000000..f83ce55634 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockIgnoresSingleSlashAtStart.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..6)::6 - [@/ foo] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..6)::5 - [/ foo] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + Whitespace;[ ]; + Text;[foo]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.cspans.txt new file mode 100644 index 0000000000..12ec38b2d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Code span at (1:0,1 [26] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) +Markup span at (27:2,0 [1] ) (Accepts:Any) - Parent: Markup block at (27:2,0 [21] ) +Markup span at (28:2,1 [3] ) (Accepts:None) - Parent: Tag block at (28:2,1 [3] ) +Markup span at (31:2,4 [11] ) (Accepts:Any) - Parent: Markup block at (27:2,0 [21] ) +Markup span at (42:2,15 [4] ) (Accepts:None) - Parent: Tag block at (42:2,15 [4] ) +Markup span at (46:2,19 [2] ) (Accepts:None) - Parent: Markup block at (27:2,0 [21] ) +Code span at (48:3,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.stree.txt new file mode 100644 index 0000000000..a97f0f5812 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/ParseBlockTerminatesSingleLineCommentAtEndOfLine.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..49)::49 - [@if(!false) {LF // FooLF

                    A real tag!

                    LF}] + MarkupBlock - [0..49)::49 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..49)::49 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..27)::26 - [if(!false) {LF // FooLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Not;[!]; + Keyword;[false]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + CSharpComment;[// Foo]; + NewLine;[LF]; + MarkupBlock - [27..48)::21 + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [28..46)::18 + MarkupStartTag - [28..31)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [31..42)::11 - [A real tag!] - Gen - SpanEditHandler;Accepts:Any + Text;[A]; + Whitespace;[ ]; + Text;[real]; + Whitespace;[ ]; + Text;[tag]; + Bang;[!]; + MarkupEndTag - [42..46)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [46..48)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [48..49)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.cspans.txt new file mode 100644 index 0000000000..15f7b3d523 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Code span at (2:0,2 [37] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (39:0,39 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (40:0,40 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.stree.txt new file mode 100644 index 0000000000..54a90a74b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpSpecialBlockTest/TypeAliasInsideCodeBlockIsNotHandledSpecially.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..40)::40 - [@{ using Foo = Bar.Baz; var foo = bar; }] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..39)::37 + CSharpStatementLiteral - [2..39)::37 - [ using Foo = Bar.Baz; var foo = bar; ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[using]; + Whitespace;[ ]; + Identifier;[Foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[Bar]; + Dot;[.]; + Identifier;[Baz]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [39..40)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/AwaitForEachStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/AwaitForEachStatement.cspans.txt new file mode 100644 index 0000000000..d4911d2950 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/AwaitForEachStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Code span at (1:0,1 [40] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (41:0,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/AwaitForEachStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/AwaitForEachStatement.stree.txt new file mode 100644 index 0000000000..abd0bc235d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/AwaitForEachStatement.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..41)::41 - [@await foreach(var foo in bar) { foo(); }] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..41)::40 - [await foreach(var foo in bar) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[await]; + Whitespace;[ ]; + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.cspans.txt new file mode 100644 index 0000000000..a01e4584d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [94] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [94] ) +Code span at (1:0,1 [93] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [94] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.stree.txt new file mode 100644 index 0000000000..d369b28d28 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/CatchClause.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..94)::94 - [@try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }] + MarkupBlock - [0..94)::94 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..94)::94 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..94)::93 - [try { foo(); } catch(IOException ioex) { handleIO(); } catch(Exception ex) { handleOther(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[IOException]; + Whitespace;[ ]; + Identifier;[ioex]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[handleIO]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + Whitespace;[ ]; + Identifier;[ex]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[handleOther]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.cspans.txt new file mode 100644 index 0000000000..0ef53c991b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Code span at (1:0,1 [26] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.stree.txt new file mode 100644 index 0000000000..2861b1c596 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/DoStatement.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..27)::27 - [@do { foo(); } while(true);] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..27)::26 - [do { foo(); } while(true);] - Gen - SpanEditHandler;Accepts:None + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.cspans.txt new file mode 100644 index 0000000000..28d83350e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Code span at (1:0,1 [35] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.stree.txt new file mode 100644 index 0000000000..fd032ca251 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseClause.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..36)::36 - [@if(true) { foo(); } else { foo(); }] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..36)::35 - [if(true) { foo(); } else { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.cspans.txt new file mode 100644 index 0000000000..aeec5c79f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [73] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [73] ) +Code span at (1:0,1 [72] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [73] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.stree.txt new file mode 100644 index 0000000000..ba0efa1002 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ElseIfClause.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..73)::73 - [@if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }] + MarkupBlock - [0..73)::73 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..73)::73 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..73)::72 - [if(true) { foo(); } else if(false) { foo(); } else if(!false) { foo(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Not;[!]; + Keyword;[false]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.cspans.txt new file mode 100644 index 0000000000..a4f8405520 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +Code span at (1:0,1 [52] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.diag.txt new file mode 100644 index 0000000000..821f352b2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.diag.txt @@ -0,0 +1 @@ +(1,24): Error RZ1006: The catch block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.stree.txt new file mode 100644 index 0000000000..4c3534f86f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteBody.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..53)::53 - [@try { someMethod(); } catch(Exception) when (true) {] + MarkupBlock - [0..53)::53 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..53)::53 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..53)::52 - [try { someMethod(); } catch(Exception) when (true) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.cspans.txt new file mode 100644 index 0000000000..70b420119b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Code span at (1:0,1 [45] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.diag.txt new file mode 100644 index 0000000000..33043e2030 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.diag.txt @@ -0,0 +1 @@ +(1,46): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.stree.txt new file mode 100644 index 0000000000..c4d32daa6c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilterError_TryCatchWhen_InCompleteCondition.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..46)::46 - [@try { someMethod(); } catch(Exception) when (] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..46)::45 - [try { someMethod(); } catch(Exception) when (] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.cspans.txt new file mode 100644 index 0000000000..957b72bff8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [65] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [65] ) +Code span at (1:0,1 [64] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [65] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.stree.txt new file mode 100644 index 0000000000..7ca00fefc7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchNoBodyWhen.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..65)::65 - [@try { someMethod(); } catch(Exception) when { anotherMethod(); }] + MarkupBlock - [0..65)::65 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..65)::65 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..65)::64 - [try { someMethod(); } catch(Exception) when { anotherMethod(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[anotherMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.cspans.txt new file mode 100644 index 0000000000..b12747ada5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Code span at (1:0,1 [43] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [44] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.stree.txt new file mode 100644 index 0000000000..adbef40a1d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhen.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..44)::44 - [@try { someMethod(); } catch(Exception) when] + MarkupBlock - [0..44)::44 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..44)::43 - [try { someMethod(); } catch(Exception) when] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.cspans.txt new file mode 100644 index 0000000000..4b8a2bb802 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Code span at (1:0,1 [50] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.stree.txt new file mode 100644 index 0000000000..8bd5aa4ee0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryCatchWhenNoBodies.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..51)::51 - [@try { someMethod(); } catch(Exception) when (true)] + MarkupBlock - [0..51)::51 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..51)::51 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..51)::50 - [try { someMethod(); } catch(Exception) when (true)] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.cspans.txt new file mode 100644 index 0000000000..70af370fb6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Code span at (1:0,1 [21] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.stree.txt new file mode 100644 index 0000000000..9f1d367820 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_IncompleteTryWhen.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..27)::27 - [@try { someMethod(); } when] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..22)::21 - [try { someMethod(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [22..27)::5 - [ when] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[when]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.cspans.txt new file mode 100644 index 0000000000..1c9dd5a659 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [103] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [103] ) +Code span at (1:0,1 [102] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [103] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.stree.txt new file mode 100644 index 0000000000..adbc2b8c66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_MultiLine.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..103)::103 - [@tryLF{LFA();LF}LFcatch(Exception) when (true)LF{LFB();LF}LFcatch(IOException) when (false)LF{LFC();LF}] + MarkupBlock - [0..103)::103 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..103)::103 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..103)::102 - [tryLF{LFA();LF}LFcatch(Exception) when (true)LF{LFB();LF}LFcatch(IOException) when (false)LF{LFC();LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + Identifier;[A]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + Identifier;[B]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + NewLine;[LF]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[IOException]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + NewLine;[LF]; + LeftBrace;[{]; + NewLine;[LF]; + Identifier;[C]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.cspans.txt new file mode 100644 index 0000000000..54e259787a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) +Code span at (2:0,2 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [69] ) +MetaCode span at (68:0,68 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [69] ) +Markup span at (69:0,69 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.stree.txt new file mode 100644 index 0000000000..8afdc4bc9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_NestedTryCatchWhen.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..69)::69 - [@{try { someMethod(); } catch(Exception) when (true) { handleIO(); }}] + MarkupBlock - [0..69)::69 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..69)::69 + CSharpStatement - [0..69)::69 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..69)::68 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..68)::66 + CSharpStatementLiteral - [2..68)::66 - [try { someMethod(); } catch(Exception) when (true) { handleIO(); }] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[handleIO]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + RazorMetaCode - [68..69)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [69..69)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.cspans.txt new file mode 100644 index 0000000000..eaf9d4d880 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [92] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [92] ) +Code span at (1:0,1 [91] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [92] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.stree.txt new file mode 100644 index 0000000000..89d4307ace --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenCatchWhenComplete_SingleLine.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..92)::92 - [@try { A(); } catch(Exception) when (true) { B(); } catch(IOException) when (false) { C(); }] + MarkupBlock - [0..92)::92 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..92)::92 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..92)::91 - [try { A(); } catch(Exception) when (true) { B(); } catch(IOException) when (false) { C(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[A]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[B]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[IOException]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[C]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.cspans.txt new file mode 100644 index 0000000000..2d883a5590 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [67] ) +Code span at (1:0,1 [66] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [67] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.stree.txt new file mode 100644 index 0000000000..8a1e974063 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenComplete_SingleLine.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..67)::67 - [@try { someMethod(); } catch(Exception) when (true) { handleIO(); }] + MarkupBlock - [0..67)::67 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..67)::67 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..67)::66 - [try { someMethod(); } catch(Exception) when (true) { handleIO(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someMethod]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[handleIO]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.cspans.txt new file mode 100644 index 0000000000..4852e2bc04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Code span at (1:0,1 [67] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Markup span at (68:0,68 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.stree.txt new file mode 100644 index 0000000000..0a385e2668 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ExceptionFilter_TryCatchWhenFinallyComplete_SingleLine.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..68)::68 - [@try { A(); } catch(Exception) when (true) { B(); } finally { C(); }] + MarkupBlock - [0..68)::68 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..68)::68 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..68)::67 - [try { A(); } catch(Exception) when (true) { B(); } finally { C(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[A]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[catch]; + LeftParenthesis;[(]; + Identifier;[Exception]; + RightParenthesis;[)]; + Whitespace;[ ]; + Keyword;[when]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[B]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[C]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [68..68)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.cspans.txt new file mode 100644 index 0000000000..0b4bcf4edf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Code span at (1:0,1 [37] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:0,38 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.stree.txt new file mode 100644 index 0000000000..a954f77c66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/FinallyClause.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..38)::38 - [@try { foo(); } finally { Dispose(); }] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..38)::37 - [try { foo(); } finally { Dispose(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[finally]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Dispose]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.cspans.txt new file mode 100644 index 0000000000..dce52a5221 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Code span at (1:0,1 [34] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Markup span at (35:0,35 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.stree.txt new file mode 100644 index 0000000000..5bf4fcfbaf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForEachStatement.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..35)::35 - [@foreach(var foo in bar) { foo(); }] + MarkupBlock - [0..35)::35 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..35)::35 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..35)::34 - [foreach(var foo in bar) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.cspans.txt new file mode 100644 index 0000000000..1c487bc0c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Code span at (1:0,1 [42] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (43:0,43 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.stree.txt new file mode 100644 index 0000000000..12634efa7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/ForStatement.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..43)::43 - [@for(int i = 0; i++; i < length) { foo(); }] + MarkupBlock - [0..43)::43 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..43)::43 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..43)::42 - [for(int i = 0; i++; i < length) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[for]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + Identifier;[length]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.cspans.txt new file mode 100644 index 0000000000..887f311722 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.stree.txt new file mode 100644 index 0000000000..70766aa364 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/IfStatement.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..20)::20 - [@if(true) { foo(); }] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..20)::19 - [if(true) { foo(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.cspans.txt new file mode 100644 index 0000000000..33dc768c7d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Code span at (1:0,1 [20] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.stree.txt new file mode 100644 index 0000000000..1bb156c26d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/LockStatement.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..21)::21 - [@lock(baz) { foo(); }] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..21)::20 - [lock(baz) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[lock]; + LeftParenthesis;[(]; + Identifier;[baz]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.cspans.txt new file mode 100644 index 0000000000..2ed26af598 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Code span at (1:0,1 [38] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.diag.txt new file mode 100644 index 0000000000..994acd46f2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.diag.txt @@ -0,0 +1 @@ +(1,15): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.stree.txt new file mode 100644 index 0000000000..e0398c5923 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/MalformedAwaitForEachStatement.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..39)::39 - [@await foreach(var foo in bar { foo(); ] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..39)::38 - [await foreach(var foo in bar { foo(); ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[await]; + Whitespace;[ ]; + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[bar]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.cspans.txt new file mode 100644 index 0000000000..11ff79adf0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [3] ) +Code span at (1:0,1 [2] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [3] ) +Markup span at (3:0,3 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.stree.txt new file mode 100644 index 0000000000..a55975b613 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/NonBlockKeywordTreatedAsImplicitExpression.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..7)::7 - [@is foo] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..3)::3 + CSharpImplicitExpression - [0..3)::3 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..3)::2 + CSharpCodeBlock - [1..3)::2 + CSharpExpressionLiteral - [1..3)::2 - [is] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Keyword;[is]; + MarkupTextLiteral - [3..7)::4 - [ foo] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[foo]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.cspans.txt new file mode 100644 index 0000000000..8ead4f60c2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [40] ) +Code span at (1:0,1 [39] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [40] ) +Markup span at (40:0,40 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.stree.txt new file mode 100644 index 0000000000..6769177337 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_Complete_Spaced.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..42)::42 - [@using static global::System.Console ] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + RazorDirective - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..40)::39 + CSharpStatementLiteral - [1..40)::39 - [using static global::System.Console] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Keyword;[static]; + Whitespace;[ ]; + Identifier;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Console]; + MarkupTextLiteral - [40..42)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.cspans.txt new file mode 100644 index 0000000000..e4feb782e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [36] ) +Code span at (1:0,1 [35] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.stree.txt new file mode 100644 index 0000000000..2944c79da1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_GlobalPrefix.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..36)::36 - [@using static global::System.Console] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + RazorDirective - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..36)::35 + CSharpStatementLiteral - [1..36)::35 - [using static global::System.Console] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Keyword;[static]; + Whitespace;[ ]; + Identifier;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Console]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.cspans.txt new file mode 100644 index 0000000000..8510b2c37d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Code span at (1:0,1 [27] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.stree.txt new file mode 100644 index 0000000000..553f6174f2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_MultipleIdentifiers.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..28)::28 - [@using static System.Console] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + RazorDirective - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..28)::27 + CSharpStatementLiteral - [1..28)::27 - [using static System.Console] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Keyword;[static]; + Whitespace;[ ]; + Identifier;[System]; + Dot;[.]; + Identifier;[Console]; + MarkupTextLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.cspans.txt new file mode 100644 index 0000000000..6baa3a6c93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [13] ) +Code span at (1:0,1 [12] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [13] ) +Markup span at (13:0,13 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.stree.txt new file mode 100644 index 0000000000..25a5facf95 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_NoUsing.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..13)::13 - [@using static] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + RazorDirective - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..13)::12 + CSharpStatementLiteral - [1..13)::12 - [using static] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Keyword;[static]; + MarkupTextLiteral - [13..13)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.cspans.txt new file mode 100644 index 0000000000..c2b5fb0a36 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (1:0,1 [19] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.stree.txt new file mode 100644 index 0000000000..87f25da2f1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/StaticUsing_SingleIdentifier.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..20)::20 - [@using static System] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + RazorDirective - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..20)::19 + CSharpStatementLiteral - [1..20)::19 - [using static System] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Keyword;[static]; + Whitespace;[ ]; + Identifier;[System]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.cspans.txt new file mode 100644 index 0000000000..cdeba78164 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.stree.txt new file mode 100644 index 0000000000..5ccdbf8b7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/SwitchStatement.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..23)::23 - [@switch(foo) { foo(); }] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..23)::22 - [switch(foo) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[switch]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.cspans.txt new file mode 100644 index 0000000000..11cc3bcb68 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Code span at (1:0,1 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.stree.txt new file mode 100644 index 0000000000..9f95d564bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/TryStatement.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..15)::15 - [@try { foo(); }] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..15)::14 - [try { foo(); }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[try]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.cspans.txt new file mode 100644 index 0000000000..e3ee30b682 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [41] ) +Code span at (1:0,1 [40] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [41] ) +Markup span at (41:0,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.stree.txt new file mode 100644 index 0000000000..a3d95afa7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingNamespaceImport.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..41)::41 - [@using System.Text.Encoding.ASCIIEncoding] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + RazorDirective - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..41)::40 + CSharpStatementLiteral - [1..41)::40 - [using System.Text.Encoding.ASCIIEncoding] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupTextLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.cspans.txt new file mode 100644 index 0000000000..6a5ad243c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Code span at (1:0,1 [41] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (42:0,42 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.stree.txt new file mode 100644 index 0000000000..9747414ae4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingStatement.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..42)::42 - [@using(var foo = new Foo()) { foo.Bar(); }] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..42)::41 - [using(var foo = new Foo()) { foo.Bar(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[using]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[new]; + Whitespace;[ ]; + Identifier;[Foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + Dot;[.]; + Identifier;[Bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.cspans.txt new file mode 100644 index 0000000000..cde43d9d9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [79] ) +Code span at (1:0,1 [78] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [79] ) +Markup span at (79:0,79 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [79] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.stree.txt new file mode 100644 index 0000000000..ea46ea988b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/UsingTypeAlias.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..79)::79 - [@using StringDictionary = System.Collections.Generic.Dictionary] + MarkupBlock - [0..79)::79 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..79)::79 + RazorDirective - [0..79)::79 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..79)::78 + CSharpStatementLiteral - [1..79)::78 - [using StringDictionary = System.Collections.Generic.Dictionary] - Gen;> - SpanEditHandler;Accepts:AnyExceptNewline + Keyword;[using]; + Whitespace;[ ]; + Identifier;[StringDictionary]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[System]; + Dot;[.]; + Identifier;[Collections]; + Dot;[.]; + Identifier;[Generic]; + Dot;[.]; + Identifier;[Dictionary]; + LessThan;[<]; + Keyword;[string]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + GreaterThan;[>]; + MarkupTextLiteral - [79..79)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Complex.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Complex.cspans.txt new file mode 100644 index 0000000000..8fd6b20bde --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Complex.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [126] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [126] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [126] ) +Code span at (2:0,2 [123] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [126] ) +MetaCode span at (125:0,125 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [126] ) +Markup span at (126:0,126 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [126] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Complex.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Complex.stree.txt new file mode 100644 index 0000000000..a3eed94cbe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Complex.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..126)::126 - [@{ using Some.Disposable.TypeName foo = GetDisposable(() => { using var bar = otherDisposable; }); }] + MarkupBlock - [0..126)::126 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..126)::126 + CSharpStatement - [0..126)::126 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..126)::125 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..125)::123 + CSharpStatementLiteral - [2..125)::123 - [ using Some.Disposable.TypeName foo = GetDisposable(() => { using var bar = otherDisposable; }); ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[using]; + Whitespace;[ ]; + Identifier;[Some]; + Dot;[.]; + Identifier;[Disposable]; + Dot;[.]; + Identifier;[TypeName]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[GetDisposable]; + LessThan;[<]; + Identifier;[Some]; + Dot;[.]; + Identifier;[Disposable]; + Dot;[.]; + Identifier;[TypeName]; + GreaterThan;[>]; + LeftParenthesis;[(]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Whitespace;[ ]; + GreaterThanEqual;[=>]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Keyword;[using]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[bar]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[otherDisposable]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [125..126)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [126..126)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Simple.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Simple.cspans.txt new file mode 100644 index 0000000000..3b71285c08 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Simple.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Code span at (2:0,2 [33] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (35:0,35 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Simple.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Simple.stree.txt new file mode 100644 index 0000000000..3a8984ebc9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/Using_VariableDeclaration_Simple.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..36)::36 - [@{ using var foo = someDisposable; }] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpStatement - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..36)::35 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..35)::33 + CSharpStatementLiteral - [2..35)::33 - [ using var foo = someDisposable; ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[using]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[someDisposable]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [35..36)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.cspans.txt new file mode 100644 index 0000000000..cdeba78164 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (1:0,1 [22] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.stree.txt new file mode 100644 index 0000000000..4174c105bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpStatementTest/WhileStatement.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..23)::23 - [@while(true) { foo(); }] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..23)::22 - [while(true) { foo(); }] - Gen - SpanEditHandler;Accepts:None + Keyword;[while]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.cspans.txt new file mode 100644 index 0000000000..91eb2c5b1d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [38] ) +Code span at (2:0,2 [16] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [38] ) +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Markup block at (18:0,18 [18] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (19:0,19 [3] ) +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [18] ) +Transition span at (27:0,27 [1] ) (Accepts:None) - Parent: Expression block at (27:0,27 [5] ) +Code span at (28:0,28 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (27:0,27 [5] ) +Markup span at (32:0,32 [4] ) (Accepts:None) - Parent: Tag block at (32:0,32 [4] ) +Code span at (36:0,36 [1] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [38] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [38] ) +Markup span at (38:0,38 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.stree.txt new file mode 100644 index 0000000000..d6482c071f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInExplicitExpressionParens.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..38)::38 - [@(Html.Repeat(10, @

                    Foo #@item

                    ))] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpExplicitExpression - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [2..37)::35 + CSharpExpressionLiteral - [2..18)::16 - [Html.Repeat(10, ] - Gen - SpanEditHandler;Accepts:Any + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [18..36)::18 + MarkupBlock - [18..36)::18 + MarkupTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [19..36)::17 + MarkupStartTag - [19..22)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [22..27)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [27..32)::5 + CSharpImplicitExpression - [27..32)::5 + CSharpTransition - [27..28)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [28..32)::4 + CSharpCodeBlock - [28..32)::4 + CSharpExpressionLiteral - [28..32)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [32..36)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [36..37)::1 - [)] - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[)]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInImplicitExpressionParens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInImplicitExpressionParens.cspans.txt new file mode 100644 index 0000000000..90df13237d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInImplicitExpressionParens.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [36] ) +Code span at (1:0,1 [16] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [36] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (17:0,17 [18] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (21:0,21 [5] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [18] ) +Transition span at (26:0,26 [1] ) (Accepts:None) - Parent: Expression block at (26:0,26 [5] ) +Code span at (27:0,27 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (26:0,26 [5] ) +Markup span at (31:0,31 [4] ) (Accepts:None) - Parent: Tag block at (31:0,31 [4] ) +Code span at (35:0,35 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInImplicitExpressionParens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInImplicitExpressionParens.stree.txt new file mode 100644 index 0000000000..c12bad27f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInImplicitExpressionParens.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..36)::36 - [@Html.Repeat(10, @

                    Foo #@item

                    )] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpImplicitExpression - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..36)::35 + CSharpCodeBlock - [1..36)::35 + CSharpExpressionLiteral - [1..17)::16 - [Html.Repeat(10, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [17..35)::18 + MarkupBlock - [17..35)::18 + MarkupTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [18..35)::17 + MarkupStartTag - [18..21)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..26)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [26..31)::5 + CSharpImplicitExpression - [26..31)::5 + CSharpTransition - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [27..31)::4 + CSharpCodeBlock - [27..31)::4 + CSharpExpressionLiteral - [27..31)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [31..35)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [35..36)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinCodeBlock.cspans.txt new file mode 100644 index 0000000000..185f8e0ad1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinCodeBlock.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [71] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [71] ) +Code span at (1:0,1 [48] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [71] ) +Transition span at (49:0,49 [1] ) (Accepts:None) - Parent: Markup block at (49:0,49 [18] ) +Markup span at (50:0,50 [3] ) (Accepts:None) - Parent: Tag block at (50:0,50 [3] ) +Markup span at (53:0,53 [5] ) (Accepts:Any) - Parent: Markup block at (49:0,49 [18] ) +Transition span at (58:0,58 [1] ) (Accepts:None) - Parent: Expression block at (58:0,58 [5] ) +Code span at (59:0,59 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (58:0,58 [5] ) +Markup span at (63:0,63 [4] ) (Accepts:None) - Parent: Tag block at (63:0,63 [4] ) +Code span at (67:0,67 [4] ) (Accepts:None) - Parent: Statement block at (0:0,0 [71] ) +Markup span at (71:0,71 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [71] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinCodeBlock.stree.txt new file mode 100644 index 0000000000..c5e726c705 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinCodeBlock.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..71)::71 - [@foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

                    Foo #@item

                    ); }] + MarkupBlock - [0..71)::71 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..71)::71 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..49)::48 - [foreach(foo in Bar) { Html.ExecuteTemplate(foo, ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [49..67)::18 + MarkupBlock - [49..67)::18 + MarkupTransition - [49..50)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [50..67)::17 + MarkupStartTag - [50..53)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [53..58)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [58..63)::5 + CSharpImplicitExpression - [58..63)::5 + CSharpTransition - [58..59)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [59..63)::4 + CSharpCodeBlock - [59..63)::4 + CSharpExpressionLiteral - [59..63)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [63..67)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [67..71)::4 - [); }] - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [71..71)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinStatementBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinStatementBlock.cspans.txt new file mode 100644 index 0000000000..f0f818c60c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinStatementBlock.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [66] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [66] ) +Code span at (2:0,2 [42] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [66] ) +Transition span at (44:0,44 [1] ) (Accepts:None) - Parent: Markup block at (44:0,44 [18] ) +Markup span at (45:0,45 [3] ) (Accepts:None) - Parent: Tag block at (45:0,45 [3] ) +Markup span at (48:0,48 [5] ) (Accepts:Any) - Parent: Markup block at (44:0,44 [18] ) +Transition span at (53:0,53 [1] ) (Accepts:None) - Parent: Expression block at (53:0,53 [5] ) +Code span at (54:0,54 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (53:0,53 [5] ) +Markup span at (58:0,58 [4] ) (Accepts:None) - Parent: Tag block at (58:0,58 [4] ) +Code span at (62:0,62 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [66] ) +MetaCode span at (65:0,65 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [66] ) +Markup span at (66:0,66 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinStatementBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinStatementBlock.stree.txt new file mode 100644 index 0000000000..2073b33dd2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSimpleTemplateInStatementWithinStatementBlock.stree.txt @@ -0,0 +1,64 @@ +RazorDocument - [0..66)::66 - [@{ var foo = bar; Html.ExecuteTemplate(foo, @

                    Foo #@item

                    ); }] + MarkupBlock - [0..66)::66 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..66)::66 + CSharpStatement - [0..66)::66 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..66)::65 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..65)::63 + CSharpStatementLiteral - [2..44)::42 - [ var foo = bar; Html.ExecuteTemplate(foo, ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [44..62)::18 + MarkupBlock - [44..62)::18 + MarkupTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [45..62)::17 + MarkupStartTag - [45..48)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [48..53)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [53..58)::5 + CSharpImplicitExpression - [53..58)::5 + CSharpTransition - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [54..58)::4 + CSharpCodeBlock - [54..58)::4 + CSharpExpressionLiteral - [54..58)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [58..62)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [62..65)::3 - [); ] - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [65..66)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [66..66)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineImmediatelyFollowingStatementChar.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineImmediatelyFollowingStatementChar.cspans.txt new file mode 100644 index 0000000000..bd2c061107 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineImmediatelyFollowingStatementChar.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Code span at (2:0,2 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Markup block at (3:0,3 [8] ) +MetaCode span at (4:0,4 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [8] ) +Markup span at (5:0,5 [6] ) (Accepts:None) - Parent: Markup block at (3:0,3 [8] ) +Code span at (11:1,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (11:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Markup span at (12:1,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineImmediatelyFollowingStatementChar.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineImmediatelyFollowingStatementChar.stree.txt new file mode 100644 index 0000000000..6f9495273c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineImmediatelyFollowingStatementChar.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..12)::12 - [@{i@: barLF}] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + CSharpStatement - [0..12)::12 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..12)::11 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..11)::9 + CSharpStatementLiteral - [2..3)::1 - [i] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Identifier;[i]; + CSharpTemplateBlock - [3..11)::8 + MarkupBlock - [3..11)::8 + MarkupTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [4..5)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [5..11)::6 - [ barLF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[bar]; + NewLine;[LF]; + CSharpStatementLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [12..12)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineTemplate.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineTemplate.cspans.txt new file mode 100644 index 0000000000..5c5175b1b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineTemplate.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Code span at (2:0,2 [11] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (13:0,13 [8] ) +MetaCode span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [8] ) +Markup span at (15:0,15 [6] ) (Accepts:None) - Parent: Markup block at (13:0,13 [8] ) +Code span at (21:1,0 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (23:1,2 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (24:1,3 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineTemplate.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineTemplate.stree.txt new file mode 100644 index 0000000000..986b3afba4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesSingleLineTemplate.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..24)::24 - [@{ var foo = @: barLF; }] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + CSharpStatementLiteral - [2..13)::11 - [ var foo = ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + CSharpTemplateBlock - [13..21)::8 + MarkupBlock - [13..21)::8 + MarkupTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [15..21)::6 - [ barLF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[bar]; + NewLine;[LF]; + CSharpStatementLiteral - [21..23)::2 - [; ] - Gen - SpanEditHandler;Accepts:Any + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInImplicitExpressionParens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInImplicitExpressionParens.cspans.txt new file mode 100644 index 0000000000..f16349c57b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInImplicitExpressionParens.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [56] ) +Code span at (1:0,1 [16] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [56] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (17:0,17 [18] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (21:0,21 [5] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [18] ) +Transition span at (26:0,26 [1] ) (Accepts:None) - Parent: Expression block at (26:0,26 [5] ) +Code span at (27:0,27 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (26:0,26 [5] ) +Markup span at (31:0,31 [4] ) (Accepts:None) - Parent: Tag block at (31:0,31 [4] ) +Code span at (35:0,35 [2] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [56] ) +Transition span at (37:0,37 [1] ) (Accepts:None) - Parent: Markup block at (37:0,37 [18] ) +Markup span at (38:0,38 [3] ) (Accepts:None) - Parent: Tag block at (38:0,38 [3] ) +Markup span at (41:0,41 [5] ) (Accepts:Any) - Parent: Markup block at (37:0,37 [18] ) +Transition span at (46:0,46 [1] ) (Accepts:None) - Parent: Expression block at (46:0,46 [5] ) +Code span at (47:0,47 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (46:0,46 [5] ) +Markup span at (51:0,51 [4] ) (Accepts:None) - Parent: Tag block at (51:0,51 [4] ) +Code span at (55:0,55 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [56] ) +Markup span at (56:0,56 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInImplicitExpressionParens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInImplicitExpressionParens.stree.txt new file mode 100644 index 0000000000..a14beedeab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInImplicitExpressionParens.stree.txt @@ -0,0 +1,77 @@ +RazorDocument - [0..56)::56 - [@Html.Repeat(10, @

                    Foo #@item

                    , @

                    Foo #@item

                    )] + MarkupBlock - [0..56)::56 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..56)::56 + CSharpImplicitExpression - [0..56)::56 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..56)::55 + CSharpCodeBlock - [1..56)::55 + CSharpExpressionLiteral - [1..17)::16 - [Html.Repeat(10, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [17..35)::18 + MarkupBlock - [17..35)::18 + MarkupTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [18..35)::17 + MarkupStartTag - [18..21)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..26)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [26..31)::5 + CSharpImplicitExpression - [26..31)::5 + CSharpTransition - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [27..31)::4 + CSharpCodeBlock - [27..31)::4 + CSharpExpressionLiteral - [27..31)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [31..35)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [35..37)::2 - [, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [37..55)::18 + MarkupBlock - [37..55)::18 + MarkupTransition - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [38..55)::17 + MarkupStartTag - [38..41)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [41..46)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [46..51)::5 + CSharpImplicitExpression - [46..51)::5 + CSharpTransition - [46..47)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [47..51)::4 + CSharpCodeBlock - [47..51)::4 + CSharpExpressionLiteral - [47..51)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [51..55)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [55..56)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupTextLiteral - [56..56)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInStatementWithinCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInStatementWithinCodeBlock.cspans.txt new file mode 100644 index 0000000000..995931257d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInStatementWithinCodeBlock.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [91] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [91] ) +Code span at (1:0,1 [48] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [91] ) +Transition span at (49:0,49 [1] ) (Accepts:None) - Parent: Markup block at (49:0,49 [18] ) +Markup span at (50:0,50 [3] ) (Accepts:None) - Parent: Tag block at (50:0,50 [3] ) +Markup span at (53:0,53 [5] ) (Accepts:Any) - Parent: Markup block at (49:0,49 [18] ) +Transition span at (58:0,58 [1] ) (Accepts:None) - Parent: Expression block at (58:0,58 [5] ) +Code span at (59:0,59 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (58:0,58 [5] ) +Markup span at (63:0,63 [4] ) (Accepts:None) - Parent: Tag block at (63:0,63 [4] ) +Code span at (67:0,67 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [91] ) +Transition span at (69:0,69 [1] ) (Accepts:None) - Parent: Markup block at (69:0,69 [18] ) +Markup span at (70:0,70 [3] ) (Accepts:None) - Parent: Tag block at (70:0,70 [3] ) +Markup span at (73:0,73 [5] ) (Accepts:Any) - Parent: Markup block at (69:0,69 [18] ) +Transition span at (78:0,78 [1] ) (Accepts:None) - Parent: Expression block at (78:0,78 [5] ) +Code span at (79:0,79 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (78:0,78 [5] ) +Markup span at (83:0,83 [4] ) (Accepts:None) - Parent: Tag block at (83:0,83 [4] ) +Code span at (87:0,87 [4] ) (Accepts:None) - Parent: Statement block at (0:0,0 [91] ) +Markup span at (91:0,91 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [91] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInStatementWithinCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInStatementWithinCodeBlock.stree.txt new file mode 100644 index 0000000000..e304e697ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlesTwoTemplatesInStatementWithinCodeBlock.stree.txt @@ -0,0 +1,88 @@ +RazorDocument - [0..91)::91 - [@foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

                    Foo #@item

                    , @

                    Foo #@item

                    ); }] + MarkupBlock - [0..91)::91 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..91)::91 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..49)::48 - [foreach(foo in Bar) { Html.ExecuteTemplate(foo, ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [49..67)::18 + MarkupBlock - [49..67)::18 + MarkupTransition - [49..50)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [50..67)::17 + MarkupStartTag - [50..53)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [53..58)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [58..63)::5 + CSharpImplicitExpression - [58..63)::5 + CSharpTransition - [58..59)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [59..63)::4 + CSharpCodeBlock - [59..63)::4 + CSharpExpressionLiteral - [59..63)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [63..67)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [67..69)::2 - [, ] - Gen - SpanEditHandler;Accepts:Any + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [69..87)::18 + MarkupBlock - [69..87)::18 + MarkupTransition - [69..70)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [70..87)::17 + MarkupStartTag - [70..73)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [73..78)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [78..83)::5 + CSharpImplicitExpression - [78..83)::5 + CSharpTransition - [78..79)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [79..83)::4 + CSharpCodeBlock - [79..83)::4 + CSharpExpressionLiteral - [79..83)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [83..87)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [87..91)::4 - [); }] - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [91..91)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlessTwoTemplatesInStatementWithinStatementBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlessTwoTemplatesInStatementWithinStatementBlock.cspans.txt new file mode 100644 index 0000000000..217bee2ec1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlessTwoTemplatesInStatementWithinStatementBlock.cspans.txt @@ -0,0 +1,20 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [86] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [86] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [86] ) +Code span at (2:0,2 [42] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [86] ) +Transition span at (44:0,44 [1] ) (Accepts:None) - Parent: Markup block at (44:0,44 [18] ) +Markup span at (45:0,45 [3] ) (Accepts:None) - Parent: Tag block at (45:0,45 [3] ) +Markup span at (48:0,48 [5] ) (Accepts:Any) - Parent: Markup block at (44:0,44 [18] ) +Transition span at (53:0,53 [1] ) (Accepts:None) - Parent: Expression block at (53:0,53 [5] ) +Code span at (54:0,54 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (53:0,53 [5] ) +Markup span at (58:0,58 [4] ) (Accepts:None) - Parent: Tag block at (58:0,58 [4] ) +Code span at (62:0,62 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [86] ) +Transition span at (64:0,64 [1] ) (Accepts:None) - Parent: Markup block at (64:0,64 [18] ) +Markup span at (65:0,65 [3] ) (Accepts:None) - Parent: Tag block at (65:0,65 [3] ) +Markup span at (68:0,68 [5] ) (Accepts:Any) - Parent: Markup block at (64:0,64 [18] ) +Transition span at (73:0,73 [1] ) (Accepts:None) - Parent: Expression block at (73:0,73 [5] ) +Code span at (74:0,74 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (73:0,73 [5] ) +Markup span at (78:0,78 [4] ) (Accepts:None) - Parent: Tag block at (78:0,78 [4] ) +Code span at (82:0,82 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [86] ) +MetaCode span at (85:0,85 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [86] ) +Markup span at (86:0,86 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [86] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlessTwoTemplatesInStatementWithinStatementBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlessTwoTemplatesInStatementWithinStatementBlock.stree.txt new file mode 100644 index 0000000000..3d0ccca4b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/HandlessTwoTemplatesInStatementWithinStatementBlock.stree.txt @@ -0,0 +1,93 @@ +RazorDocument - [0..86)::86 - [@{ var foo = bar; Html.ExecuteTemplate(foo, @

                    Foo #@item

                    , @

                    Foo #@item

                    ); }] + MarkupBlock - [0..86)::86 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..86)::86 + CSharpStatement - [0..86)::86 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..86)::85 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..85)::83 + CSharpStatementLiteral - [2..44)::42 - [ var foo = bar; Html.ExecuteTemplate(foo, ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [44..62)::18 + MarkupBlock - [44..62)::18 + MarkupTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [45..62)::17 + MarkupStartTag - [45..48)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [48..53)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [53..58)::5 + CSharpImplicitExpression - [53..58)::5 + CSharpTransition - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [54..58)::4 + CSharpCodeBlock - [54..58)::4 + CSharpExpressionLiteral - [54..58)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [58..62)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [62..64)::2 - [, ] - Gen - SpanEditHandler;Accepts:Any + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [64..82)::18 + MarkupBlock - [64..82)::18 + MarkupTransition - [64..65)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [65..82)::17 + MarkupStartTag - [65..68)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [68..73)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [73..78)::5 + CSharpImplicitExpression - [73..78)::5 + CSharpTransition - [73..74)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [74..78)::4 + CSharpCodeBlock - [74..78)::4 + CSharpExpressionLiteral - [74..78)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [78..82)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [82..85)::3 - [); ] - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [85..86)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [86..86)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.cspans.txt new file mode 100644 index 0000000000..c926c0bb0d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [62] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [62] ) +Code span at (1:0,1 [16] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [62] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (17:0,17 [44] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (21:0,21 [5] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [44] ) +Transition span at (26:0,26 [1] ) (Accepts:None) - Parent: Expression block at (26:0,26 [31] ) +Code span at (27:0,27 [16] ) (Accepts:Any) - Parent: Expression block at (26:0,26 [31] ) +Transition span at (43:0,43 [1] ) (Accepts:None) - Parent: Markup block at (43:0,43 [13] ) +Markup span at (44:0,44 [3] ) (Accepts:None) - Parent: Tag block at (44:0,44 [3] ) +Markup span at (47:0,47 [0] ) (Accepts:Any) - Parent: Markup block at (43:0,43 [13] ) +Transition span at (47:0,47 [1] ) (Accepts:None) - Parent: Expression block at (47:0,47 [5] ) +Code span at (48:0,48 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (47:0,47 [5] ) +Markup span at (52:0,52 [4] ) (Accepts:None) - Parent: Tag block at (52:0,52 [4] ) +Code span at (56:0,56 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (26:0,26 [31] ) +Markup span at (57:0,57 [4] ) (Accepts:None) - Parent: Tag block at (57:0,57 [4] ) +Code span at (61:0,61 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [62] ) +Markup span at (62:0,62 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [62] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.diag.txt new file mode 100644 index 0000000000..f634e63ad3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.diag.txt @@ -0,0 +1 @@ +(1,44): Error RZ2003: Inline markup blocks (@

                    Content

                    ) cannot be nested. Only one level of inline markup is allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.stree.txt new file mode 100644 index 0000000000..df8ed3f5c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens.stree.txt @@ -0,0 +1,80 @@ +RazorDocument - [0..62)::62 - [@Html.Repeat(10, @

                    Foo #@Html.Repeat(10, @

                    @item

                    )

                    )] + MarkupBlock - [0..62)::62 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..62)::62 + CSharpImplicitExpression - [0..62)::62 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..62)::61 + CSharpCodeBlock - [1..62)::61 + CSharpExpressionLiteral - [1..17)::16 - [Html.Repeat(10, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [17..61)::44 + MarkupBlock - [17..61)::44 + MarkupTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [18..61)::43 + MarkupStartTag - [18..21)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..26)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [26..57)::31 + CSharpImplicitExpression - [26..57)::31 + CSharpTransition - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [27..57)::30 + CSharpCodeBlock - [27..57)::30 + CSharpExpressionLiteral - [27..43)::16 - [Html.Repeat(10, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [43..56)::13 + MarkupBlock - [43..56)::13 + MarkupTransition - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [44..56)::12 + MarkupStartTag - [44..47)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [47..52)::5 + CSharpImplicitExpression - [47..52)::5 + CSharpTransition - [47..48)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [48..52)::4 + CSharpCodeBlock - [48..52)::4 + CSharpExpressionLiteral - [48..52)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [52..56)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [56..57)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupEndTag - [57..61)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [61..62)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupTextLiteral - [62..62)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.cspans.txt new file mode 100644 index 0000000000..338b4bec5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [97] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [97] ) +Code span at (1:0,1 [48] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [97] ) +Transition span at (49:0,49 [1] ) (Accepts:None) - Parent: Markup block at (49:0,49 [44] ) +Markup span at (50:0,50 [3] ) (Accepts:None) - Parent: Tag block at (50:0,50 [3] ) +Markup span at (53:0,53 [5] ) (Accepts:Any) - Parent: Markup block at (49:0,49 [44] ) +Transition span at (58:0,58 [1] ) (Accepts:None) - Parent: Expression block at (58:0,58 [31] ) +Code span at (59:0,59 [16] ) (Accepts:Any) - Parent: Expression block at (58:0,58 [31] ) +Transition span at (75:0,75 [1] ) (Accepts:None) - Parent: Markup block at (75:0,75 [13] ) +Markup span at (76:0,76 [3] ) (Accepts:None) - Parent: Tag block at (76:0,76 [3] ) +Markup span at (79:0,79 [0] ) (Accepts:Any) - Parent: Markup block at (75:0,75 [13] ) +Transition span at (79:0,79 [1] ) (Accepts:None) - Parent: Expression block at (79:0,79 [5] ) +Code span at (80:0,80 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (79:0,79 [5] ) +Markup span at (84:0,84 [4] ) (Accepts:None) - Parent: Tag block at (84:0,84 [4] ) +Code span at (88:0,88 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (58:0,58 [31] ) +Markup span at (89:0,89 [4] ) (Accepts:None) - Parent: Tag block at (89:0,89 [4] ) +Code span at (93:0,93 [4] ) (Accepts:None) - Parent: Statement block at (0:0,0 [97] ) +Markup span at (97:0,97 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [97] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.diag.txt new file mode 100644 index 0000000000..2f60746b35 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.diag.txt @@ -0,0 +1 @@ +(1,76): Error RZ2003: Inline markup blocks (@

                    Content

                    ) cannot be nested. Only one level of inline markup is allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.stree.txt new file mode 100644 index 0000000000..f55be998e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock.stree.txt @@ -0,0 +1,91 @@ +RazorDocument - [0..97)::97 - [@foreach(foo in Bar) { Html.ExecuteTemplate(foo, @

                    Foo #@Html.Repeat(10, @

                    @item

                    )

                    ); }] + MarkupBlock - [0..97)::97 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..97)::97 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..49)::48 - [foreach(foo in Bar) { Html.ExecuteTemplate(foo, ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[foo]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [49..93)::44 + MarkupBlock - [49..93)::44 + MarkupTransition - [49..50)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [50..93)::43 + MarkupStartTag - [50..53)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [53..58)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [58..89)::31 + CSharpImplicitExpression - [58..89)::31 + CSharpTransition - [58..59)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [59..89)::30 + CSharpCodeBlock - [59..89)::30 + CSharpExpressionLiteral - [59..75)::16 - [Html.Repeat(10, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [75..88)::13 + MarkupBlock - [75..88)::13 + MarkupTransition - [75..76)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [76..88)::12 + MarkupStartTag - [76..79)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [79..79)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [79..84)::5 + CSharpImplicitExpression - [79..84)::5 + CSharpTransition - [79..80)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [80..84)::4 + CSharpCodeBlock - [80..84)::4 + CSharpExpressionLiteral - [80..84)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [84..88)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [88..89)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupEndTag - [89..93)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [93..97)::4 - [); }] - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [97..97)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.cspans.txt new file mode 100644 index 0000000000..5ab2d1d144 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.cspans.txt @@ -0,0 +1,20 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [92] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [92] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [92] ) +Code span at (2:0,2 [42] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [92] ) +Transition span at (44:0,44 [1] ) (Accepts:None) - Parent: Markup block at (44:0,44 [44] ) +Markup span at (45:0,45 [3] ) (Accepts:None) - Parent: Tag block at (45:0,45 [3] ) +Markup span at (48:0,48 [5] ) (Accepts:Any) - Parent: Markup block at (44:0,44 [44] ) +Transition span at (53:0,53 [1] ) (Accepts:None) - Parent: Expression block at (53:0,53 [31] ) +Code span at (54:0,54 [16] ) (Accepts:Any) - Parent: Expression block at (53:0,53 [31] ) +Transition span at (70:0,70 [1] ) (Accepts:None) - Parent: Markup block at (70:0,70 [13] ) +Markup span at (71:0,71 [3] ) (Accepts:None) - Parent: Tag block at (71:0,71 [3] ) +Markup span at (74:0,74 [0] ) (Accepts:Any) - Parent: Markup block at (70:0,70 [13] ) +Transition span at (74:0,74 [1] ) (Accepts:None) - Parent: Expression block at (74:0,74 [5] ) +Code span at (75:0,75 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (74:0,74 [5] ) +Markup span at (79:0,79 [4] ) (Accepts:None) - Parent: Tag block at (79:0,79 [4] ) +Code span at (83:0,83 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (53:0,53 [31] ) +Markup span at (84:0,84 [4] ) (Accepts:None) - Parent: Tag block at (84:0,84 [4] ) +Code span at (88:0,88 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [92] ) +MetaCode span at (91:0,91 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [92] ) +Markup span at (92:0,92 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [92] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.diag.txt new file mode 100644 index 0000000000..94b69b6efc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.diag.txt @@ -0,0 +1 @@ +(1,71): Error RZ2003: Inline markup blocks (@

                    Content

                    ) cannot be nested. Only one level of inline markup is allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.stree.txt new file mode 100644 index 0000000000..23a9e76520 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock.stree.txt @@ -0,0 +1,96 @@ +RazorDocument - [0..92)::92 - [@{ var foo = bar; Html.ExecuteTemplate(foo, @

                    Foo #@Html.Repeat(10, @

                    @item

                    )

                    ); }] + MarkupBlock - [0..92)::92 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..92)::92 + CSharpStatement - [0..92)::92 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..92)::91 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..91)::89 + CSharpStatementLiteral - [2..44)::42 - [ var foo = bar; Html.ExecuteTemplate(foo, ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [44..88)::44 + MarkupBlock - [44..88)::44 + MarkupTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [45..88)::43 + MarkupStartTag - [45..48)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [48..53)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [53..84)::31 + CSharpImplicitExpression - [53..84)::31 + CSharpTransition - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [54..84)::30 + CSharpCodeBlock - [54..84)::30 + CSharpExpressionLiteral - [54..70)::16 - [Html.Repeat(10, ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Html]; + Dot;[.]; + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [70..83)::13 + MarkupBlock - [70..83)::13 + MarkupTransition - [70..71)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [71..83)::12 + MarkupStartTag - [71..74)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [74..74)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [74..79)::5 + CSharpImplicitExpression - [74..79)::5 + CSharpTransition - [74..75)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [75..79)::4 + CSharpCodeBlock - [75..79)::4 + CSharpExpressionLiteral - [75..79)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [79..83)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [83..84)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupEndTag - [84..88)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [88..91)::3 - [); ] - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [91..92)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [92..92)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/_WithDoubleTransition_DoesNotThrow.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/_WithDoubleTransition_DoesNotThrow.cspans.txt new file mode 100644 index 0000000000..ccfd591f1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/_WithDoubleTransition_DoesNotThrow.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [75] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) +Code span at (2:0,2 [42] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +Transition span at (44:0,44 [1] ) (Accepts:None) - Parent: Markup block at (44:0,44 [27] ) +Markup span at (45:0,45 [2] ) (Accepts:Any) - Parent: Tag block at (45:0,45 [12] ) +Markup span at (47:0,47 [6] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [9] ) +Markup span at (53:0,53 [1] ) (Accepts:None) - Parent: Markup block at (53:0,53 [2] ) +Markup span at (54:0,54 [1] ) (Accepts:None) - Parent: Markup block at (53:0,53 [2] ) +Markup span at (55:0,55 [1] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [9] ) +Markup span at (56:0,56 [1] ) (Accepts:None) - Parent: Tag block at (45:0,45 [12] ) +Markup span at (57:0,57 [5] ) (Accepts:Any) - Parent: Markup block at (44:0,44 [27] ) +Transition span at (62:0,62 [1] ) (Accepts:None) - Parent: Expression block at (62:0,62 [5] ) +Code span at (63:0,63 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (62:0,62 [5] ) +Markup span at (67:0,67 [4] ) (Accepts:None) - Parent: Tag block at (67:0,67 [4] ) +Code span at (71:0,71 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (74:0,74 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (75:0,75 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [75] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/_WithDoubleTransition_DoesNotThrow.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/_WithDoubleTransition_DoesNotThrow.stree.txt new file mode 100644 index 0000000000..bbd0281f2f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpTemplateTest/_WithDoubleTransition_DoesNotThrow.stree.txt @@ -0,0 +1,80 @@ +RazorDocument - [0..75)::75 - [@{ var foo = bar; Html.ExecuteTemplate(foo, @

                    Foo #@item

                    ); }] + MarkupBlock - [0..75)::75 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..75)::75 + CSharpStatement - [0..75)::75 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..75)::74 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..74)::72 + CSharpStatementLiteral - [2..44)::42 - [ var foo = bar; Html.ExecuteTemplate(foo, ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[Html]; + Dot;[.]; + Identifier;[ExecuteTemplate]; + LeftParenthesis;[(]; + Identifier;[foo]; + Comma;[,]; + Whitespace;[ ]; + CSharpTemplateBlock - [44..71)::27 + MarkupBlock - [44..71)::27 + MarkupTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [45..71)::26 + MarkupStartTag - [45..57)::12 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupAttributeBlock - [47..56)::9 - [ foo='@@'] + MarkupTextLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [48..51)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Equals;[=]; + MarkupTextLiteral - [52..53)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [53..55)::2 + MarkupBlock - [53..55)::2 + MarkupTextLiteral - [53..54)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [54..55)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [55..56)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [57..62)::5 - [Foo #] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[#]; + CSharpCodeBlock - [62..67)::5 + CSharpImplicitExpression - [62..67)::5 + CSharpTransition - [62..63)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [63..67)::4 + CSharpCodeBlock - [63..67)::4 + CSharpExpressionLiteral - [63..67)::4 - [item] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[item]; + MarkupEndTag - [67..71)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [71..74)::3 - [); ] - Gen - SpanEditHandler;Accepts:Any + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [74..75)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [75..75)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBraces.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBraces.cspans.txt new file mode 100644 index 0000000000..ba8948b5ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBraces.cspans.txt @@ -0,0 +1,22 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [71] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [71] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [71] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:None) - Parent: Tag block at (11:0,11 [3] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [12] ) +Markup span at (17:0,17 [4] ) (Accepts:None) - Parent: Tag block at (17:0,17 [4] ) +Markup span at (21:0,21 [1] ) (Accepts:None) - Parent: Markup block at (10:0,10 [12] ) +Code span at (22:0,22 [16] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [71] ) +Markup span at (38:0,38 [1] ) (Accepts:Any) - Parent: Markup block at (38:0,38 [12] ) +Markup span at (39:0,39 [3] ) (Accepts:None) - Parent: Tag block at (39:0,39 [3] ) +Markup span at (42:0,42 [3] ) (Accepts:Any) - Parent: Markup block at (38:0,38 [12] ) +Markup span at (45:0,45 [4] ) (Accepts:None) - Parent: Tag block at (45:0,45 [4] ) +Markup span at (49:0,49 [1] ) (Accepts:None) - Parent: Markup block at (38:0,38 [12] ) +Code span at (50:0,50 [8] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [71] ) +Markup span at (58:0,58 [1] ) (Accepts:Any) - Parent: Markup block at (58:0,58 [12] ) +Markup span at (59:0,59 [3] ) (Accepts:None) - Parent: Tag block at (59:0,59 [3] ) +Markup span at (62:0,62 [3] ) (Accepts:Any) - Parent: Markup block at (58:0,58 [12] ) +Markup span at (65:0,65 [4] ) (Accepts:None) - Parent: Tag block at (65:0,65 [4] ) +Markup span at (69:0,69 [1] ) (Accepts:None) - Parent: Markup block at (58:0,58 [12] ) +Code span at (70:0,70 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [71] ) +Markup span at (71:0,71 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [71] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBraces.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBraces.stree.txt new file mode 100644 index 0000000000..c13cff2566 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBraces.stree.txt @@ -0,0 +1,86 @@ +RazorDocument - [0..71)::71 - [@if(foo) {

                    Bar

                    } else if(bar) {

                    Baz

                    } else {

                    Boz

                    }] + MarkupBlock - [0..71)::71 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..71)::71 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..10)::9 - [if(foo) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [10..22)::12 + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [11..21)::10 + MarkupStartTag - [11..14)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [14..17)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [17..21)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [22..38)::16 - [} else if(bar) {] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [38..50)::12 + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [39..49)::10 + MarkupStartTag - [39..42)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [42..45)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupEndTag - [45..49)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [49..50)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [50..58)::8 - [} else {] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [58..70)::12 + MarkupTextLiteral - [58..59)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [59..69)::10 + MarkupStartTag - [59..62)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [62..65)::3 - [Boz] - Gen - SpanEditHandler;Accepts:Any + Text;[Boz]; + MarkupEndTag - [65..69)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [69..70)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [70..71)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [71..71)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBracesWithinCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBracesWithinCodeBlock.cspans.txt new file mode 100644 index 0000000000..adb029e02e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBracesWithinCodeBlock.cspans.txt @@ -0,0 +1,24 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [75] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) +Code span at (2:0,2 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:None) - Parent: Tag block at (13:0,13 [3] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [12] ) +Markup span at (19:0,19 [4] ) (Accepts:None) - Parent: Tag block at (19:0,19 [4] ) +Markup span at (23:0,23 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [12] ) +Code span at (24:0,24 [16] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (40:0,40 [12] ) +Markup span at (41:0,41 [3] ) (Accepts:None) - Parent: Tag block at (41:0,41 [3] ) +Markup span at (44:0,44 [3] ) (Accepts:Any) - Parent: Markup block at (40:0,40 [12] ) +Markup span at (47:0,47 [4] ) (Accepts:None) - Parent: Tag block at (47:0,47 [4] ) +Markup span at (51:0,51 [1] ) (Accepts:None) - Parent: Markup block at (40:0,40 [12] ) +Code span at (52:0,52 [8] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (60:0,60 [1] ) (Accepts:Any) - Parent: Markup block at (60:0,60 [12] ) +Markup span at (61:0,61 [3] ) (Accepts:None) - Parent: Tag block at (61:0,61 [3] ) +Markup span at (64:0,64 [3] ) (Accepts:Any) - Parent: Markup block at (60:0,60 [12] ) +Markup span at (67:0,67 [4] ) (Accepts:None) - Parent: Tag block at (67:0,67 [4] ) +Markup span at (71:0,71 [1] ) (Accepts:None) - Parent: Markup block at (60:0,60 [12] ) +Code span at (72:0,72 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (74:0,74 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (75:0,75 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [75] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBracesWithinCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBracesWithinCodeBlock.stree.txt new file mode 100644 index 0000000000..8caaea2097 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/AllowsMarkupInIfBodyWithBracesWithinCodeBlock.stree.txt @@ -0,0 +1,95 @@ +RazorDocument - [0..75)::75 - [@{ if(foo) {

                    Bar

                    } else if(bar) {

                    Baz

                    } else {

                    Boz

                    } }] + MarkupBlock - [0..75)::75 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..75)::75 + CSharpStatement - [0..75)::75 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..75)::74 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..74)::72 + CSharpStatementLiteral - [2..12)::10 - [ if(foo) {] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [12..24)::12 + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [13..23)::10 + MarkupStartTag - [13..16)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [16..19)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [19..23)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [24..40)::16 - [} else if(bar) {] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[bar]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [40..52)::12 + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [41..51)::10 + MarkupStartTag - [41..44)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [44..47)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupEndTag - [47..51)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [52..60)::8 - [} else {] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[else]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [60..72)::12 + MarkupTextLiteral - [60..61)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [61..71)::10 + MarkupStartTag - [61..64)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [64..67)::3 - [Boz] - Gen - SpanEditHandler;Accepts:Any + Text;[Boz]; + MarkupEndTag - [67..71)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [71..72)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [72..74)::2 - [} ] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [74..75)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [75..75)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTag.cspans.txt new file mode 100644 index 0000000000..b996780bfc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTag.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Code span at (1:0,1 [13] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) +Transition span at (14:0,14 [6] ) (Accepts:None) - Parent: Tag block at (14:0,14 [6] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [14] ) +Transition span at (21:0,21 [7] ) (Accepts:None) - Parent: Tag block at (21:0,21 [7] ) +Code span at (28:0,28 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTag.stree.txt new file mode 100644 index 0000000000..bf3516ae2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTag.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..30)::30 - [@if (i > 0) { ; }] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..14)::13 - [if (i > 0) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[i]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + MarkupBlock - [14..28)::14 + MarkupElement - [14..28)::14 + MarkupStartTag - [14..20)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [20..21)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; + MarkupEndTag - [21..28)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [28..30)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock.cspans.txt new file mode 100644 index 0000000000..2c37a80334 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Code span at (2:0,2 [14] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +Transition span at (16:0,16 [6] ) (Accepts:None) - Parent: Tag block at (16:0,16 [6] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [14] ) +Transition span at (23:0,23 [7] ) (Accepts:None) - Parent: Tag block at (23:0,23 [7] ) +Code span at (30:0,30 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock.stree.txt new file mode 100644 index 0000000000..980017555f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..34)::34 - [@{ if (i > 0) { ; } }] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + CSharpStatementLiteral - [2..16)::14 - [ if (i > 0) { ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[i]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + IntegerLiteral;[0]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + MarkupBlock - [16..30)::14 + MarkupElement - [16..30)::14 + MarkupStartTag - [16..22)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [22..23)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; + MarkupEndTag - [23..30)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [30..33)::3 - [ } ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline.cspans.txt new file mode 100644 index 0000000000..8ce52132ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [162] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [162] ) +Code span at (1:0,1 [80] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [162] ) +Markup span at (81:2,0 [4] ) (Accepts:Any) - Parent: Markup block at (81:2,0 [46] ) +Markup span at (85:2,4 [3] ) (Accepts:None) - Parent: Tag block at (85:2,4 [3] ) +Markup span at (88:2,7 [15] ) (Accepts:Any) - Parent: Markup block at (81:2,0 [46] ) +Code span at (103:4,0 [8] ) (Accepts:Any) - Parent: Statement block at (103:4,0 [12] ) +Transition span at (111:4,8 [1] ) (Accepts:None) - Parent: Expression block at (111:4,8 [4] ) +Code span at (112:4,9 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (111:4,8 [4] ) +Markup span at (115:4,12 [6] ) (Accepts:Any) - Parent: Markup block at (81:2,0 [46] ) +Markup span at (121:5,4 [4] ) (Accepts:None) - Parent: Tag block at (121:5,4 [4] ) +Markup span at (125:5,8 [2] ) (Accepts:None) - Parent: Markup block at (81:2,0 [46] ) +Markup span at (127:6,0 [4] ) (Accepts:Any) - Parent: Markup block at (127:6,0 [14] ) +Transition span at (131:6,4 [1] ) (Accepts:None) - Parent: Markup block at (127:6,0 [14] ) +MetaCode span at (132:6,5 [1] ) (Accepts:Any) - Parent: Markup block at (127:6,0 [14] ) +Markup span at (133:6,6 [8] ) (Accepts:None) - Parent: Markup block at (127:6,0 [14] ) +Code span at (141:7,0 [21] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [162] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline.stree.txt new file mode 100644 index 0000000000..f9c1f89c55 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline.stree.txt @@ -0,0 +1,82 @@ +RazorDocument - [0..162)::162 - [@if(foo) {LF var foo = "After this statement there are 10 spaces"; LF

                    LF FooLF @barLF

                    LF @:Hello!LF var biz = boz;LF}] + MarkupBlock - [0..162)::162 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..162)::162 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..81)::80 - [if(foo) {LF var foo = "After this statement there are 10 spaces"; LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["After this statement there are 10 spaces"]; + Semicolon;[;]; + Whitespace;[ ]; + NewLine;[LF]; + MarkupBlock - [81..127)::46 + MarkupTextLiteral - [81..85)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [85..125)::40 + MarkupStartTag - [85..88)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [88..103)::15 - [LF FooLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Foo]; + NewLine;[LF]; + CSharpCodeBlock - [103..115)::12 + CSharpStatementLiteral - [103..111)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpImplicitExpression - [111..115)::4 + CSharpTransition - [111..112)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [112..115)::3 + CSharpCodeBlock - [112..115)::3 + CSharpExpressionLiteral - [112..115)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [115..121)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupEndTag - [121..125)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [125..127)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [127..141)::14 + MarkupTextLiteral - [127..131)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [131..132)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [132..133)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [133..141)::8 - [Hello!LF] - Gen - SpanEditHandler;Accepts:None + Text;[Hello]; + Bang;[!]; + NewLine;[LF]; + CSharpStatementLiteral - [141..162)::21 - [ var biz = boz;LF}] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[biz]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[boz]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode.cspans.txt new file mode 100644 index 0000000000..f1fa226b75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [30] ) +Code span at (1:0,1 [10] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [30] ) +Transition span at (11:1,0 [1] ) (Accepts:None) - Parent: Markup block at (11:1,0 [18] ) +MetaCode span at (12:1,1 [1] ) (Accepts:Any) - Parent: Markup block at (11:1,0 [18] ) +Markup span at (13:1,2 [16] ) (Accepts:None) - Parent: Markup block at (11:1,0 [18] ) +Code span at (29:2,0 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [30] ) +Markup span at (30:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode.stree.txt new file mode 100644 index 0000000000..4e046e53ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..30)::30 - [@Foo( LF@:

                    Foo

                    LF)] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpImplicitExpression - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..30)::29 + CSharpCodeBlock - [1..30)::29 + CSharpExpressionLiteral - [1..11)::10 - [Foo( LF] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + LeftParenthesis;[(]; + Whitespace;[ ]; + NewLine;[LF]; + CSharpTemplateBlock - [11..29)::18 + MarkupBlock - [11..29)::18 + MarkupTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [13..29)::16 - [

                    Foo

                    LF] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + Text;[Foo]; + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + Whitespace;[ ]; + NewLine;[LF]; + CSharpExpressionLiteral - [29..30)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode.cspans.txt new file mode 100644 index 0000000000..1bd9c8867a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +Transition span at (8:1,4 [1] ) (Accepts:None) - Parent: Markup block at (8:1,4 [18] ) +MetaCode span at (9:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [18] ) +Markup span at (10:1,6 [16] ) (Accepts:None) - Parent: Markup block at (8:1,4 [18] ) +Code span at (26:2,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode.stree.txt new file mode 100644 index 0000000000..ec8316ecf8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..27)::27 - [@{LF @:

                    Foo

                    LF}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [8..26)::18 + MarkupTransition - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [10..26)::16 - [

                    Foo

                    LF] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + Text;[Foo]; + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + Whitespace;[ ]; + NewLine;[LF]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode.cspans.txt new file mode 100644 index 0000000000..a687eaf720 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [25] ) +Code span at (1:0,1 [8] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [25] ) +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Markup block at (9:0,9 [11] ) +Markup span at (10:0,10 [3] ) (Accepts:None) - Parent: Tag block at (10:0,10 [3] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (9:0,9 [11] ) +Markup span at (16:0,16 [4] ) (Accepts:None) - Parent: Tag block at (16:0,16 [4] ) +Code span at (20:0,20 [5] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode.stree.txt new file mode 100644 index 0000000000..b271586561 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..25)::25 - [@Foo( @

                    Foo

                    )] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpImplicitExpression - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..25)::24 + CSharpCodeBlock - [1..25)::24 + CSharpExpressionLiteral - [1..9)::8 - [Foo( ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + LeftParenthesis;[(]; + Whitespace;[ ]; + CSharpTemplateBlock - [9..20)::11 + MarkupBlock - [9..20)::11 + MarkupTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [10..20)::10 + MarkupStartTag - [10..13)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [13..16)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [16..20)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpExpressionLiteral - [20..25)::5 - [ )] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Whitespace;[ ]; + RightParenthesis;[)]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.cspans.txt new file mode 100644 index 0000000000..5b0b252277 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Transition span at (8:1,4 [1] ) (Accepts:None) - Parent: Markup block at (8:1,4 [11] ) +Markup span at (9:1,5 [3] ) (Accepts:None) - Parent: Tag block at (9:1,5 [3] ) +Markup span at (12:1,8 [3] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [11] ) +Markup span at (15:1,11 [4] ) (Accepts:None) - Parent: Tag block at (15:1,11 [4] ) +Code span at (19:1,15 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (25:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (26:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.diag.txt new file mode 100644 index 0000000000..fd4615efa6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.diag.txt @@ -0,0 +1,5 @@ +(2,5): Error RZ1009: The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + +@if(isLoggedIn) { +

                    Hello, @user!

                    +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.stree.txt new file mode 100644 index 0000000000..630bd75bbb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..26)::26 - [@{LF @

                    Foo

                    LF}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..25)::23 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [8..19)::11 + MarkupTransition - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupElement - [9..19)::10 + MarkupStartTag - [9..12)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [12..15)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [15..19)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..25)::6 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnTagTransitionInDesignTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnTagTransitionInDesignTimeMode.cspans.txt new file mode 100644 index 0000000000..a8076b5e94 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnTagTransitionInDesignTimeMode.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (8:1,4 [3] ) (Accepts:None) - Parent: Tag block at (8:1,4 [3] ) +Markup span at (11:1,7 [3] ) (Accepts:Any) - Parent: Markup block at (8:1,4 [10] ) +Markup span at (14:1,10 [4] ) (Accepts:None) - Parent: Tag block at (14:1,10 [4] ) +Code span at (18:1,14 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (24:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnTagTransitionInDesignTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnTagTransitionInDesignTimeMode.stree.txt new file mode 100644 index 0000000000..736cbe9532 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/GivesSpacesToCodeOnTagTransitionInDesignTimeMode.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..25)::25 - [@{LF

                    Foo

                    LF}] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [8..18)::10 + MarkupElement - [8..18)::10 + MarkupStartTag - [8..11)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [11..14)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [14..18)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [18..24)::6 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracket.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracket.cspans.txt new file mode 100644 index 0000000000..8d8980837d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracket.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Code span at (1:0,1 [29] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (30:0,30 [1] ) (Accepts:Any) - Parent: Markup block at (30:0,30 [12] ) +Markup span at (31:0,31 [3] ) (Accepts:None) - Parent: Tag block at (31:0,31 [3] ) +Markup span at (34:0,34 [3] ) (Accepts:Any) - Parent: Markup block at (30:0,30 [12] ) +Markup span at (37:0,37 [4] ) (Accepts:None) - Parent: Tag block at (37:0,37 [4] ) +Markup span at (41:0,41 [1] ) (Accepts:None) - Parent: Markup block at (30:0,30 [12] ) +Code span at (42:0,42 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (43:0,43 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracket.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracket.stree.txt new file mode 100644 index 0000000000..831e37ead9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracket.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..43)::43 - [@for(int i = 0; i < 10; i++) {

                    Foo

                    }] + MarkupBlock - [0..43)::43 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..43)::43 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..30)::29 - [for(int i = 0; i < 10; i++) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[for]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Increment;[++]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [30..42)::12 + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [31..41)::10 + MarkupStartTag - [31..34)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [34..37)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [37..41)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [41..42)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [42..43)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracketInCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracketInCodeBlock.cspans.txt new file mode 100644 index 0000000000..308cd5d14f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracketInCodeBlock.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +Code span at (2:0,2 [30] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [47] ) +Markup span at (32:0,32 [1] ) (Accepts:Any) - Parent: Markup block at (32:0,32 [12] ) +Markup span at (33:0,33 [3] ) (Accepts:None) - Parent: Tag block at (33:0,33 [3] ) +Markup span at (36:0,36 [3] ) (Accepts:Any) - Parent: Markup block at (32:0,32 [12] ) +Markup span at (39:0,39 [4] ) (Accepts:None) - Parent: Tag block at (39:0,39 [4] ) +Markup span at (43:0,43 [1] ) (Accepts:None) - Parent: Markup block at (32:0,32 [12] ) +Code span at (44:0,44 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [47] ) +MetaCode span at (46:0,46 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +Markup span at (47:0,47 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracketInCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracketInCodeBlock.stree.txt new file mode 100644 index 0000000000..338f7b1022 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnOpenAngleBracketInCodeBlock.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..47)::47 - [@{ for(int i = 0; i < 10; i++) {

                    Foo

                    } }] + MarkupBlock - [0..47)::47 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..47)::47 + CSharpStatement - [0..47)::47 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..47)::46 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..46)::44 + CSharpStatementLiteral - [2..32)::30 - [ for(int i = 0; i < 10; i++) {] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[for]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + IntegerLiteral;[10]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[i]; + Increment;[++]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [32..44)::12 + MarkupTextLiteral - [32..33)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [33..43)::10 + MarkupStartTag - [33..36)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [36..39)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [39..43)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [44..46)::2 - [} ] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [46..47)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColon.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColon.cspans.txt new file mode 100644 index 0000000000..e759ba2bed --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColon.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [8] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Markup block at (10:0,10 [8] ) +MetaCode span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [8] ) +Markup span at (13:0,13 [5] ) (Accepts:None) - Parent: Markup block at (10:0,10 [8] ) +Code span at (18:1,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (19:1,1 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColon.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColon.stree.txt new file mode 100644 index 0000000000..be98669bd5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColon.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..24)::24 - [@if(foo) { @:BarLF} zoop] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..10)::9 - [if(foo) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [10..18)::8 + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [13..18)::5 - [BarLF] - Gen - SpanEditHandler;Accepts:None + Text;[Bar]; + NewLine;[LF]; + CSharpStatementLiteral - [18..19)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + MarkupTextLiteral - [19..24)::5 - [ zoop] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[zoop]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock.cspans.txt new file mode 100644 index 0000000000..985b278a3a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (2:0,2 [10] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [8] ) +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Markup block at (12:0,12 [8] ) +MetaCode span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [8] ) +Markup span at (15:0,15 [5] ) (Accepts:None) - Parent: Markup block at (12:0,12 [8] ) +Code span at (20:1,0 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:1,2 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:1,3 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock.stree.txt new file mode 100644 index 0000000000..6b53cd40f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..28)::28 - [@{ if(foo) { @:BarLF} } zoop] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + CSharpStatementLiteral - [2..12)::10 - [ if(foo) {] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [12..20)::8 + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [15..20)::5 - [BarLF] - Gen - SpanEditHandler;Accepts:None + Text;[Bar]; + NewLine;[LF]; + CSharpStatementLiteral - [20..22)::2 - [} ] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..28)::5 - [ zoop] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[zoop]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon.cspans.txt new file mode 100644 index 0000000000..8ca4ca163f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [14] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Markup block at (10:0,10 [14] ) +MetaCode span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [14] ) +Markup span at (13:0,13 [11] ) (Accepts:None) - Parent: Markup block at (10:0,10 [14] ) +Code span at (24:1,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon.stree.txt new file mode 100644 index 0000000000..a495874e27 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..25)::25 - [@if(foo) { @::SometextLF}] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..10)::9 - [if(foo) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [10..24)::14 + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [13..24)::11 - [:SometextLF] - Gen - SpanEditHandler;Accepts:None + Text;[:Sometext]; + NewLine;[LF]; + CSharpStatementLiteral - [24..25)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon.cspans.txt new file mode 100644 index 0000000000..284bead87a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (1:0,1 [9] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [15] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Markup block at (10:0,10 [15] ) +MetaCode span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [15] ) +Markup span at (13:0,13 [12] ) (Accepts:None) - Parent: Markup block at (10:0,10 [15] ) +Code span at (25:1,0 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon.stree.txt new file mode 100644 index 0000000000..64cf48ac22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..26)::26 - [@if(foo) { @:::SometextLF}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..10)::9 - [if(foo) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [10..25)::15 + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [13..25)::12 - [::SometextLF] - Gen - SpanEditHandler;Accepts:None + Text;[::Sometext]; + NewLine;[LF]; + CSharpStatementLiteral - [25..26)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportMarkupWithoutPreceedingWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportMarkupWithoutPreceedingWhitespace.cspans.txt new file mode 100644 index 0000000000..ba66ea2b8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportMarkupWithoutPreceedingWhitespace.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Code span at (1:0,1 [33] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [68] ) +Transition span at (34:3,0 [1] ) (Accepts:None) - Parent: Markup block at (34:3,0 [7] ) +MetaCode span at (35:3,1 [1] ) (Accepts:Any) - Parent: Markup block at (34:3,0 [7] ) +Markup span at (36:3,2 [5] ) (Accepts:None) - Parent: Markup block at (34:3,0 [7] ) +Markup span at (41:4,0 [5] ) (Accepts:None) - Parent: Tag block at (41:4,0 [5] ) +Markup span at (46:4,5 [2] ) (Accepts:None) - Parent: Markup block at (41:4,0 [7] ) +Markup span at (48:5,0 [3] ) (Accepts:None) - Parent: Tag block at (48:5,0 [3] ) +Markup span at (51:5,3 [3] ) (Accepts:Any) - Parent: Markup block at (48:5,0 [12] ) +Markup span at (54:5,6 [4] ) (Accepts:None) - Parent: Tag block at (54:5,6 [4] ) +Markup span at (58:5,10 [2] ) (Accepts:None) - Parent: Markup block at (48:5,0 [12] ) +Transition span at (60:6,0 [1] ) (Accepts:None) - Parent: Markup block at (60:6,0 [7] ) +MetaCode span at (61:6,1 [1] ) (Accepts:Any) - Parent: Markup block at (60:6,0 [7] ) +Markup span at (62:6,2 [5] ) (Accepts:None) - Parent: Markup block at (60:6,0 [7] ) +Code span at (67:7,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Markup span at (68:7,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportMarkupWithoutPreceedingWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportMarkupWithoutPreceedingWhitespace.stree.txt new file mode 100644 index 0000000000..bb699f4b93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportMarkupWithoutPreceedingWhitespace.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..68)::68 - [@foreach(var file in files){LFLFLF@:BazLF
                    LFFooLF@:BarLF}] + MarkupBlock - [0..68)::68 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..68)::68 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..34)::33 - [foreach(var file in files){LFLFLF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[file]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[files]; + RightParenthesis;[)]; + LeftBrace;[{]; + NewLine;[LF]; + NewLine;[LF]; + NewLine;[LF]; + MarkupBlock - [34..41)::7 + MarkupTransition - [34..35)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [35..36)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [36..41)::5 - [BazLF] - Gen - SpanEditHandler;Accepts:None + Text;[Baz]; + NewLine;[LF]; + MarkupBlock - [41..48)::7 + MarkupElement - [41..46)::5 + MarkupStartTag - [41..46)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[br]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [46..48)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [48..60)::12 + MarkupElement - [48..58)::10 + MarkupStartTag - [48..51)::3 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + CloseAngle;[>]; + MarkupTextLiteral - [51..54)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [54..58)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[a]; + CloseAngle;[>]; + MarkupTextLiteral - [58..60)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [60..67)::7 + MarkupTransition - [60..61)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [61..62)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [62..67)::5 - [BarLF] - Gen - SpanEditHandler;Accepts:None + Text;[Bar]; + NewLine;[LF]; + CSharpStatementLiteral - [67..68)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [68..68)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportSingleLineMarkupContainingStatementBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportSingleLineMarkupContainingStatementBlock.cspans.txt new file mode 100644 index 0000000000..1bc4567d7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportSingleLineMarkupContainingStatementBlock.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [26] ) +Code span at (1:0,1 [16] ) (Accepts:Any) - Parent: Expression block at (0:0,0 [26] ) +Transition span at (17:1,4 [1] ) (Accepts:None) - Parent: Markup block at (17:1,4 [8] ) +MetaCode span at (18:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (17:1,4 [8] ) +Markup span at (19:1,6 [1] ) (Accepts:Any) - Parent: Markup block at (17:1,4 [8] ) +Transition span at (20:1,7 [1] ) (Accepts:None) - Parent: Statement block at (20:1,7 [3] ) +MetaCode span at (21:1,8 [1] ) (Accepts:None) - Parent: Statement block at (20:1,7 [3] ) +Code span at (22:1,9 [0] ) (Accepts:Any) - Parent: Statement block at (20:1,7 [3] ) +MetaCode span at (22:1,9 [1] ) (Accepts:None) - Parent: Statement block at (20:1,7 [3] ) +Markup span at (23:1,10 [2] ) (Accepts:None) - Parent: Markup block at (17:1,4 [8] ) +Code span at (25:2,0 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [26] ) +Markup span at (26:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportSingleLineMarkupContainingStatementBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportSingleLineMarkupContainingStatementBlock.stree.txt new file mode 100644 index 0000000000..63d7684102 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/ShouldSupportSingleLineMarkupContainingStatementBlock.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..26)::26 - [@Repeat(10,LF @: @{}LF)] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpImplicitExpression - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..26)::25 + CSharpCodeBlock - [1..26)::25 + CSharpExpressionLiteral - [1..17)::16 - [Repeat(10,LF ] - Gen - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 + Identifier;[Repeat]; + LeftParenthesis;[(]; + IntegerLiteral;[10]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + CSharpTemplateBlock - [17..25)::8 + MarkupBlock - [17..25)::8 + MarkupTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [18..19)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [20..23)::3 + CSharpStatement - [20..23)::3 + CSharpTransition - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [21..23)::2 + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [22..22)::0 + CSharpStatementLiteral - [22..22)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..25)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpExpressionLiteral - [25..26)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + RightParenthesis;[)]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated.cspans.txt new file mode 100644 index 0000000000..71420aa95e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Code span at (2:0,2 [7] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated.stree.txt new file mode 100644 index 0000000000..9cd8630955 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SingleAngleBracketDoesNotCauseSwitchIfOuterBlockIsTerminated.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..10)::10 - [@{ List< }] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + CSharpStatementLiteral - [2..9)::7 - [ List< ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[List]; + LessThan;[<]; + Whitespace;[ ]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsAllKindsOfImplicitMarkupInCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsAllKindsOfImplicitMarkupInCodeBlock.cspans.txt new file mode 100644 index 0000000000..df3f126852 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsAllKindsOfImplicitMarkupInCodeBlock.cspans.txt @@ -0,0 +1,23 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [207] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [207] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [207] ) +Code span at (2:0,2 [18] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [207] ) +Markup span at (20:2,0 [8] ) (Accepts:Any) - Parent: Markup block at (20:2,0 [30] ) +Transition span at (28:2,8 [1] ) (Accepts:None) - Parent: Markup block at (20:2,0 [30] ) +MetaCode span at (29:2,9 [1] ) (Accepts:Any) - Parent: Markup block at (20:2,0 [30] ) +Markup span at (30:2,10 [20] ) (Accepts:None) - Parent: Markup block at (20:2,0 [30] ) +Code span at (50:3,0 [65] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [207] ) +Transition span at (115:5,8 [6] ) (Accepts:None) - Parent: Tag block at (115:5,8 [6] ) +Markup span at (121:5,14 [14] ) (Accepts:Any) - Parent: Markup block at (115:5,8 [29] ) +Transition span at (135:5,28 [1] ) (Accepts:None) - Parent: Expression block at (135:5,28 [2] ) +Code span at (136:5,29 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (135:5,28 [2] ) +Transition span at (137:5,30 [7] ) (Accepts:None) - Parent: Tag block at (137:5,30 [7] ) +Code span at (144:5,37 [27] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [207] ) +Markup span at (171:8,0 [8] ) (Accepts:Any) - Parent: Markup block at (171:8,0 [28] ) +Markup span at (179:8,8 [3] ) (Accepts:None) - Parent: Tag block at (179:8,8 [3] ) +Markup span at (182:8,11 [11] ) (Accepts:Any) - Parent: Markup block at (171:8,0 [28] ) +Markup span at (193:8,22 [4] ) (Accepts:None) - Parent: Tag block at (193:8,22 [4] ) +Markup span at (197:8,26 [2] ) (Accepts:None) - Parent: Markup block at (171:8,0 [28] ) +Code span at (199:9,0 [7] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [207] ) +MetaCode span at (206:10,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [207] ) +Markup span at (207:10,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [207] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsAllKindsOfImplicitMarkupInCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsAllKindsOfImplicitMarkupInCodeBlock.stree.txt new file mode 100644 index 0000000000..020255d2f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsAllKindsOfImplicitMarkupInCodeBlock.stree.txt @@ -0,0 +1,134 @@ +RazorDocument - [0..207)::207 - [@{LF if(true) {LF @:Single Line MarkupLF }LF foreach (var p in Enumerable.Range(1, 10)) {LF The number is @pLF }LF if(!false) {LF

                    A real tag!

                    LF }LF}] + MarkupBlock - [0..207)::207 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..207)::207 + CSharpStatement - [0..207)::207 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..207)::206 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..206)::204 + CSharpStatementLiteral - [2..20)::18 - [LF if(true) {LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [20..50)::30 + MarkupTextLiteral - [20..28)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTransition - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [30..50)::20 - [Single Line MarkupLF] - Gen - SpanEditHandler;Accepts:None + Text;[Single]; + Whitespace;[ ]; + Text;[Line]; + Whitespace;[ ]; + Text;[Markup]; + NewLine;[LF]; + CSharpStatementLiteral - [50..115)::65 - [ }LF foreach (var p in Enumerable.Range(1, 10)) {LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[foreach]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[p]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Enumerable]; + Dot;[.]; + Identifier;[Range]; + LeftParenthesis;[(]; + IntegerLiteral;[1]; + Comma;[,]; + Whitespace;[ ]; + IntegerLiteral;[10]; + RightParenthesis;[)]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [115..144)::29 + MarkupElement - [115..144)::29 + MarkupStartTag - [115..121)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [121..135)::14 - [The number is ] - Gen - SpanEditHandler;Accepts:Any + Text;[The]; + Whitespace;[ ]; + Text;[number]; + Whitespace;[ ]; + Text;[is]; + Whitespace;[ ]; + CSharpCodeBlock - [135..137)::2 + CSharpImplicitExpression - [135..137)::2 + CSharpTransition - [135..136)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [136..137)::1 + CSharpCodeBlock - [136..137)::1 + CSharpExpressionLiteral - [136..137)::1 - [p] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[p]; + MarkupEndTag - [137..144)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [144..171)::27 - [LF }LF if(!false) {LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[if]; + LeftParenthesis;[(]; + Not;[!]; + Keyword;[false]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [171..199)::28 + MarkupTextLiteral - [171..179)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [179..197)::18 + MarkupStartTag - [179..182)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [182..193)::11 - [A real tag!] - Gen - SpanEditHandler;Accepts:Any + Text;[A]; + Whitespace;[ ]; + Text;[real]; + Whitespace;[ ]; + Text;[tag]; + Bang;[!]; + MarkupEndTag - [193..197)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [197..199)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [199..206)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + RazorMetaCode - [206..207)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [207..207)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitch.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitch.cspans.txt new file mode 100644 index 0000000000..08846c99c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitch.cspans.txt @@ -0,0 +1,33 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [233] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [233] ) +Code span at (1:0,1 [28] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [233] ) +Markup span at (29:2,0 [8] ) (Accepts:Any) - Parent: Markup block at (29:2,0 [20] ) +Markup span at (37:2,8 [3] ) (Accepts:None) - Parent: Tag block at (37:2,8 [3] ) +Markup span at (40:2,11 [3] ) (Accepts:Any) - Parent: Markup block at (29:2,0 [20] ) +Markup span at (43:2,14 [4] ) (Accepts:None) - Parent: Tag block at (43:2,14 [4] ) +Markup span at (47:2,18 [2] ) (Accepts:None) - Parent: Markup block at (29:2,0 [20] ) +Code span at (49:3,0 [29] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [233] ) +Markup span at (78:5,0 [8] ) (Accepts:Any) - Parent: Markup block at (78:5,0 [20] ) +Markup span at (86:5,8 [3] ) (Accepts:None) - Parent: Tag block at (86:5,8 [3] ) +Markup span at (89:5,11 [3] ) (Accepts:Any) - Parent: Markup block at (78:5,0 [20] ) +Markup span at (92:5,14 [4] ) (Accepts:None) - Parent: Tag block at (92:5,14 [4] ) +Markup span at (96:5,18 [2] ) (Accepts:None) - Parent: Markup block at (78:5,0 [20] ) +Code span at (98:6,0 [41] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [233] ) +Markup span at (139:9,0 [12] ) (Accepts:Any) - Parent: Markup block at (139:9,0 [24] ) +Markup span at (151:9,12 [3] ) (Accepts:None) - Parent: Tag block at (151:9,12 [3] ) +Markup span at (154:9,15 [3] ) (Accepts:Any) - Parent: Markup block at (139:9,0 [24] ) +Markup span at (157:9,18 [4] ) (Accepts:None) - Parent: Tag block at (157:9,18 [4] ) +Markup span at (161:9,22 [2] ) (Accepts:None) - Parent: Markup block at (139:9,0 [24] ) +Markup span at (163:10,0 [12] ) (Accepts:Any) - Parent: Markup block at (163:10,0 [24] ) +Markup span at (175:10,12 [3] ) (Accepts:None) - Parent: Tag block at (175:10,12 [3] ) +Markup span at (178:10,15 [3] ) (Accepts:Any) - Parent: Markup block at (163:10,0 [24] ) +Markup span at (181:10,18 [4] ) (Accepts:None) - Parent: Tag block at (181:10,18 [4] ) +Markup span at (185:10,22 [2] ) (Accepts:None) - Parent: Markup block at (163:10,0 [24] ) +Code span at (187:11,0 [25] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [233] ) +Markup span at (212:13,0 [8] ) (Accepts:Any) - Parent: Markup block at (212:13,0 [20] ) +Markup span at (220:13,8 [3] ) (Accepts:None) - Parent: Tag block at (220:13,8 [3] ) +Markup span at (223:13,11 [3] ) (Accepts:Any) - Parent: Markup block at (212:13,0 [20] ) +Markup span at (226:13,14 [4] ) (Accepts:None) - Parent: Tag block at (226:13,14 [4] ) +Markup span at (230:13,18 [2] ) (Accepts:None) - Parent: Markup block at (212:13,0 [20] ) +Code span at (232:14,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [233] ) +Markup span at (233:14,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [233] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitch.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitch.stree.txt new file mode 100644 index 0000000000..7f17709368 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitch.stree.txt @@ -0,0 +1,143 @@ +RazorDocument - [0..233)::233 - [@switch(foo) {LF case 0:LF

                    Foo

                    LF break;LF case 1:LF

                    Bar

                    LF return;LF case 2:LF {LF

                    Baz

                    LF

                    Boz

                    LF }LF default:LF

                    Biz

                    LF}] + MarkupBlock - [0..233)::233 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..233)::233 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..29)::28 - [switch(foo) {LF case 0:LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[switch]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Colon;[:]; + NewLine;[LF]; + MarkupBlock - [29..49)::20 + MarkupTextLiteral - [29..37)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [37..47)::10 + MarkupStartTag - [37..40)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [40..43)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [43..47)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [47..49)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [49..78)::29 - [ break;LF case 1:LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Keyword;[break]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Colon;[:]; + NewLine;[LF]; + MarkupBlock - [78..98)::20 + MarkupTextLiteral - [78..86)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [86..96)::10 + MarkupStartTag - [86..89)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [89..92)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [92..96)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [96..98)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [98..139)::41 - [ return;LF case 2:LF {LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Keyword;[return]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Colon;[:]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [139..163)::24 + MarkupTextLiteral - [139..151)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [151..161)::10 + MarkupStartTag - [151..154)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [154..157)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupEndTag - [157..161)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [161..163)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [163..187)::24 + MarkupTextLiteral - [163..175)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [175..185)::10 + MarkupStartTag - [175..178)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [178..181)::3 - [Boz] - Gen - SpanEditHandler;Accepts:Any + Text;[Boz]; + MarkupEndTag - [181..185)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [185..187)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [187..212)::25 - [ }LF default:LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[default]; + Colon;[:]; + NewLine;[LF]; + MarkupBlock - [212..232)::20 + MarkupTextLiteral - [212..220)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [220..230)::10 + MarkupStartTag - [220..223)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [223..226)::3 - [Biz] - Gen - SpanEditHandler;Accepts:Any + Text;[Biz]; + MarkupEndTag - [226..230)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [230..232)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [232..233)::1 - [}] - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [233..233)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock.cspans.txt new file mode 100644 index 0000000000..371412c07f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock.cspans.txt @@ -0,0 +1,35 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [237] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [237] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [237] ) +Code span at (2:0,2 [29] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [237] ) +Markup span at (31:2,0 [8] ) (Accepts:Any) - Parent: Markup block at (31:2,0 [20] ) +Markup span at (39:2,8 [3] ) (Accepts:None) - Parent: Tag block at (39:2,8 [3] ) +Markup span at (42:2,11 [3] ) (Accepts:Any) - Parent: Markup block at (31:2,0 [20] ) +Markup span at (45:2,14 [4] ) (Accepts:None) - Parent: Tag block at (45:2,14 [4] ) +Markup span at (49:2,18 [2] ) (Accepts:None) - Parent: Markup block at (31:2,0 [20] ) +Code span at (51:3,0 [29] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [237] ) +Markup span at (80:5,0 [8] ) (Accepts:Any) - Parent: Markup block at (80:5,0 [20] ) +Markup span at (88:5,8 [3] ) (Accepts:None) - Parent: Tag block at (88:5,8 [3] ) +Markup span at (91:5,11 [3] ) (Accepts:Any) - Parent: Markup block at (80:5,0 [20] ) +Markup span at (94:5,14 [4] ) (Accepts:None) - Parent: Tag block at (94:5,14 [4] ) +Markup span at (98:5,18 [2] ) (Accepts:None) - Parent: Markup block at (80:5,0 [20] ) +Code span at (100:6,0 [41] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [237] ) +Markup span at (141:9,0 [12] ) (Accepts:Any) - Parent: Markup block at (141:9,0 [24] ) +Markup span at (153:9,12 [3] ) (Accepts:None) - Parent: Tag block at (153:9,12 [3] ) +Markup span at (156:9,15 [3] ) (Accepts:Any) - Parent: Markup block at (141:9,0 [24] ) +Markup span at (159:9,18 [4] ) (Accepts:None) - Parent: Tag block at (159:9,18 [4] ) +Markup span at (163:9,22 [2] ) (Accepts:None) - Parent: Markup block at (141:9,0 [24] ) +Markup span at (165:10,0 [12] ) (Accepts:Any) - Parent: Markup block at (165:10,0 [24] ) +Markup span at (177:10,12 [3] ) (Accepts:None) - Parent: Tag block at (177:10,12 [3] ) +Markup span at (180:10,15 [3] ) (Accepts:Any) - Parent: Markup block at (165:10,0 [24] ) +Markup span at (183:10,18 [4] ) (Accepts:None) - Parent: Tag block at (183:10,18 [4] ) +Markup span at (187:10,22 [2] ) (Accepts:None) - Parent: Markup block at (165:10,0 [24] ) +Code span at (189:11,0 [25] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [237] ) +Markup span at (214:13,0 [8] ) (Accepts:Any) - Parent: Markup block at (214:13,0 [20] ) +Markup span at (222:13,8 [3] ) (Accepts:None) - Parent: Tag block at (222:13,8 [3] ) +Markup span at (225:13,11 [3] ) (Accepts:Any) - Parent: Markup block at (214:13,0 [20] ) +Markup span at (228:13,14 [4] ) (Accepts:None) - Parent: Tag block at (228:13,14 [4] ) +Markup span at (232:13,18 [2] ) (Accepts:None) - Parent: Markup block at (214:13,0 [20] ) +Code span at (234:14,0 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [237] ) +MetaCode span at (236:14,2 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [237] ) +Markup span at (237:14,3 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [237] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock.stree.txt new file mode 100644 index 0000000000..63e92358d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpToMarkupSwitchTest/SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock.stree.txt @@ -0,0 +1,152 @@ +RazorDocument - [0..237)::237 - [@{ switch(foo) {LF case 0:LF

                    Foo

                    LF break;LF case 1:LF

                    Bar

                    LF return;LF case 2:LF {LF

                    Baz

                    LF

                    Boz

                    LF }LF default:LF

                    Biz

                    LF} }] + MarkupBlock - [0..237)::237 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..237)::237 + CSharpStatement - [0..237)::237 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..237)::236 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..236)::234 + CSharpStatementLiteral - [2..31)::29 - [ switch(foo) {LF case 0:LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[switch]; + LeftParenthesis;[(]; + Identifier;[foo]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Colon;[:]; + NewLine;[LF]; + MarkupBlock - [31..51)::20 + MarkupTextLiteral - [31..39)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [39..49)::10 + MarkupStartTag - [39..42)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [42..45)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [45..49)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [49..51)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [51..80)::29 - [ break;LF case 1:LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Keyword;[break]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Colon;[:]; + NewLine;[LF]; + MarkupBlock - [80..100)::20 + MarkupTextLiteral - [80..88)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [88..98)::10 + MarkupStartTag - [88..91)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [91..94)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [94..98)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [98..100)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [100..141)::41 - [ return;LF case 2:LF {LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Keyword;[return]; + Semicolon;[;]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[case]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Colon;[:]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [141..165)::24 + MarkupTextLiteral - [141..153)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [153..163)::10 + MarkupStartTag - [153..156)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [156..159)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupEndTag - [159..163)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [163..165)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [165..189)::24 + MarkupTextLiteral - [165..177)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [177..187)::10 + MarkupStartTag - [177..180)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [180..183)::3 - [Boz] - Gen - SpanEditHandler;Accepts:Any + Text;[Boz]; + MarkupEndTag - [183..187)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [187..189)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [189..214)::25 - [ }LF default:LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[default]; + Colon;[:]; + NewLine;[LF]; + MarkupBlock - [214..234)::20 + MarkupTextLiteral - [214..222)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [222..232)::10 + MarkupStartTag - [222..225)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [225..228)::3 - [Biz] - Gen - SpanEditHandler;Accepts:Any + Text;[Biz]; + MarkupEndTag - [228..232)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [232..234)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [234..236)::2 - [} ] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + Whitespace;[ ]; + RazorMetaCode - [236..237)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [237..237)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode.cspans.txt new file mode 100644 index 0000000000..73d431f67b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Expression block at (2:0,2 [5] ) +Code span at (3:0,3 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (2:0,2 [5] ) +Code span at (7:0,7 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (9:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:1,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode.stree.txt new file mode 100644 index 0000000000..537ca2fd70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..10)::10 - [@{@foo.LF}] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + CSharpCodeBlock - [2..7)::5 + CSharpImplicitExpression - [2..7)::5 + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [3..7)::4 + CSharpCodeBlock - [3..7)::4 + CSharpExpressionLiteral - [3..7)::4 - [foo.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Identifier;[foo]; + Dot;[.]; + CSharpStatementLiteral - [7..9)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.cspans.txt new file mode 100644 index 0000000000..2caa075c0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Expression block at (2:0,2 [1] ) +Code span at (3:0,3 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (2:0,2 [1] ) +Code span at (3:0,3 [1] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (4:0,4 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (5:0,5 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.diag.txt new file mode 100644 index 0000000000..af4954d89e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1005: "." is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.stree.txt new file mode 100644 index 0000000000..6efc85bc18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptDotAfterAt.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..5)::5 - [@{@.}] + MarkupBlock - [0..5)::5 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..4)::2 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + CSharpCodeBlock - [2..3)::1 + CSharpImplicitExpression - [2..3)::1 + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [3..3)::0 + CSharpCodeBlock - [3..3)::0 + CSharpExpressionLiteral - [3..3)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Marker;[]; + CSharpStatementLiteral - [3..4)::1 - [.] - Gen - SpanEditHandler;Accepts:Any + Dot;[.]; + RazorMetaCode - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [5..5)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode.cspans.txt new file mode 100644 index 0000000000..73d431f67b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Expression block at (2:0,2 [5] ) +Code span at (3:0,3 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (2:0,2 [5] ) +Code span at (7:0,7 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (9:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:1,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode.stree.txt new file mode 100644 index 0000000000..537ca2fd70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..10)::10 - [@{@foo.LF}] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + CSharpCodeBlock - [2..7)::5 + CSharpImplicitExpression - [2..7)::5 + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [3..7)::4 + CSharpCodeBlock - [3..7)::4 + CSharpExpressionLiteral - [3..7)::4 - [foo.] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Identifier;[foo]; + Dot;[.]; + CSharpStatementLiteral - [7..9)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.cspans.txt new file mode 100644 index 0000000000..cfb01939e7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Code span at (2:0,2 [6] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) +Transition span at (8:1,4 [1] ) (Accepts:None) - Parent: Expression block at (8:1,4 [1] ) +Code span at (9:1,5 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (8:1,4 [1] ) +Code span at (9:1,5 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (11:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Markup span at (12:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.diag.txt new file mode 100644 index 0000000000..a8f6dc0930 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.diag.txt @@ -0,0 +1 @@ +(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.stree.txt new file mode 100644 index 0000000000..a83496ddd1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..12)::12 - [@{LF @LF}] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + CSharpStatement - [0..12)::12 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..12)::11 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..11)::9 + CSharpStatementLiteral - [2..8)::6 - [LF ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + Whitespace;[ ]; + CSharpCodeBlock - [8..9)::1 + CSharpImplicitExpression - [8..9)::1 + CSharpTransition - [8..9)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [9..9)::0 + CSharpCodeBlock - [9..9)::0 + CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Marker;[]; + CSharpStatementLiteral - [9..11)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [12..12)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.cspans.txt new file mode 100644 index 0000000000..38b8899f16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [4] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Expression block at (2:0,2 [1] ) +Code span at (3:0,3 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (2:0,2 [1] ) +Code span at (3:0,3 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [4] ) +Markup span at (4:0,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.diag.txt new file mode 100644 index 0000000000..ca1dc596ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1005: "}" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.stree.txt new file mode 100644 index 0000000000..7d2bc1804c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..4)::4 - [@{@}] + MarkupBlock - [0..4)::4 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpStatement - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..4)::3 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..3)::1 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + CSharpCodeBlock - [2..3)::1 + CSharpImplicitExpression - [2..3)::1 + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [3..3)::0 + CSharpCodeBlock - [3..3)::0 + CSharpExpressionLiteral - [3..3)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + Marker;[]; + CSharpStatementLiteral - [3..3)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [4..4)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/VerbatimBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/VerbatimBlock.cspans.txt new file mode 100644 index 0000000000..d86374cf4e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/VerbatimBlock.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Code span at (2:0,2 [8] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/VerbatimBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/VerbatimBlock.stree.txt new file mode 100644 index 0000000000..fed47f7288 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpVerbatimBlockTest/VerbatimBlock.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..11)::11 - [@{ foo(); }] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpStatement - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..10)::8 + CSharpStatementLiteral - [2..10)::8 - [ foo(); ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpWhitespaceHandlingTest/StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpWhitespaceHandlingTest/StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor.cspans.txt new file mode 100644 index 0000000000..86b0e40245 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpWhitespaceHandlingTest/StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [19] ) +MetaCode span at (3:0,3 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Transition span at (5:0,5 [1] ) (Accepts:None) - Parent: Statement block at (5:0,5 [14] ) +Code span at (6:0,6 [13] ) (Accepts:Any) - Parent: Statement block at (5:0,5 [14] ) +Markup span at (19:0,19 [2] ) (Accepts:None) - Parent: Markup block at (2:0,2 [19] ) +Code span at (21:1,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:1,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpWhitespaceHandlingTest/StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpWhitespaceHandlingTest/StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor.stree.txt new file mode 100644 index 0000000000..b40e6c93fd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpWhitespaceHandlingTest/StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..22)::22 - [@{@: @if (true) { }LF}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [5..19)::14 + CSharpTransition - [5..6)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [6..19)::13 - [if (true) { }] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [19..21)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesAsMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesAsMarkup.cspans.txt new file mode 100644 index 0000000000..9832cbfec6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesAsMarkup.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [20] ) +Markup span at (5:0,5 [9] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [14] ) +Transition span at (14:0,14 [1] ) (Accepts:None) - Parent: Expression block at (14:0,14 [4] ) +Code span at (15:0,15 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (14:0,14 [4] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [14] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [20] ) +Markup span at (20:0,20 [7] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesAsMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesAsMarkup.stree.txt new file mode 100644 index 0000000000..e8c4ec1095 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesAsMarkup.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..27)::27 - [] + MarkupBlock - [0..27)::27 + MarkupElement - [0..27)::27 + MarkupStartTag - [0..20)::20 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [5..19)::14 - [ @class='@foo'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..12)::6 - [@class] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [14..18)::4 + MarkupDynamicAttributeValue - [14..18)::4 - [@foo] + GenericBlock - [14..18)::4 + CSharpCodeBlock - [14..18)::4 + CSharpImplicitExpression - [14..18)::4 + CSharpTransition - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [15..18)::3 + CSharpCodeBlock - [15..18)::3 + CSharpExpressionLiteral - [15..18)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [20..27)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup.cspans.txt new file mode 100644 index 0000000000..94b56eaa83 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (5:0,5 [15] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [20] ) +Transition span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (20:0,20 [4] ) +Code span at (21:0,21 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (20:0,20 [4] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [20] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (26:0,26 [7] ) (Accepts:Any) - Parent: Tag block at (26:0,26 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup.stree.txt new file mode 100644 index 0000000000..4742d0f6c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ComponentFileKind_ParsesDirectiveAttributesWithParameterAsMarkup.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..33)::33 - [] + MarkupBlock - [0..33)::33 + MarkupElement - [0..33)::33 + MarkupStartTag - [0..26)::26 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [5..25)::20 - [ @class:param='@foo'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..18)::12 - [@class:param] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Text;[class:param]; + Equals;[=]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [20..24)::4 + MarkupDynamicAttributeValue - [20..24)::4 - [@foo] + GenericBlock - [20..24)::4 + CSharpCodeBlock - [20..24)::4 + CSharpImplicitExpression - [20..24)::4 + CSharpTransition - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [21..24)::3 + CSharpCodeBlock - [21..24)::3 + CSharpExpressionLiteral - [21..24)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [26..33)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInBlock.cspans.txt new file mode 100644 index 0000000000..afd40eccab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInBlock.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (7:0,7 [11] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [16] ) +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Expression block at (18:0,18 [4] ) +Code span at (19:0,19 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (18:0,18 [4] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [16] ) +Markup span at (23:0,23 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (24:0,24 [7] ) (Accepts:None) - Parent: Tag block at (24:0,24 [7] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInBlock.stree.txt new file mode 100644 index 0000000000..4e4b3a1ee0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInBlock.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupElement - [2..31)::29 + MarkupStartTag - [2..24)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..23)::16 - [ data-foo='@foo'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [data-foo] - Gen - SpanEditHandler;Accepts:Any + Text;[data-foo]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [18..22)::4 + CSharpCodeBlock - [18..22)::4 + CSharpImplicitExpression - [18..22)::4 + CSharpTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [19..22)::3 + CSharpCodeBlock - [19..22)::3 + CSharpExpressionLiteral - [19..22)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [24..31)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInDocument.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInDocument.cspans.txt new file mode 100644 index 0000000000..afd40eccab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInDocument.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (7:0,7 [11] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [16] ) +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Expression block at (18:0,18 [4] ) +Code span at (19:0,19 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (18:0,18 [4] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [16] ) +Markup span at (23:0,23 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (24:0,24 [7] ) (Accepts:None) - Parent: Tag block at (24:0,24 [7] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInDocument.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInDocument.stree.txt new file mode 100644 index 0000000000..4e4b3a1ee0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreDisabledForDataAttributesInDocument.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupElement - [2..31)::29 + MarkupStartTag - [2..24)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..23)::16 - [ data-foo='@foo'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [data-foo] - Gen - SpanEditHandler;Accepts:Any + Text;[data-foo]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [18..22)::4 + CSharpCodeBlock - [18..22)::4 + CSharpImplicitExpression - [18..22)::4 + CSharpTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [19..22)::3 + CSharpCodeBlock - [19..22)::3 + CSharpExpressionLiteral - [19..22)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [24..31)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag.cspans.txt new file mode 100644 index 0000000000..afd40eccab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (7:0,7 [11] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [16] ) +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Expression block at (18:0,18 [4] ) +Code span at (19:0,19 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (18:0,18 [4] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [16] ) +Markup span at (23:0,23 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (24:0,24 [7] ) (Accepts:None) - Parent: Tag block at (24:0,24 [7] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag.stree.txt new file mode 100644 index 0000000000..dcab17b569 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesAreEnabledForDataAttributesWithExperimentalFlag.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupElement - [2..31)::29 + MarkupStartTag - [2..24)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..23)::16 - [ data-foo='@foo'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [data-foo] - Gen - SpanEditHandler;Accepts:Any + Text;[data-foo]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [18..22)::4 + MarkupDynamicAttributeValue - [18..22)::4 - [@foo] + GenericBlock - [18..22)::4 + CSharpCodeBlock - [18..22)::4 + CSharpImplicitExpression - [18..22)::4 + CSharpTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [19..22)::3 + CSharpCodeBlock - [19..22)::3 + CSharpExpressionLiteral - [19..22)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [24..31)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock.cspans.txt new file mode 100644 index 0000000000..d4c9ee0a56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [26] ) +Markup span at (7:0,7 [15] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [20] ) +Transition span at (22:0,22 [1] ) (Accepts:None) - Parent: Expression block at (22:0,22 [4] ) +Code span at (23:0,23 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (22:0,22 [4] ) +Markup span at (26:0,26 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [20] ) +Markup span at (27:0,27 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [26] ) +Markup span at (28:0,28 [7] ) (Accepts:None) - Parent: Tag block at (28:0,28 [7] ) +Code span at (35:0,35 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (35:0,35 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock.stree.txt new file mode 100644 index 0000000000..f4602b1fde --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInBlock.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..36)::36 - [@{}] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpStatement - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..36)::35 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..35)::33 + MarkupBlock - [2..35)::33 + MarkupElement - [2..35)::33 + MarkupStartTag - [2..28)::26 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..27)::20 - [ data-foo = '@foo'] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [data-foo] - Gen - SpanEditHandler;Accepts:Any + Text;[data-foo]; + MarkupTextLiteral - [16..18)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Equals;[=]; + MarkupTextLiteral - [19..22)::3 - [ '] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + SingleQuote;[']; + GenericBlock - [22..26)::4 + CSharpCodeBlock - [22..26)::4 + CSharpImplicitExpression - [22..26)::4 + CSharpTransition - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [23..26)::3 + CSharpCodeBlock - [23..26)::3 + CSharpExpressionLiteral - [23..26)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [26..27)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [28..35)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [35..36)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument.cspans.txt new file mode 100644 index 0000000000..b00cc5d9fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [21] ) +Markup span at (7:0,7 [10] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [14] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Expression block at (17:0,17 [4] ) +Code span at (18:0,18 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (17:0,17 [4] ) +Markup span at (21:0,21 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [21] ) +Markup span at (23:0,23 [7] ) (Accepts:None) - Parent: Tag block at (23:0,23 [7] ) +Code span at (30:0,30 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (31:0,31 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument.stree.txt new file mode 100644 index 0000000000..77907906b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/ConditionalAttributesWithWeirdSpacingAreDisabledForDataAttributesInDocument.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..31)::31 - [@{}] + MarkupBlock - [0..31)::31 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + CSharpStatement - [0..31)::31 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..31)::30 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + MarkupBlock - [2..30)::28 + MarkupElement - [2..30)::28 + MarkupStartTag - [2..23)::21 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[span]; + MarkupAttributeBlock - [7..21)::14 - [ data-foo=@foo] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [data-foo] - Gen - SpanEditHandler;Accepts:Any + Text;[data-foo]; + Equals;[=]; + GenericBlock - [17..21)::4 + CSharpCodeBlock - [17..21)::4 + CSharpImplicitExpression - [17..21)::4 + CSharpTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [18..21)::3 + CSharpCodeBlock - [18..21)::3 + CSharpExpressionLiteral - [18..21)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupMiscAttributeContent - [21..22)::1 + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupEndTag - [23..30)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DoubleQuotedLiteralAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DoubleQuotedLiteralAttribute.cspans.txt new file mode 100644 index 0000000000..d2e1dc16d5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DoubleQuotedLiteralAttribute.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [24] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (14:0,14 [4] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (18:0,18 [4] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (23:0,23 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [24] ) +Code span at (26:0,26 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DoubleQuotedLiteralAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DoubleQuotedLiteralAttribute.stree.txt new file mode 100644 index 0000000000..522918f3b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DoubleQuotedLiteralAttribute.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..27)::27 - [@{}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..26)::24 + MarkupElement - [2..26)::24 + MarkupStartTag - [2..26)::24 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..23)::19 - [ href="Foo Bar Baz"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..22)::11 + MarkupLiteralAttributeValue - [11..14)::3 - [Foo] + MarkupTextLiteral - [11..14)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupLiteralAttributeValue - [14..18)::4 - [ Bar] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..18)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupLiteralAttributeValue - [18..22)::4 - [ Baz] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..22)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [23..24)::1 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DynamicAttributeWithWhitespaceSurroundingEquals.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DynamicAttributeWithWhitespaceSurroundingEquals.cspans.txt new file mode 100644 index 0000000000..2b04b0aff1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DynamicAttributeWithWhitespaceSurroundingEquals.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [23] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Transition span at (17:2,1 [1] ) (Accepts:None) - Parent: Expression block at (17:2,1 [4] ) +Code span at (18:2,2 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (17:2,1 [4] ) +Markup span at (21:2,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (22:2,6 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [23] ) +Code span at (25:2,9 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (25:2,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (26:2,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DynamicAttributeWithWhitespaceSurroundingEquals.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DynamicAttributeWithWhitespaceSurroundingEquals.stree.txt new file mode 100644 index 0000000000..59949b3f82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/DynamicAttributeWithWhitespaceSurroundingEquals.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..26)::26 - [@{}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..25)::23 + MarkupBlock - [2..25)::23 + MarkupElement - [2..25)::23 + MarkupStartTag - [2..25)::23 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..22)::18 - [ href LF= LF'@Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + MarkupTextLiteral - [9..12)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [13..17)::4 - [ LF'] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [17..21)::4 + MarkupDynamicAttributeValue - [17..21)::4 - [@Foo] + GenericBlock - [17..21)::4 + CSharpCodeBlock - [17..21)::4 + CSharpImplicitExpression - [17..21)::4 + CSharpTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [18..21)::3 + CSharpCodeBlock - [18..21)::3 + CSharpExpressionLiteral - [18..21)::3 - [Foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[Foo]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [22..23)::1 + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiPartLiteralAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiPartLiteralAttribute.cspans.txt new file mode 100644 index 0000000000..d2e1dc16d5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiPartLiteralAttribute.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [24] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (14:0,14 [4] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (18:0,18 [4] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (23:0,23 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [24] ) +Code span at (26:0,26 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiPartLiteralAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiPartLiteralAttribute.stree.txt new file mode 100644 index 0000000000..449c6e679d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiPartLiteralAttribute.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..27)::27 - [@{}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..26)::24 + MarkupElement - [2..26)::24 + MarkupStartTag - [2..26)::24 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..23)::19 - [ href='Foo Bar Baz'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..22)::11 + MarkupLiteralAttributeValue - [11..14)::3 - [Foo] + MarkupTextLiteral - [11..14)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupLiteralAttributeValue - [14..18)::4 - [ Bar] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..18)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupLiteralAttributeValue - [18..22)::4 - [ Baz] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..22)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [23..24)::1 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiValueExpressionAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiValueExpressionAttribute.cspans.txt new file mode 100644 index 0000000000..a859fd716e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiValueExpressionAttribute.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [26] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [21] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [4] ) +Code span at (12:0,12 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (11:0,11 [4] ) +Markup span at (15:0,15 [4] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [21] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (19:0,19 [5] ) +Transition span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (20:0,20 [4] ) +Code span at (21:0,21 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (20:0,20 [4] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [21] ) +Markup span at (25:0,25 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [26] ) +Code span at (28:0,28 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiValueExpressionAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiValueExpressionAttribute.stree.txt new file mode 100644 index 0000000000..9a528190d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/MultiValueExpressionAttribute.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..29)::29 - [@{}] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpStatement - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..29)::28 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..28)::26 + MarkupBlock - [2..28)::26 + MarkupElement - [2..28)::26 + MarkupStartTag - [2..28)::26 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..25)::21 - [ href='@foo bar @baz'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..24)::13 + MarkupDynamicAttributeValue - [11..15)::4 - [@foo] + GenericBlock - [11..15)::4 + CSharpCodeBlock - [11..15)::4 + CSharpImplicitExpression - [11..15)::4 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [12..15)::3 + CSharpCodeBlock - [12..15)::3 + CSharpExpressionLiteral - [12..15)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupLiteralAttributeValue - [15..19)::4 - [ bar] + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [16..19)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + MarkupDynamicAttributeValue - [19..24)::5 - [ @baz] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + GenericBlock - [20..24)::4 + CSharpCodeBlock - [20..24)::4 + CSharpImplicitExpression - [20..24)::4 + CSharpTransition - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [21..24)::3 + CSharpCodeBlock - [21..24)::3 + CSharpExpressionLiteral - [21..24)::3 - [baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[baz]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [25..26)::1 + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLineBetweenAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLineBetweenAttributes.cspans.txt new file mode 100644 index 0000000000..4ec6f65e2f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLineBetweenAttributes.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [29] ) +Markup span at (4:0,4 [8] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (12:1,6 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (15:1,9 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (16:1,10 [8] ) (Accepts:Any) - Parent: Markup block at (16:1,10 [12] ) +Markup span at (24:2,6 [3] ) (Accepts:Any) - Parent: Markup block at (16:1,10 [12] ) +Markup span at (27:2,9 [1] ) (Accepts:Any) - Parent: Markup block at (16:1,10 [12] ) +Markup span at (28:2,10 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [29] ) +Code span at (31:2,13 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:2,13 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:2,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLineBetweenAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLineBetweenAttributes.stree.txt new file mode 100644 index 0000000000..9284b6d6e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLineBetweenAttributes.stree.txt @@ -0,0 +1,56 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupElement - [2..31)::29 + MarkupStartTag - [2..31)::29 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..16)::12 - [LFhref='Foo'] + MarkupTextLiteral - [4..6)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [6..10)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [Foo] + MarkupTextLiteral - [12..15)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [16..28)::12 - [LFabcd='Bar'] + MarkupTextLiteral - [16..18)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [18..22)::4 - [abcd] - Gen - SpanEditHandler;Accepts:Any + Text;[abcd]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [24..27)::3 + MarkupLiteralAttributeValue - [24..27)::3 - [Bar] + MarkupTextLiteral - [24..27)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLinePrecedingAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLinePrecedingAttribute.cspans.txt new file mode 100644 index 0000000000..abb2545da4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLinePrecedingAttribute.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [17] ) +Markup span at (4:0,4 [8] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (12:1,6 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (15:1,9 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (16:1,10 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [17] ) +Code span at (19:1,13 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (19:1,13 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (20:1,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLinePrecedingAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLinePrecedingAttribute.stree.txt new file mode 100644 index 0000000000..c50f1edec6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/NewLinePrecedingAttribute.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..20)::20 - [@{}] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..19)::17 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..16)::12 - [LFhref='Foo'] + MarkupTextLiteral - [4..6)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [6..10)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [Foo] + MarkupTextLiteral - [12..15)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [19..20)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleExpressionAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleExpressionAttribute.cspans.txt new file mode 100644 index 0000000000..d427da460b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleExpressionAttribute.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [17] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [4] ) +Code span at (12:0,12 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (11:0,11 [4] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [17] ) +Code span at (19:0,19 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (19:0,19 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleExpressionAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleExpressionAttribute.stree.txt new file mode 100644 index 0000000000..f62fcea9b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleExpressionAttribute.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..20)::20 - [@{}] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..19)::17 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..16)::12 - [ href='@foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..15)::4 + MarkupDynamicAttributeValue - [11..15)::4 - [@foo] + GenericBlock - [11..15)::4 + CSharpCodeBlock - [11..15)::4 + CSharpImplicitExpression - [11..15)::4 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [12..15)::3 + CSharpCodeBlock - [12..15)::3 + CSharpExpressionLiteral - [12..15)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [19..20)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttribute.cspans.txt new file mode 100644 index 0000000000..ef0c16944f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttribute.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [11] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [11] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [11] ) +Markup span at (15:0,15 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Code span at (18:0,18 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttribute.stree.txt new file mode 100644 index 0000000000..71e57bd7e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttribute.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..19)::19 - [@{}] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpStatement - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..19)::18 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..18)::16 + MarkupBlock - [2..18)::16 + MarkupElement - [2..18)::16 + MarkupStartTag - [2..18)::16 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..15)::11 - [ href='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [Foo] + MarkupTextLiteral - [11..14)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [14..15)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [15..16)::1 + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttributeWithWhitespaceSurroundingEquals.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttributeWithWhitespaceSurroundingEquals.cspans.txt new file mode 100644 index 0000000000..1cbe6752de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttributeWithWhitespaceSurroundingEquals.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [24] ) +Markup span at (4:0,4 [15] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (19:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (22:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (23:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [24] ) +Code span at (26:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttributeWithWhitespaceSurroundingEquals.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttributeWithWhitespaceSurroundingEquals.stree.txt new file mode 100644 index 0000000000..3363750b09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SimpleLiteralAttributeWithWhitespaceSurroundingEquals.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..27)::27 - [@{}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..26)::24 + MarkupElement - [2..26)::24 + MarkupStartTag - [2..26)::24 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..23)::19 - [ href LF= LF'Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + MarkupTextLiteral - [9..13)::4 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [14..19)::5 - [ LF'] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [19..22)::3 + MarkupLiteralAttributeValue - [19..22)::3 - [Foo] + MarkupTextLiteral - [19..22)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [23..24)::1 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes1.cspans.txt new file mode 100644 index 0000000000..10b7d1d16f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes1.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (4:0,4 [9] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [13] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [13] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [13] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [18] ) +Code span at (20:0,20 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes1.stree.txt new file mode 100644 index 0000000000..dc163ac41b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes1.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..21)::21 - [@{}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..20)::18 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..17)::13 - [ [item]='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..11)::6 - [[item]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[item]; + RightBracket;[]]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [Foo] + MarkupTextLiteral - [13..16)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes2.cspans.txt new file mode 100644 index 0000000000..e1faf07262 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes2.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [10] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Code span at (21:0,21 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes2.stree.txt new file mode 100644 index 0000000000..b35f003282 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes2.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..22)::22 - [@{}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupElement - [2..21)::19 + MarkupStartTag - [2..21)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..18)::14 - [ [(item,='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..12)::7 - [[(item,] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[(item,]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [14..17)::3 + MarkupLiteralAttributeValue - [14..17)::3 - [Foo] + MarkupTextLiteral - [14..17)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [18..19)::1 + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes3.cspans.txt new file mode 100644 index 0000000000..e1faf07262 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes3.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [10] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (18:0,18 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Code span at (21:0,21 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes3.stree.txt new file mode 100644 index 0000000000..14dbd17409 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes3.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..22)::22 - [@{}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupElement - [2..21)::19 + MarkupStartTag - [2..21)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..18)::14 - [ (click)='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..12)::7 - [(click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(click)]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [14..17)::3 + MarkupLiteralAttributeValue - [14..17)::3 - [Foo] + MarkupTextLiteral - [14..17)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [18..19)::1 + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes4.cspans.txt new file mode 100644 index 0000000000..13c38bf943 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes4.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [20] ) +Markup span at (4:0,4 [11] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [20] ) +Code span at (22:0,22 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes4.stree.txt new file mode 100644 index 0000000000..b7b93fab26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes4.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..23)::23 - [@{}] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupElement - [2..22)::20 + MarkupStartTag - [2..22)::20 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..19)::15 - [ (^click)='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..13)::8 - [(^click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(^click)]; + Equals;[=]; + MarkupTextLiteral - [14..15)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [15..18)::3 + MarkupLiteralAttributeValue - [15..18)::3 - [Foo] + MarkupTextLiteral - [15..18)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes5.cspans.txt new file mode 100644 index 0000000000..680860b7d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes5.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (17:0,17 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (21:0,21 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [22] ) +Code span at (24:0,24 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes5.stree.txt new file mode 100644 index 0000000000..51a3ab853e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes5.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..25)::25 - [@{}] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + MarkupBlock - [2..24)::22 + MarkupElement - [2..24)::22 + MarkupStartTag - [2..24)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..21)::17 - [ *something='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..15)::10 - [*something] - Gen - SpanEditHandler;Accepts:Any + Text;[*something]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [17..20)::3 + MarkupLiteralAttributeValue - [17..20)::3 - [Foo] + MarkupTextLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [20..21)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [21..22)::1 + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes6.cspans.txt new file mode 100644 index 0000000000..10b7d1d16f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes6.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (4:0,4 [9] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [13] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [13] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [13] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [18] ) +Code span at (20:0,20 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes6.stree.txt new file mode 100644 index 0000000000..c257aeddef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes6.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..21)::21 - [@{}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..20)::18 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..17)::13 - [ #local='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..11)::6 - [#local] - Gen - SpanEditHandler;Accepts:Any + Text;[#local]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [Foo] + MarkupTextLiteral - [13..16)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace1.cspans.txt new file mode 100644 index 0000000000..a20afccd16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace1.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [35] ) +Markup span at (4:0,4 [11] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (15:1,2 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (18:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (19:1,6 [11] ) (Accepts:Any) - Parent: Markup block at (19:1,6 [15] ) +Markup span at (30:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (19:1,6 [15] ) +Markup span at (33:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (19:1,6 [15] ) +Markup span at (34:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [35] ) +Code span at (37:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (37:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace1.stree.txt new file mode 100644 index 0000000000..2dd3fffe2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace1.stree.txt @@ -0,0 +1,63 @@ +RazorDocument - [0..38)::38 - [@{}] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpStatement - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..37)::35 + MarkupBlock - [2..37)::35 + MarkupElement - [2..37)::35 + MarkupStartTag - [2..37)::35 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..19)::15 - [ [item]LF='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..11)::6 - [[item]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[item]; + RightBracket;[]]; + MarkupTextLiteral - [11..13)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [14..15)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [15..18)::3 + MarkupLiteralAttributeValue - [15..18)::3 - [Foo] + MarkupTextLiteral - [15..18)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [19..34)::15 - [ [item]=LF'Bar'] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..26)::6 - [[item]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[item]; + RightBracket;[]]; + Equals;[=]; + MarkupTextLiteral - [27..30)::3 - [LF'] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [30..33)::3 + MarkupLiteralAttributeValue - [30..33)::3 - [Bar] + MarkupTextLiteral - [30..33)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [33..34)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [34..35)::1 + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [37..37)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace2.cspans.txt new file mode 100644 index 0000000000..83bb3afe4d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace2.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [37] ) +Markup span at (4:0,4 [12] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [16] ) +Markup span at (16:1,2 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [16] ) +Markup span at (19:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [16] ) +Markup span at (20:1,6 [12] ) (Accepts:Any) - Parent: Markup block at (20:1,6 [16] ) +Markup span at (32:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (20:1,6 [16] ) +Markup span at (35:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (20:1,6 [16] ) +Markup span at (36:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [37] ) +Code span at (39:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (39:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (40:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace2.stree.txt new file mode 100644 index 0000000000..c020e7c836 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace2.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..40)::40 - [@{}] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..39)::37 + MarkupBlock - [2..39)::37 + MarkupElement - [2..39)::37 + MarkupStartTag - [2..39)::37 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..20)::16 - [ [(item,LF='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..12)::7 - [[(item,] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[(item,]; + MarkupTextLiteral - [12..14)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [Foo] + MarkupTextLiteral - [16..19)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [20..36)::16 - [ [(item,=LF'Bar'] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..28)::7 - [[(item,] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[(item,]; + Equals;[=]; + MarkupTextLiteral - [29..32)::3 - [LF'] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [32..35)::3 + MarkupLiteralAttributeValue - [32..35)::3 - [Bar] + MarkupTextLiteral - [32..35)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [36..37)::1 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [39..40)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace3.cspans.txt new file mode 100644 index 0000000000..83bb3afe4d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace3.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [37] ) +Markup span at (4:0,4 [12] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [16] ) +Markup span at (16:1,2 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [16] ) +Markup span at (19:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [16] ) +Markup span at (20:1,6 [12] ) (Accepts:Any) - Parent: Markup block at (20:1,6 [16] ) +Markup span at (32:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (20:1,6 [16] ) +Markup span at (35:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (20:1,6 [16] ) +Markup span at (36:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [37] ) +Code span at (39:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (39:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (40:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace3.stree.txt new file mode 100644 index 0000000000..403687e9a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace3.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..40)::40 - [@{}] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..39)::37 + MarkupBlock - [2..39)::37 + MarkupElement - [2..39)::37 + MarkupStartTag - [2..39)::37 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..20)::16 - [ (click)LF='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..12)::7 - [(click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(click)]; + MarkupTextLiteral - [12..14)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [Foo] + MarkupTextLiteral - [16..19)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [20..36)::16 - [ (click)=LF'Bar'] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..28)::7 - [(click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(click)]; + Equals;[=]; + MarkupTextLiteral - [29..32)::3 - [LF'] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [32..35)::3 + MarkupLiteralAttributeValue - [32..35)::3 - [Bar] + MarkupTextLiteral - [32..35)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [36..37)::1 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [39..40)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace4.cspans.txt new file mode 100644 index 0000000000..fbac8eaab7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace4.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [39] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (17:1,2 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (20:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (21:1,6 [13] ) (Accepts:Any) - Parent: Markup block at (21:1,6 [17] ) +Markup span at (34:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (21:1,6 [17] ) +Markup span at (37:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (21:1,6 [17] ) +Markup span at (38:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [39] ) +Code span at (41:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (41:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (42:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace4.stree.txt new file mode 100644 index 0000000000..3a677aa3db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace4.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..42)::42 - [@{}] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpStatement - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..42)::41 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..41)::39 + MarkupBlock - [2..41)::39 + MarkupElement - [2..41)::39 + MarkupStartTag - [2..41)::39 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..21)::17 - [ (^click)LF='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..13)::8 - [(^click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(^click)]; + MarkupTextLiteral - [13..15)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [17..20)::3 + MarkupLiteralAttributeValue - [17..20)::3 - [Foo] + MarkupTextLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [20..21)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [21..38)::17 - [ (^click)=LF'Bar'] + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [22..30)::8 - [(^click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(^click)]; + Equals;[=]; + MarkupTextLiteral - [31..34)::3 - [LF'] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [34..37)::3 + MarkupLiteralAttributeValue - [34..37)::3 - [Bar] + MarkupTextLiteral - [34..37)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [38..39)::1 + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace5.cspans.txt new file mode 100644 index 0000000000..38ddcc3004 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace5.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [43] ) +Markup span at (4:0,4 [15] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (19:1,2 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (22:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (23:1,6 [15] ) (Accepts:Any) - Parent: Markup block at (23:1,6 [19] ) +Markup span at (38:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (23:1,6 [19] ) +Markup span at (41:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (23:1,6 [19] ) +Markup span at (42:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [43] ) +Code span at (45:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (45:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (46:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace5.stree.txt new file mode 100644 index 0000000000..4b9f7e3f7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace5.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..46)::46 - [@{}] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpStatement - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..46)::45 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + MarkupBlock - [2..45)::43 + MarkupElement - [2..45)::43 + MarkupStartTag - [2..45)::43 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..23)::19 - [ *somethingLF='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..15)::10 - [*something] - Gen - SpanEditHandler;Accepts:Any + Text;[*something]; + MarkupTextLiteral - [15..17)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [19..22)::3 + MarkupLiteralAttributeValue - [19..22)::3 - [Foo] + MarkupTextLiteral - [19..22)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [23..42)::19 - [ *something=LF'Bar'] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..34)::10 - [*something] - Gen - SpanEditHandler;Accepts:Any + Text;[*something]; + Equals;[=]; + MarkupTextLiteral - [35..38)::3 - [LF'] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [38..41)::3 + MarkupLiteralAttributeValue - [38..41)::3 - [Bar] + MarkupTextLiteral - [38..41)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [41..42)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [42..43)::1 + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace6.cspans.txt new file mode 100644 index 0000000000..a20afccd16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace6.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [35] ) +Markup span at (4:0,4 [11] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (15:1,2 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (18:1,5 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [15] ) +Markup span at (19:1,6 [11] ) (Accepts:Any) - Parent: Markup block at (19:1,6 [15] ) +Markup span at (30:2,1 [3] ) (Accepts:Any) - Parent: Markup block at (19:1,6 [15] ) +Markup span at (33:2,4 [1] ) (Accepts:Any) - Parent: Markup block at (19:1,6 [15] ) +Markup span at (34:2,5 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [35] ) +Code span at (37:2,8 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (37:2,8 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:2,9 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace6.stree.txt new file mode 100644 index 0000000000..bf93ad7e28 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_BeforeEqualWhitespace6.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..38)::38 - [@{}] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpStatement - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..37)::35 + MarkupBlock - [2..37)::35 + MarkupElement - [2..37)::35 + MarkupStartTag - [2..37)::35 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..19)::15 - [ #localLF='Foo'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..11)::6 - [#local] - Gen - SpanEditHandler;Accepts:Any + Text;[#local]; + MarkupTextLiteral - [11..13)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Equals;[=]; + MarkupTextLiteral - [14..15)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [15..18)::3 + MarkupLiteralAttributeValue - [15..18)::3 - [Foo] + MarkupTextLiteral - [15..18)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [19..34)::15 - [ #local=LF'Bar'] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..26)::6 - [#local] - Gen - SpanEditHandler;Accepts:Any + Text;[#local]; + Equals;[=]; + MarkupTextLiteral - [27..30)::3 - [LF'] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + SingleQuote;[']; + GenericBlock - [30..33)::3 + MarkupLiteralAttributeValue - [30..33)::3 - [Bar] + MarkupTextLiteral - [30..33)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [33..34)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [34..35)::1 + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [37..37)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace1.cspans.txt new file mode 100644 index 0000000000..58b825a092 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace1.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [37] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (17:1,10 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (20:1,13 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (21:1,14 [11] ) (Accepts:Any) - Parent: Markup block at (21:1,14 [15] ) +Markup span at (32:2,8 [3] ) (Accepts:Any) - Parent: Markup block at (21:1,14 [15] ) +Markup span at (35:2,11 [1] ) (Accepts:Any) - Parent: Markup block at (21:1,14 [15] ) +Markup span at (36:2,12 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [37] ) +Code span at (39:2,15 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (39:2,15 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (40:2,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace1.stree.txt new file mode 100644 index 0000000000..241683bef1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace1.stree.txt @@ -0,0 +1,63 @@ +RazorDocument - [0..40)::40 - [@{}] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..39)::37 + MarkupBlock - [2..39)::37 + MarkupElement - [2..39)::37 + MarkupStartTag - [2..39)::37 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..21)::17 - [ LF [item]='Foo'] + MarkupTextLiteral - [4..9)::5 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [9..15)::6 - [[item]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[item]; + RightBracket;[]]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [17..20)::3 + MarkupLiteralAttributeValue - [17..20)::3 - [Foo] + MarkupTextLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [20..21)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [21..36)::15 - [ LF[item]='Bar'] + MarkupTextLiteral - [21..24)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [24..30)::6 - [[item]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[item]; + RightBracket;[]]; + Equals;[=]; + MarkupTextLiteral - [31..32)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [32..35)::3 + MarkupLiteralAttributeValue - [32..35)::3 - [Bar] + MarkupTextLiteral - [32..35)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [36..37)::1 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [39..40)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace2.cspans.txt new file mode 100644 index 0000000000..a3d8894755 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace2.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [39] ) +Markup span at (4:0,4 [14] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (18:1,11 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (21:1,14 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (22:1,15 [12] ) (Accepts:Any) - Parent: Markup block at (22:1,15 [16] ) +Markup span at (34:2,9 [3] ) (Accepts:Any) - Parent: Markup block at (22:1,15 [16] ) +Markup span at (37:2,12 [1] ) (Accepts:Any) - Parent: Markup block at (22:1,15 [16] ) +Markup span at (38:2,13 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [39] ) +Code span at (41:2,16 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (41:2,16 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (42:2,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace2.stree.txt new file mode 100644 index 0000000000..993f446d3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace2.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..42)::42 - [@{}] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpStatement - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..42)::41 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..41)::39 + MarkupBlock - [2..41)::39 + MarkupElement - [2..41)::39 + MarkupStartTag - [2..41)::39 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..22)::18 - [ LF [(item,='Foo'] + MarkupTextLiteral - [4..9)::5 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [9..16)::7 - [[(item,] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[(item,]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [18..21)::3 + MarkupLiteralAttributeValue - [18..21)::3 - [Foo] + MarkupTextLiteral - [18..21)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [22..38)::16 - [ LF[(item,='Bar'] + MarkupTextLiteral - [22..25)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [25..32)::7 - [[(item,] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[(item,]; + Equals;[=]; + MarkupTextLiteral - [33..34)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [34..37)::3 + MarkupLiteralAttributeValue - [34..37)::3 - [Bar] + MarkupTextLiteral - [34..37)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [38..39)::1 + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace3.cspans.txt new file mode 100644 index 0000000000..a3d8894755 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace3.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [39] ) +Markup span at (4:0,4 [14] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (18:1,11 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (21:1,14 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [18] ) +Markup span at (22:1,15 [12] ) (Accepts:Any) - Parent: Markup block at (22:1,15 [16] ) +Markup span at (34:2,9 [3] ) (Accepts:Any) - Parent: Markup block at (22:1,15 [16] ) +Markup span at (37:2,12 [1] ) (Accepts:Any) - Parent: Markup block at (22:1,15 [16] ) +Markup span at (38:2,13 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [39] ) +Code span at (41:2,16 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (41:2,16 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (42:2,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace3.stree.txt new file mode 100644 index 0000000000..09be6b80eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace3.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..42)::42 - [@{}] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpStatement - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..42)::41 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..41)::39 + MarkupBlock - [2..41)::39 + MarkupElement - [2..41)::39 + MarkupStartTag - [2..41)::39 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..22)::18 - [ LF (click)='Foo'] + MarkupTextLiteral - [4..9)::5 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [9..16)::7 - [(click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(click)]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [18..21)::3 + MarkupLiteralAttributeValue - [18..21)::3 - [Foo] + MarkupTextLiteral - [18..21)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [22..38)::16 - [ LF(click)='Bar'] + MarkupTextLiteral - [22..25)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [25..32)::7 - [(click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(click)]; + Equals;[=]; + MarkupTextLiteral - [33..34)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [34..37)::3 + MarkupLiteralAttributeValue - [34..37)::3 - [Bar] + MarkupTextLiteral - [34..37)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [38..39)::1 + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace4.cspans.txt new file mode 100644 index 0000000000..294e7d4526 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace4.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [41] ) +Markup span at (4:0,4 [15] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (19:1,12 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (22:1,15 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [19] ) +Markup span at (23:1,16 [13] ) (Accepts:Any) - Parent: Markup block at (23:1,16 [17] ) +Markup span at (36:2,10 [3] ) (Accepts:Any) - Parent: Markup block at (23:1,16 [17] ) +Markup span at (39:2,13 [1] ) (Accepts:Any) - Parent: Markup block at (23:1,16 [17] ) +Markup span at (40:2,14 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [41] ) +Code span at (43:2,17 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [44] ) +MetaCode span at (43:2,17 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Markup span at (44:2,18 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace4.stree.txt new file mode 100644 index 0000000000..9024fc2d73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace4.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..44)::44 - [@{}] + MarkupBlock - [0..44)::44 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + CSharpStatement - [0..44)::44 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..44)::43 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..43)::41 + MarkupBlock - [2..43)::41 + MarkupElement - [2..43)::41 + MarkupStartTag - [2..43)::41 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..23)::19 - [ LF (^click)='Foo'] + MarkupTextLiteral - [4..9)::5 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [9..17)::8 - [(^click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(^click)]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [19..22)::3 + MarkupLiteralAttributeValue - [19..22)::3 - [Foo] + MarkupTextLiteral - [19..22)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [23..40)::17 - [ LF(^click)='Bar'] + MarkupTextLiteral - [23..26)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [26..34)::8 - [(^click)] - Gen - SpanEditHandler;Accepts:Any + Text;[(^click)]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [36..39)::3 + MarkupLiteralAttributeValue - [36..39)::3 - [Bar] + MarkupTextLiteral - [36..39)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [39..40)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [40..41)::1 + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace5.cspans.txt new file mode 100644 index 0000000000..3c145a8469 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace5.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [45] ) +Markup span at (4:0,4 [17] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [21] ) +Markup span at (21:1,14 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [21] ) +Markup span at (24:1,17 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [21] ) +Markup span at (25:1,18 [15] ) (Accepts:Any) - Parent: Markup block at (25:1,18 [19] ) +Markup span at (40:2,12 [3] ) (Accepts:Any) - Parent: Markup block at (25:1,18 [19] ) +Markup span at (43:2,15 [1] ) (Accepts:Any) - Parent: Markup block at (25:1,18 [19] ) +Markup span at (44:2,16 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [45] ) +Code span at (47:2,19 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) +MetaCode span at (47:2,19 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (48:2,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace5.stree.txt new file mode 100644 index 0000000000..6ab9b95ff0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace5.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..48)::48 - [@{}] + MarkupBlock - [0..48)::48 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..48)::48 + CSharpStatement - [0..48)::48 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..48)::47 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..47)::45 + MarkupBlock - [2..47)::45 + MarkupElement - [2..47)::45 + MarkupStartTag - [2..47)::45 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..25)::21 - [ LF *something='Foo'] + MarkupTextLiteral - [4..9)::5 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [9..19)::10 - [*something] - Gen - SpanEditHandler;Accepts:Any + Text;[*something]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [Foo] + MarkupTextLiteral - [21..24)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [25..44)::19 - [ LF*something='Bar'] + MarkupTextLiteral - [25..28)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [28..38)::10 - [*something] - Gen - SpanEditHandler;Accepts:Any + Text;[*something]; + Equals;[=]; + MarkupTextLiteral - [39..40)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [40..43)::3 + MarkupLiteralAttributeValue - [40..43)::3 - [Bar] + MarkupTextLiteral - [40..43)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [43..44)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [44..45)::1 + MarkupTextLiteral - [44..45)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [47..48)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [48..48)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace6.cspans.txt new file mode 100644 index 0000000000..58b825a092 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace6.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [37] ) +Markup span at (4:0,4 [13] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (17:1,10 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (20:1,13 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [17] ) +Markup span at (21:1,14 [11] ) (Accepts:Any) - Parent: Markup block at (21:1,14 [15] ) +Markup span at (32:2,8 [3] ) (Accepts:Any) - Parent: Markup block at (21:1,14 [15] ) +Markup span at (35:2,11 [1] ) (Accepts:Any) - Parent: Markup block at (21:1,14 [15] ) +Markup span at (36:2,12 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [37] ) +Code span at (39:2,15 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [40] ) +MetaCode span at (39:2,15 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [40] ) +Markup span at (40:2,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace6.stree.txt new file mode 100644 index 0000000000..d60bd00437 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/SymbolBoundAttributes_Whitespace6.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..40)::40 - [@{}] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..40)::40 + CSharpStatement - [0..40)::40 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..40)::39 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..39)::37 + MarkupBlock - [2..39)::37 + MarkupElement - [2..39)::37 + MarkupStartTag - [2..39)::37 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..21)::17 - [ LF #local='Foo'] + MarkupTextLiteral - [4..9)::5 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupTextLiteral - [9..15)::6 - [#local] - Gen - SpanEditHandler;Accepts:Any + Text;[#local]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [17..20)::3 + MarkupLiteralAttributeValue - [17..20)::3 - [Foo] + MarkupTextLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [20..21)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [21..36)::15 - [ LF#local='Bar'] + MarkupTextLiteral - [21..24)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [24..30)::6 - [#local] - Gen - SpanEditHandler;Accepts:Any + Text;[#local]; + Equals;[=]; + MarkupTextLiteral - [31..32)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [32..35)::3 + MarkupLiteralAttributeValue - [32..35)::3 - [Bar] + MarkupTextLiteral - [32..35)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [36..37)::1 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [39..40)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInBlock.cspans.txt new file mode 100644 index 0000000000..5869ff5ca4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInBlock.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (2:0,2 [6] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [20] ) +Markup span at (8:0,8 [7] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [11] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [4] ) +Code span at (16:0,16 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (15:0,15 [4] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [20] ) +Code span at (22:0,22 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInBlock.stree.txt new file mode 100644 index 0000000000..0afdde8d78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInBlock.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..23)::23 - [@{}] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupElement - [2..22)::20 + MarkupStartTag - [2..22)::20 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupAttributeBlock - [8..19)::11 - [ value=@foo] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [value] - Gen - SpanEditHandler;Accepts:Any + Text;[value]; + Equals;[=]; + GenericBlock - [15..19)::4 + MarkupDynamicAttributeValue - [15..19)::4 - [@foo] + GenericBlock - [15..19)::4 + CSharpCodeBlock - [15..19)::4 + CSharpImplicitExpression - [15..19)::4 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [16..19)::3 + CSharpCodeBlock - [16..19)::3 + CSharpExpressionLiteral - [16..19)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInDocument.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInDocument.cspans.txt new file mode 100644 index 0000000000..764f3bb0e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInDocument.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [20] ) +Markup span at (6:0,6 [7] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [11] ) +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Expression block at (13:0,13 [4] ) +Code span at (14:0,14 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (13:0,13 [4] ) +Markup span at (17:0,17 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [20] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInDocument.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInDocument.stree.txt new file mode 100644 index 0000000000..cd4499af20 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedAttributeWithCodeWithSpacesInDocument.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..21)::21 - [}] + MarkupBlock - [0..21)::21 + MarkupElement - [0..20)::20 + MarkupStartTag - [0..20)::20 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupAttributeBlock - [6..17)::11 - [ value=@foo] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [value] - Gen - SpanEditHandler;Accepts:Any + Text;[value]; + Equals;[=]; + GenericBlock - [13..17)::4 + MarkupDynamicAttributeValue - [13..17)::4 - [@foo] + GenericBlock - [13..17)::4 + CSharpCodeBlock - [13..17)::4 + CSharpImplicitExpression - [13..17)::4 + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [14..17)::3 + CSharpCodeBlock - [14..17)::3 + CSharpExpressionLiteral - [14..17)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [20..21)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedLiteralAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedLiteralAttribute.cspans.txt new file mode 100644 index 0000000000..ea9b1b25c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedLiteralAttribute.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [22] ) +Markup span at (4:0,4 [6] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [9] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [9] ) +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Markup block at (13:0,13 [4] ) +Markup span at (17:0,17 [4] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [4] ) +Markup span at (21:0,21 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [22] ) +Code span at (24:0,24 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedLiteralAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedLiteralAttribute.stree.txt new file mode 100644 index 0000000000..f080505b4b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/UnquotedLiteralAttribute.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..25)::25 - [@{}] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + MarkupBlock - [2..24)::22 + MarkupElement - [2..24)::22 + MarkupStartTag - [2..24)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..13)::9 - [ href=Foo] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + GenericBlock - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [Foo] + MarkupTextLiteral - [10..13)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupMinimizedAttributeBlock - [13..17)::4 - [ Bar] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..17)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupMinimizedAttributeBlock - [17..21)::4 - [ Baz] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..21)::3 - [Baz] - Gen - SpanEditHandler;Accepts:Any + Text;[Baz]; + MarkupMiscAttributeContent - [21..22)::1 + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/VirtualPathAttributesWorkWithConditionalAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/VirtualPathAttributesWorkWithConditionalAttributes.cspans.txt new file mode 100644 index 0000000000..0fa9f90bf0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/VirtualPathAttributesWorkWithConditionalAttributes.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [27] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [22] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [4] ) +Code span at (12:0,12 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (11:0,11 [4] ) +Markup span at (15:0,15 [10] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [22] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [22] ) +Markup span at (26:0,26 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [27] ) +Code span at (29:0,29 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/VirtualPathAttributesWorkWithConditionalAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/VirtualPathAttributesWorkWithConditionalAttributes.stree.txt new file mode 100644 index 0000000000..6d3e5ff327 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/VirtualPathAttributesWorkWithConditionalAttributes.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..30)::30 - [@{}] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpStatement - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..30)::29 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..29)::27 + MarkupBlock - [2..29)::27 + MarkupElement - [2..29)::27 + MarkupStartTag - [2..29)::27 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..26)::22 - [ href='@foo ~/Foo/Bar'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..25)::14 + MarkupDynamicAttributeValue - [11..15)::4 - [@foo] + GenericBlock - [11..15)::4 + CSharpCodeBlock - [11..15)::4 + CSharpImplicitExpression - [11..15)::4 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [12..15)::3 + CSharpCodeBlock - [12..15)::3 + CSharpExpressionLiteral - [12..15)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupLiteralAttributeValue - [15..25)::10 - [ ~/Foo/Bar] + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [16..25)::9 - [~/Foo/Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[~]; + ForwardSlash;[/]; + Text;[Foo]; + ForwardSlash;[/]; + Text;[Bar]; + MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [26..27)::1 + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/WhitespaceAndNewLinePrecedingAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/WhitespaceAndNewLinePrecedingAttribute.cspans.txt new file mode 100644 index 0000000000..0a74de6c35 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/WhitespaceAndNewLinePrecedingAttribute.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [10] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (14:1,6 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (17:1,9 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [14] ) +Markup span at (18:1,10 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Code span at (21:1,13 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:1,13 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:1,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/WhitespaceAndNewLinePrecedingAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/WhitespaceAndNewLinePrecedingAttribute.stree.txt new file mode 100644 index 0000000000..c0f11eea56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/WhitespaceAndNewLinePrecedingAttribute.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..22)::22 - [@{}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupElement - [2..21)::19 + MarkupStartTag - [2..21)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..18)::14 - [ LFhref='Foo'] + MarkupTextLiteral - [4..8)::4 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupTextLiteral - [8..12)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [14..17)::3 + MarkupLiteralAttributeValue - [14..17)::3 - [Foo] + MarkupTextLiteral - [14..17)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [18..19)::1 + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsEmptyTextTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsEmptyTextTag.cspans.txt new file mode 100644 index 0000000000..0bd53ac932 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsEmptyTextTag.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Transition span at (2:0,2 [7] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Code span at (9:0,9 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsEmptyTextTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsEmptyTextTag.stree.txt new file mode 100644 index 0000000000..1d3c357c03 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsEmptyTextTag.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..10)::10 - [@{}] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + MarkupBlock - [2..9)::7 + MarkupElement - [2..9)::7 + MarkupStartTag - [2..9)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [9..9)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsTextTagAsOuterTagButDoesNotRender.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsTextTagAsOuterTagButDoesNotRender.cspans.txt new file mode 100644 index 0000000000..07d11db795 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsTextTagAsOuterTagButDoesNotRender.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [30] ) +Markup span at (16:0,16 [5] ) (Accepts:None) - Parent: Tag block at (16:0,16 [5] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [30] ) +Transition span at (25:0,25 [7] ) (Accepts:None) - Parent: Tag block at (25:0,25 [7] ) +Code span at (32:0,32 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [38] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [38] ) +Markup span at (38:0,38 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsTextTagAsOuterTagButDoesNotRender.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsTextTagAsOuterTagButDoesNotRender.stree.txt new file mode 100644 index 0000000000..59086b2f9a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AcceptsTextTagAsOuterTagButDoesNotRender.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..38)::38 - [@{Foo Bar Baz zoop}] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..38)::38 + CSharpStatement - [0..38)::38 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..38)::37 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..37)::35 + MarkupBlock - [2..32)::30 + MarkupElement - [2..32)::30 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [8..16)::8 - [Foo Bar ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[Bar]; + Whitespace;[ ]; + MarkupElement - [16..25)::9 + MarkupStartTag - [16..21)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [21..25)::4 - [ Baz] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Baz]; + MarkupEndTag - [25..32)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..37)::5 - [ zoop] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Identifier;[zoop]; + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted.cspans.txt new file mode 100644 index 0000000000..2573b6dc22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [4] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [15] ) +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (7:0,7 [15] ) +Markup span at (22:0,22 [6] ) (Accepts:None) - Parent: Tag block at (22:0,22 [6] ) +Code span at (28:0,28 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted.stree.txt new file mode 100644 index 0000000000..032272b7d4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..29)::29 - [@{}] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpStatement - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..29)::28 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..28)::26 + MarkupBlock - [2..28)::26 + MarkupElement - [2..28)::26 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..22)::15 + MarkupStartTag - [7..22)::15 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + MarkupAttributeBlock - [11..19)::8 - [ baz=">"] + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [12..15)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [17..18)::1 + MarkupLiteralAttributeValue - [17..18)::1 - [>] + MarkupTextLiteral - [17..18)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupEndTag - [22..28)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfSingleQuoted.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfSingleQuoted.cspans.txt new file mode 100644 index 0000000000..2573b6dc22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfSingleQuoted.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [4] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [15] ) +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: Tag block at (7:0,7 [15] ) +Markup span at (22:0,22 [6] ) (Accepts:None) - Parent: Tag block at (22:0,22 [6] ) +Code span at (28:0,28 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfSingleQuoted.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfSingleQuoted.stree.txt new file mode 100644 index 0000000000..167959449b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsCloseAngleBracketInAttributeValueIfSingleQuoted.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..29)::29 - [@{}] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpStatement - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..29)::28 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..28)::26 + MarkupBlock - [2..28)::26 + MarkupElement - [2..28)::26 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..22)::15 + MarkupStartTag - [7..22)::15 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + MarkupAttributeBlock - [11..19)::8 - [ baz='>'] + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [12..15)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [17..18)::1 + MarkupLiteralAttributeValue - [17..18)::1 - [>] + MarkupTextLiteral - [17..18)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupEndTag - [22..28)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfDoubleQuoted.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfDoubleQuoted.cspans.txt new file mode 100644 index 0000000000..8fee8f2662 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfDoubleQuoted.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [4] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [13] ) +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (19:0,19 [1] ) (Accepts:None) - Parent: Tag block at (7:0,7 [13] ) +Markup span at (20:0,20 [6] ) (Accepts:None) - Parent: Tag block at (20:0,20 [6] ) +Markup span at (26:0,26 [6] ) (Accepts:None) - Parent: Tag block at (26:0,26 [6] ) +Code span at (32:0,32 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfDoubleQuoted.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfDoubleQuoted.stree.txt new file mode 100644 index 0000000000..71b793bf6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfDoubleQuoted.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..33)::33 - [@{}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + CSharpStatement - [0..33)::33 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..33)::32 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..32)::30 + MarkupBlock - [2..32)::30 + MarkupElement - [2..32)::30 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..26)::19 + MarkupStartTag - [7..20)::13 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + MarkupAttributeBlock - [11..19)::8 - [ baz="/"] + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [12..15)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [17..18)::1 + MarkupLiteralAttributeValue - [17..18)::1 - [/] + MarkupTextLiteral - [17..18)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupEndTag - [20..26)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[bar]; + CloseAngle;[>]; + MarkupEndTag - [26..32)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfSingleQuoted.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfSingleQuoted.cspans.txt new file mode 100644 index 0000000000..8fee8f2662 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfSingleQuoted.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [4] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [13] ) +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (11:0,11 [8] ) +Markup span at (19:0,19 [1] ) (Accepts:None) - Parent: Tag block at (7:0,7 [13] ) +Markup span at (20:0,20 [6] ) (Accepts:None) - Parent: Tag block at (20:0,20 [6] ) +Markup span at (26:0,26 [6] ) (Accepts:None) - Parent: Tag block at (26:0,26 [6] ) +Code span at (32:0,32 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfSingleQuoted.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfSingleQuoted.stree.txt new file mode 100644 index 0000000000..91929b7c24 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsSlashInAttributeValueIfSingleQuoted.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..33)::33 - [@{}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + CSharpStatement - [0..33)::33 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..33)::32 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..32)::30 + MarkupBlock - [2..32)::30 + MarkupElement - [2..32)::30 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..26)::19 + MarkupStartTag - [7..20)::13 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + MarkupAttributeBlock - [11..19)::8 - [ baz='/'] + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [12..15)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [17..18)::1 + MarkupLiteralAttributeValue - [17..18)::1 - [/] + MarkupTextLiteral - [17..18)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [20..26)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[bar]; + CloseAngle;[>]; + MarkupEndTag - [26..32)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsStartAndEndTagsToDifferInCase.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsStartAndEndTagsToDifferInCase.cspans.txt new file mode 100644 index 0000000000..f7d0febda1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsStartAndEndTagsToDifferInCase.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [4] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (6:0,6 [3] ) (Accepts:None) - Parent: Tag block at (6:0,6 [3] ) +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: Tag block at (12:0,12 [4] ) +Markup span at (16:0,16 [5] ) (Accepts:None) - Parent: Tag block at (16:0,16 [5] ) +Code span at (21:0,21 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsStartAndEndTagsToDifferInCase.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsStartAndEndTagsToDifferInCase.stree.txt new file mode 100644 index 0000000000..39206aa1d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsStartAndEndTagsToDifferInCase.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..22)::22 - [@{
                  • Foo

                  • }] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupElement - [2..21)::19 + MarkupStartTag - [2..6)::4 - [
                  • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + MarkupElement - [6..16)::10 + MarkupStartTag - [6..9)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [9..12)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [12..16)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[P]; + CloseAngle;[>]; + MarkupEndTag - [16..21)::5 - [
                  • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[lI]; + CloseAngle;[>]; + CSharpStatementLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag.cspans.txt new file mode 100644 index 0000000000..755c699fd4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [5] ) (Accepts:None) - Parent: Tag block at (7:0,7 [5] ) +Markup span at (12:0,12 [5] ) (Accepts:None) - Parent: Tag block at (12:0,12 [5] ) +Markup span at (17:0,17 [6] ) (Accepts:None) - Parent: Tag block at (17:0,17 [6] ) +Code span at (23:0,23 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag.stree.txt new file mode 100644 index 0000000000..977c4f3c70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..24)::24 - [@{}] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + MarkupBlock - [2..23)::21 + MarkupElement - [2..23)::21 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..17)::10 + MarkupStartTag - [7..12)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + CloseAngle;[>]; + MarkupElement - [12..17)::5 + MarkupStartTag - [12..17)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[baz]; + CloseAngle;[>]; + MarkupEndTag - [17..23)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CanHandleSelfClosingTagsWithinBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CanHandleSelfClosingTagsWithinBlock.cspans.txt new file mode 100644 index 0000000000..815df70ed1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CanHandleSelfClosingTagsWithinBlock.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [7] ) (Accepts:None) - Parent: Tag block at (7:0,7 [7] ) +Markup span at (14:0,14 [6] ) (Accepts:None) - Parent: Tag block at (14:0,14 [6] ) +Code span at (20:0,20 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CanHandleSelfClosingTagsWithinBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CanHandleSelfClosingTagsWithinBlock.stree.txt new file mode 100644 index 0000000000..589ca4a47b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CanHandleSelfClosingTagsWithinBlock.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..21)::21 - [@{}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..14)::7 + MarkupStartTag - [7..14)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + MarkupMiscAttributeContent - [11..12)::1 + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupEndTag - [14..20)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.cspans.txt new file mode 100644 index 0000000000..8f124b66de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [31] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Statement block at (11:0,11 [12] ) +Code span at (12:0,12 [11] ) (Accepts:Any) - Parent: Statement block at (11:0,11 [12] ) +Markup span at (23:0,23 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [31] ) +Markup span at (27:0,27 [6] ) (Accepts:None) - Parent: Tag block at (27:0,27 [6] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.stree.txt new file mode 100644 index 0000000000..27ac92cec8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..34)::34 - [@{
                    Foo @if(true) {} Bar
                    }] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..11)::4 - [Foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + CSharpCodeBlock - [11..23)::12 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [12..23)::11 - [if(true) {}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + RightBrace;[}]; + MarkupTextLiteral - [23..27)::4 - [ Bar] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Bar]; + MarkupEndTag - [27..33)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotConsiderPsuedoTagWithinMarkupBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotConsiderPsuedoTagWithinMarkupBlock.cspans.txt new file mode 100644 index 0000000000..63a6914d4e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotConsiderPsuedoTagWithinMarkupBlock.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [6] ) (Accepts:None) - Parent: Tag block at (7:0,7 [6] ) +Markup span at (13:0,13 [5] ) (Accepts:None) - Parent: Tag block at (13:0,13 [5] ) +Markup span at (18:0,18 [6] ) (Accepts:None) - Parent: Tag block at (18:0,18 [6] ) +Markup span at (24:0,24 [6] ) (Accepts:None) - Parent: Tag block at (24:0,24 [6] ) +Code span at (30:0,30 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (31:0,31 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotConsiderPsuedoTagWithinMarkupBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotConsiderPsuedoTagWithinMarkupBlock.stree.txt new file mode 100644 index 0000000000..3efea968b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotConsiderPsuedoTagWithinMarkupBlock.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..31)::31 - [@{}] + MarkupBlock - [0..31)::31 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + CSharpStatement - [0..31)::31 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..31)::30 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + MarkupBlock - [2..30)::28 + MarkupElement - [2..30)::28 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..24)::17 + MarkupStartTag - [7..13)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupElement - [13..24)::11 + MarkupStartTag - [13..18)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[bar]; + CloseAngle;[>]; + MarkupEndTag - [18..24)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[bar]; + CloseAngle;[>]; + MarkupEndTag - [24..30)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark.cspans.txt new file mode 100644 index 0000000000..4cb009f651 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [20] ) (Accepts:None) - Parent: Markup block at (2:0,2 [31] ) +Markup span at (27:0,27 [6] ) (Accepts:None) - Parent: Tag block at (27:0,27 [6] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark.stree.txt new file mode 100644 index 0000000000..2f2e4f4725 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..34)::34 - [@{ baz?>}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..27)::20 - [ baz?>] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + Text;[bar]; + CloseAngle;[>]; + Whitespace;[ ]; + Text;[baz]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupEndTag - [27..33)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesForwardSlashInAttributeContent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesForwardSlashInAttributeContent.cspans.txt new file mode 100644 index 0000000000..5f1b93ed73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesForwardSlashInAttributeContent.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (2:0,2 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [17] ) +Markup span at (6:0,6 [7] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Markup span at (16:0,16 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [17] ) +Code span at (19:0,19 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (19:0,19 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesForwardSlashInAttributeContent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesForwardSlashInAttributeContent.stree.txt new file mode 100644 index 0000000000..769a3401e6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesForwardSlashInAttributeContent.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..20)::20 - [@{

                    }] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..19)::17 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [4..5)::1 + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [5..6)::1 + MarkupTextLiteral - [5..6)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupAttributeBlock - [6..16)::10 - [ class=foo] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [foo] + MarkupTextLiteral - [13..16)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [19..20)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.cspans.txt new file mode 100644 index 0000000000..b0e0c19ca5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (4:1,0 [1] ) (Accepts:Any) - Parent: Tag block at (4:1,0 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.diag.txt new file mode 100644 index 0000000000..1b72b90879 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(2,1): Error RZ1024: End of file or an unexpected character was reached before the "" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                    ") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.stree.txt new file mode 100644 index 0000000000..93a2e245cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleAtEof.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..5)::5 - [@{LF<] + MarkupBlock - [0..5)::5 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..5)::3 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + NewLine;[LF]; + MarkupBlock - [4..5)::1 + MarkupElement - [4..5)::1 + MarkupStartTag - [4..5)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + RazorMetaCode - [5..5)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.cspans.txt new file mode 100644 index 0000000000..2a8d626589 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [14] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [14] ) +Markup span at (4:1,0 [3] ) (Accepts:Any) - Parent: Tag block at (4:1,0 [3] ) +Markup span at (7:2,0 [7] ) (Accepts:None) - Parent: Tag block at (7:2,0 [7] ) +Code span at (14:2,7 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.diag.txt new file mode 100644 index 0000000000..16d45eb0ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(2,1): Error RZ1024: End of file or an unexpected character was reached before the "" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                    ") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. +(3,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.stree.txt new file mode 100644 index 0000000000..b539423630 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesOpenAngleWithProperTagFollowingIt.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..14)::14 - [@{LF] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + CSharpStatement - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..14)::13 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + NewLine;[LF]; + MarkupBlock - [4..7)::3 + MarkupElement - [4..7)::3 + MarkupStartTag - [4..7)::3 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMiscAttributeContent - [5..7)::2 + MarkupTextLiteral - [5..7)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [7..14)::7 + MarkupElement - [7..14)::7 + MarkupEndTag - [7..14)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[html]; + CloseAngle;[>]; + CSharpStatementLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [14..14)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesUnbalancedTripleDashHTMLComments.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesUnbalancedTripleDashHTMLComments.cspans.txt new file mode 100644 index 0000000000..aaf4fd258d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesUnbalancedTripleDashHTMLComments.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [68] ) +Markup span at (4:1,0 [4] ) (Accepts:Any) - Parent: Markup block at (4:1,0 [63] ) +Markup span at (8:1,4 [4] ) (Accepts:None) - Parent: HtmlComment block at (8:1,4 [57] ) +Markup span at (12:1,8 [50] ) (Accepts:Whitespace) - Parent: HtmlComment block at (8:1,4 [57] ) +Markup span at (62:1,58 [3] ) (Accepts:None) - Parent: HtmlComment block at (8:1,4 [57] ) +Markup span at (65:1,61 [2] ) (Accepts:None) - Parent: Markup block at (4:1,0 [63] ) +Code span at (67:2,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [68] ) +MetaCode span at (67:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [68] ) +Markup span at (68:2,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesUnbalancedTripleDashHTMLComments.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesUnbalancedTripleDashHTMLComments.stree.txt new file mode 100644 index 0000000000..d6c3b6a1b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HandlesUnbalancedTripleDashHTMLComments.stree.txt @@ -0,0 +1,56 @@ +RazorDocument - [0..68)::68 - [@{LF LF}] + MarkupBlock - [0..68)::68 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..68)::68 + CSharpStatement - [0..68)::68 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..68)::67 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..67)::65 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [4..67)::63 + MarkupTextLiteral - [4..8)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupCommentBlock - [8..65)::57 + MarkupTextLiteral - [8..12)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [65..67)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [67..67)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [67..68)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [68..68)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HtmlCommentSupportsMultipleDashes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HtmlCommentSupportsMultipleDashes.cspans.txt new file mode 100644 index 0000000000..e1fed0e5a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HtmlCommentSupportsMultipleDashes.cspans.txt @@ -0,0 +1,24 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [4] ) (Accepts:None) - Parent: HtmlComment block at (5:0,5 [22] ) +Markup span at (9:0,9 [15] ) (Accepts:Whitespace) - Parent: HtmlComment block at (5:0,5 [22] ) +Markup span at (24:0,24 [3] ) (Accepts:None) - Parent: HtmlComment block at (5:0,5 [22] ) +Markup span at (27:0,27 [6] ) (Accepts:Any) - Parent: Tag block at (27:0,27 [6] ) +Markup span at (33:0,33 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [165] ) +Markup span at (35:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (35:1,0 [5] ) +Markup span at (40:1,5 [4] ) (Accepts:None) - Parent: HtmlComment block at (40:1,5 [24] ) +Markup span at (44:1,9 [17] ) (Accepts:Whitespace) - Parent: HtmlComment block at (40:1,5 [24] ) +Markup span at (61:1,26 [3] ) (Accepts:None) - Parent: HtmlComment block at (40:1,5 [24] ) +Markup span at (64:1,29 [6] ) (Accepts:Any) - Parent: Tag block at (64:1,29 [6] ) +Markup span at (70:1,35 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [165] ) +Markup span at (72:2,0 [5] ) (Accepts:Any) - Parent: Tag block at (72:2,0 [5] ) +Markup span at (77:2,5 [4] ) (Accepts:None) - Parent: HtmlComment block at (77:2,5 [26] ) +Markup span at (81:2,9 [19] ) (Accepts:Whitespace) - Parent: HtmlComment block at (77:2,5 [26] ) +Markup span at (100:2,28 [3] ) (Accepts:None) - Parent: HtmlComment block at (77:2,5 [26] ) +Markup span at (103:2,31 [6] ) (Accepts:Any) - Parent: Tag block at (103:2,31 [6] ) +Markup span at (109:2,37 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [165] ) +Markup span at (111:3,0 [5] ) (Accepts:Any) - Parent: Tag block at (111:3,0 [5] ) +Markup span at (116:3,5 [4] ) (Accepts:None) - Parent: HtmlComment block at (116:3,5 [41] ) +Markup span at (120:3,9 [34] ) (Accepts:Whitespace) - Parent: HtmlComment block at (116:3,5 [41] ) +Markup span at (154:3,43 [3] ) (Accepts:None) - Parent: HtmlComment block at (116:3,5 [41] ) +Markup span at (157:3,46 [6] ) (Accepts:Any) - Parent: Tag block at (157:3,46 [6] ) +Markup span at (163:3,52 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [165] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HtmlCommentSupportsMultipleDashes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HtmlCommentSupportsMultipleDashes.stree.txt new file mode 100644 index 0000000000..84453954c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/HtmlCommentSupportsMultipleDashes.stree.txt @@ -0,0 +1,130 @@ +RazorDocument - [0..165)::165 - [
                    LF
                    LF
                    LF
                    LF] + MarkupBlock - [0..165)::165 + MarkupElement - [0..33)::33 + MarkupStartTag - [0..5)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupCommentBlock - [5..27)::22 + MarkupTextLiteral - [5..9)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [27..33)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [33..35)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [35..70)::35 + MarkupStartTag - [35..40)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupCommentBlock - [40..64)::24 + MarkupTextLiteral - [40..44)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [64..70)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [70..72)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [72..109)::37 + MarkupStartTag - [72..77)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupCommentBlock - [77..103)::26 + MarkupTextLiteral - [77..81)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [103..109)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [109..111)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [111..163)::52 + MarkupStartTag - [111..116)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupCommentBlock - [116..157)::41 + MarkupTextLiteral - [116..120)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [157..163)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [163..165)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/IgnoresTagsInContentsOfScriptTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/IgnoresTagsInContentsOfScriptTag.cspans.txt new file mode 100644 index 0000000000..10075460db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/IgnoresTagsInContentsOfScriptTag.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Markup span at (2:0,2 [8] ) (Accepts:None) - Parent: Tag block at (2:0,2 [8] ) +Markup span at (10:0,10 [13] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [36] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Expression block at (23:0,23 [4] ) +Code span at (24:0,24 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (23:0,23 [4] ) +Markup span at (27:0,27 [2] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [36] ) +Markup span at (29:0,29 [9] ) (Accepts:None) - Parent: Tag block at (29:0,29 [9] ) +Code span at (38:0,38 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (38:0,38 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Markup span at (39:0,39 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/IgnoresTagsInContentsOfScriptTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/IgnoresTagsInContentsOfScriptTag.stree.txt new file mode 100644 index 0000000000..d90490cb93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/IgnoresTagsInContentsOfScriptTag.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..39)::39 - [@{}] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpStatement - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..39)::38 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..38)::36 + MarkupBlock - [2..38)::36 + MarkupElement - [2..38)::36 + MarkupStartTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + CSharpStatementLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [38..39)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/OnlyTerminatesCommentOnFullEndSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/OnlyTerminatesCommentOnFullEndSequence.cspans.txt new file mode 100644 index 0000000000..4ca3454d27 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/OnlyTerminatesCommentOnFullEndSequence.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (2:0,2 [4] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [20] ) +Markup span at (6:0,6 [13] ) (Accepts:Whitespace) - Parent: HtmlComment block at (2:0,2 [20] ) +Markup span at (19:0,19 [3] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [20] ) +Code span at (22:0,22 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/OnlyTerminatesCommentOnFullEndSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/OnlyTerminatesCommentOnFullEndSequence.stree.txt new file mode 100644 index 0000000000..b1bfd1c1aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/OnlyTerminatesCommentOnFullEndSequence.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..23)::23 - [@{}] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupCommentBlock - [2..22)::20 + MarkupTextLiteral - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + CSharpStatementLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesSGMLDeclarationAsEmptyTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesSGMLDeclarationAsEmptyTag.cspans.txt new file mode 100644 index 0000000000..b4f323eb1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesSGMLDeclarationAsEmptyTag.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [22] ) (Accepts:None) - Parent: Markup block at (2:0,2 [33] ) +Markup span at (29:0,29 [6] ) (Accepts:None) - Parent: Tag block at (29:0,29 [6] ) +Code span at (35:0,35 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (35:0,35 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesSGMLDeclarationAsEmptyTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesSGMLDeclarationAsEmptyTag.stree.txt new file mode 100644 index 0000000000..23ebc364be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesSGMLDeclarationAsEmptyTag.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..36)::36 - [@{}] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpStatement - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..36)::35 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..35)::33 + MarkupBlock - [2..35)::33 + MarkupElement - [2..35)::33 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..29)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[DOCTYPE]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + Text;[bar]; + Whitespace;[ ]; + Text;[baz]; + CloseAngle;[>]; + MarkupEndTag - [29..35)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [35..36)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag.cspans.txt new file mode 100644 index 0000000000..de508231ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [5] ) (Accepts:None) - Parent: Tag block at (7:0,7 [5] ) +Markup span at (12:0,12 [5] ) (Accepts:None) - Parent: Tag block at (12:0,12 [5] ) +Markup span at (17:0,17 [6] ) (Accepts:None) - Parent: Tag block at (17:0,17 [6] ) +Markup span at (23:0,23 [6] ) (Accepts:None) - Parent: Tag block at (23:0,23 [6] ) +Markup span at (29:0,29 [6] ) (Accepts:None) - Parent: Tag block at (29:0,29 [6] ) +Code span at (35:0,35 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [36] ) +MetaCode span at (35:0,35 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag.stree.txt new file mode 100644 index 0000000000..a95f5309e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..36)::36 - [@{}] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + CSharpStatement - [0..36)::36 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..36)::35 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..35)::33 + MarkupBlock - [2..35)::33 + MarkupElement - [2..35)::33 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[baz]; + CloseAngle;[>]; + MarkupElement - [7..29)::22 + MarkupStartTag - [7..12)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[boz]; + CloseAngle;[>]; + MarkupElement - [12..23)::11 + MarkupStartTag - [12..17)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[biz]; + CloseAngle;[>]; + MarkupEndTag - [17..23)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[biz]; + CloseAngle;[>]; + MarkupEndTag - [23..29)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[boz]; + CloseAngle;[>]; + MarkupEndTag - [29..35)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[baz]; + CloseAngle;[>]; + CSharpStatementLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [35..36)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesXMLProcessingInstructionAsEmptyTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesXMLProcessingInstructionAsEmptyTag.cspans.txt new file mode 100644 index 0000000000..852b239155 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesXMLProcessingInstructionAsEmptyTag.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [19] ) (Accepts:None) - Parent: Markup block at (2:0,2 [30] ) +Markup span at (26:0,26 [6] ) (Accepts:None) - Parent: Tag block at (26:0,26 [6] ) +Code span at (32:0,32 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesXMLProcessingInstructionAsEmptyTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesXMLProcessingInstructionAsEmptyTag.stree.txt new file mode 100644 index 0000000000..e9f7c9e1a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ParsesXMLProcessingInstructionAsEmptyTag.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..33)::33 - [@{}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + CSharpStatement - [0..33)::33 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..33)::32 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..32)::30 + MarkupBlock - [2..32)::30 + MarkupElement - [2..32)::30 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..26)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + Text;[bar]; + Whitespace;[ ]; + Text;[baz]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupEndTag - [26..32)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ProperlyBalancesCommentStartAndEndTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ProperlyBalancesCommentStartAndEndTags.cspans.txt new file mode 100644 index 0000000000..5c14032f92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ProperlyBalancesCommentStartAndEndTags.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [4] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [18] ) +Markup span at (6:0,6 [11] ) (Accepts:Whitespace) - Parent: HtmlComment block at (2:0,2 [18] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [18] ) +Code span at (20:0,20 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ProperlyBalancesCommentStartAndEndTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ProperlyBalancesCommentStartAndEndTags.stree.txt new file mode 100644 index 0000000000..dfc7e9d631 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ProperlyBalancesCommentStartAndEndTags.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..21)::21 - [@{}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupCommentBlock - [2..20)::18 + MarkupTextLiteral - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + CSharpStatementLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon.cspans.txt new file mode 100644 index 0000000000..3c96f3b336 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [19] ) +MetaCode span at (3:0,3 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (4:0,4 [17] ) (Accepts:None) - Parent: Markup block at (2:0,2 [19] ) +Code span at (21:1,0 [4] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (25:1,4 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (26:1,5 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon.stree.txt new file mode 100644 index 0000000000..bf557127e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..26)::26 - [@{@:
                  • Foo Bar BazLFbork}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..25)::23 + MarkupBlock - [2..21)::19 + MarkupTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [4..21)::17 - [
                  • Foo Bar BazLF] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + Text;[Foo]; + Whitespace;[ ]; + Text;[Bar]; + Whitespace;[ ]; + Text;[Baz]; + NewLine;[LF]; + CSharpStatementLiteral - [21..25)::4 - [bork] - Gen - SpanEditHandler;Accepts:Any + Identifier;[bork]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/RendersLiteralTextTagIfDoubled.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/RendersLiteralTextTagIfDoubled.cspans.txt new file mode 100644 index 0000000000..eec6718ce6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/RendersLiteralTextTagIfDoubled.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [6] ) (Accepts:None) - Parent: Tag block at (8:0,8 [6] ) +Markup span at (14:0,14 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [43] ) +Markup span at (22:0,22 [5] ) (Accepts:None) - Parent: Tag block at (22:0,22 [5] ) +Markup span at (27:0,27 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [43] ) +Markup span at (31:0,31 [7] ) (Accepts:None) - Parent: Tag block at (31:0,31 [7] ) +Transition span at (38:0,38 [7] ) (Accepts:None) - Parent: Tag block at (38:0,38 [7] ) +Code span at (45:0,45 [5] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) +MetaCode span at (50:0,50 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Markup span at (51:0,51 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/RendersLiteralTextTagIfDoubled.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/RendersLiteralTextTagIfDoubled.stree.txt new file mode 100644 index 0000000000..1c91b94c21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/RendersLiteralTextTagIfDoubled.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..51)::51 - [@{Foo Bar Baz zoop}] + MarkupBlock - [0..51)::51 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..51)::51 + CSharpStatement - [0..51)::51 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..51)::50 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..50)::48 + MarkupBlock - [2..45)::43 + MarkupElement - [2..45)::43 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupElement - [8..38)::30 + MarkupStartTag - [8..14)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [14..22)::8 - [Foo Bar ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + Text;[Bar]; + Whitespace;[ ]; + MarkupElement - [22..31)::9 + MarkupStartTag - [22..27)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [27..31)::4 - [ Baz] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Baz]; + MarkupEndTag - [31..38)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + MarkupEndTag - [38..45)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..50)::5 - [ zoop] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Identifier;[zoop]; + RazorMetaCode - [50..51)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [51..51)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsAtMatchingCloseTagToStartTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsAtMatchingCloseTagToStartTag.cspans.txt new file mode 100644 index 0000000000..232818d1f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsAtMatchingCloseTagToStartTag.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (2:0,2 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [3] ) +Markup span at (5:0,5 [3] ) (Accepts:None) - Parent: Tag block at (5:0,5 [3] ) +Markup span at (8:0,8 [4] ) (Accepts:None) - Parent: Tag block at (8:0,8 [4] ) +Markup span at (12:0,12 [4] ) (Accepts:None) - Parent: Tag block at (12:0,12 [4] ) +Markup span at (16:0,16 [3] ) (Accepts:None) - Parent: Tag block at (16:0,16 [3] ) +Markup span at (19:0,19 [4] ) (Accepts:None) - Parent: Tag block at (19:0,19 [4] ) +Code span at (23:0,23 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsAtMatchingCloseTagToStartTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsAtMatchingCloseTagToStartTag.stree.txt new file mode 100644 index 0000000000..8e19b5c2ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsAtMatchingCloseTagToStartTag.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..24)::24 - [@{}] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + MarkupBlock - [2..16)::14 + MarkupElement - [2..16)::14 + MarkupStartTag - [2..5)::3 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + CloseAngle;[>]; + MarkupElement - [5..12)::7 + MarkupStartTag - [5..8)::3 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[b]; + CloseAngle;[>]; + MarkupEndTag - [8..12)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[b]; + CloseAngle;[>]; + MarkupEndTag - [12..16)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[a]; + CloseAngle;[>]; + MarkupBlock - [16..23)::7 + MarkupElement - [16..23)::7 + MarkupStartTag - [16..19)::3 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[c]; + CloseAngle;[>]; + MarkupEndTag - [19..23)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[c]; + CloseAngle;[>]; + CSharpStatementLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.cspans.txt new file mode 100644 index 0000000000..d91425cc17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +Markup span at (2:0,2 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +Markup span at (7:0,7 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.diag.txt new file mode 100644 index 0000000000..cca79a1182 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "br" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                    ") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.stree.txt new file mode 100644 index 0000000000..d1385dbe43 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingMidEmptyTagIfEOFReached.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..7)::7 - [@{
                    - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpStatement - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..7)::6 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..6)::4 + MarkupBlock - [2..6)::4 + MarkupElement - [2..6)::4 + MarkupStartTag - [2..6)::4 - [
                    - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + ForwardSlash;[/]; + CloseAngle;[]; + RazorMetaCode - [6..7)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [7..7)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.cspans.txt new file mode 100644 index 0000000000..513e5e1227 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [9] ) +MetaCode span at (3:0,3 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [9] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.stree.txt new file mode 100644 index 0000000000..0dcd4b3227 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/StopsParsingSingleLineBlockAtEOFIfNoEOLReached.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..11)::11 - [@{@:foo bar] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpStatement - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..11)::9 + MarkupBlock - [2..11)::9 + MarkupTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [4..11)::7 - [foo bar] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Whitespace;[ ]; + Text;[bar]; + RazorMetaCode - [11..11)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentAsBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentAsBlock.cspans.txt new file mode 100644 index 0000000000..66f5786183 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentAsBlock.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (2:0,2 [4] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [12] ) +Markup span at (6:0,6 [5] ) (Accepts:Whitespace) - Parent: HtmlComment block at (2:0,2 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [12] ) +Code span at (14:0,14 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (14:0,14 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (15:0,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentAsBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentAsBlock.stree.txt new file mode 100644 index 0000000000..c857f00bc7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentAsBlock.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..15)::15 - [@{}] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + MarkupBlock - [2..14)::12 + MarkupCommentBlock - [2..14)::12 + MarkupTextLiteral - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + CSharpStatementLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithExtraDashAsBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithExtraDashAsBlock.cspans.txt new file mode 100644 index 0000000000..960fc76d40 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithExtraDashAsBlock.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (2:0,2 [4] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [13] ) +Markup span at (6:0,6 [6] ) (Accepts:Whitespace) - Parent: HtmlComment block at (2:0,2 [13] ) +Markup span at (12:0,12 [3] ) (Accepts:None) - Parent: HtmlComment block at (2:0,2 [13] ) +Code span at (15:0,15 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithExtraDashAsBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithExtraDashAsBlock.stree.txt new file mode 100644 index 0000000000..a9736e44df --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithExtraDashAsBlock.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..16)::16 - [@{}] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + CSharpStatement - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..16)::15 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..15)::13 + MarkupBlock - [2..15)::13 + MarkupCommentBlock - [2..15)::13 + MarkupTextLiteral - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + CSharpStatementLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithinBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithinBlock.cspans.txt new file mode 100644 index 0000000000..76cea803fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithinBlock.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [30] ) +Markup span at (10:0,10 [4] ) (Accepts:None) - Parent: HtmlComment block at (10:0,10 [13] ) +Markup span at (14:0,14 [6] ) (Accepts:Whitespace) - Parent: HtmlComment block at (10:0,10 [13] ) +Markup span at (20:0,20 [3] ) (Accepts:None) - Parent: HtmlComment block at (10:0,10 [13] ) +Markup span at (23:0,23 [3] ) (Accepts:None) - Parent: Markup block at (2:0,2 [30] ) +Markup span at (26:0,26 [6] ) (Accepts:None) - Parent: Tag block at (26:0,26 [6] ) +Code span at (32:0,32 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithinBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithinBlock.stree.txt new file mode 100644 index 0000000000..6bb5a51f00 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsCommentWithinBlock.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..33)::33 - [@{barbaz}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + CSharpStatement - [0..33)::33 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..33)::32 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..32)::30 + MarkupBlock - [2..32)::30 + MarkupElement - [2..32)::30 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..10)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + MarkupCommentBlock - [10..23)::13 + MarkupTextLiteral - [10..14)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [23..26)::3 - [baz] - Gen - SpanEditHandler;Accepts:None + Text;[baz]; + MarkupEndTag - [26..32)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithLessThanSignsInThem.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithLessThanSignsInThem.cspans.txt new file mode 100644 index 0000000000..308cb7122f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithLessThanSignsInThem.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (2:0,2 [8] ) (Accepts:None) - Parent: Tag block at (2:0,2 [8] ) +Markup span at (10:0,10 [28] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [45] ) +Markup span at (38:0,38 [9] ) (Accepts:None) - Parent: Tag block at (38:0,38 [9] ) +Code span at (47:0,47 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [48] ) +MetaCode span at (47:0,47 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [48] ) +Markup span at (48:0,48 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithLessThanSignsInThem.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithLessThanSignsInThem.stree.txt new file mode 100644 index 0000000000..76e144c7ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithLessThanSignsInThem.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..48)::48 - [@{}] + MarkupBlock - [0..48)::48 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..48)::48 + CSharpStatement - [0..48)::48 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..48)::47 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..47)::45 + MarkupBlock - [2..47)::45 + MarkupElement - [2..47)::45 + MarkupStartTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + CSharpStatementLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [47..48)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [48..48)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithSpacedLessThanSignsInThem.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithSpacedLessThanSignsInThem.cspans.txt new file mode 100644 index 0000000000..111203fb08 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithSpacedLessThanSignsInThem.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [50] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) +Markup span at (2:0,2 [8] ) (Accepts:None) - Parent: Tag block at (2:0,2 [8] ) +Markup span at (10:0,10 [30] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [47] ) +Markup span at (40:0,40 [9] ) (Accepts:None) - Parent: Tag block at (40:0,40 [9] ) +Code span at (49:0,49 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [50] ) +MetaCode span at (49:0,49 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) +Markup span at (50:0,50 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [50] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithSpacedLessThanSignsInThem.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithSpacedLessThanSignsInThem.stree.txt new file mode 100644 index 0000000000..bac6484d91 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsScriptTagsWithSpacedLessThanSignsInThem.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..50)::50 - [@{}] + MarkupBlock - [0..50)::50 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..50)::50 + CSharpStatement - [0..50)::50 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..50)::49 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..49)::47 + MarkupBlock - [2..49)::47 + MarkupElement - [2..49)::47 + MarkupStartTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + CSharpStatementLiteral - [49..49)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [49..50)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [50..50)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsTagsWithAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsTagsWithAttributes.cspans.txt new file mode 100644 index 0000000000..04325a68b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsTagsWithAttributes.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Markup span at (2:0,2 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [15] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [10] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [15] ) +Markup span at (17:0,17 [5] ) (Accepts:None) - Parent: Tag block at (17:0,17 [5] ) +Markup span at (22:0,22 [4] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [16] ) +Markup span at (26:0,26 [6] ) (Accepts:Any) - Parent: Markup block at (26:0,26 [10] ) +Markup span at (32:0,32 [4] ) (Accepts:Any) - Parent: Markup block at (26:0,26 [10] ) +Markup span at (36:0,36 [2] ) (Accepts:None) - Parent: Tag block at (22:0,22 [16] ) +Markup span at (38:0,38 [6] ) (Accepts:None) - Parent: Tag block at (38:0,38 [6] ) +Markup span at (44:0,44 [6] ) (Accepts:None) - Parent: Tag block at (44:0,44 [6] ) +Code span at (50:0,50 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) +MetaCode span at (50:0,50 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Markup span at (51:0,51 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsTagsWithAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsTagsWithAttributes.stree.txt new file mode 100644 index 0000000000..cec5e67cac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/SupportsTagsWithAttributes.stree.txt @@ -0,0 +1,69 @@ +RazorDocument - [0..51)::51 - [@{}] + MarkupBlock - [0..51)::51 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..51)::51 + CSharpStatement - [0..51)::51 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..51)::50 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..50)::48 + MarkupBlock - [2..50)::48 + MarkupElement - [2..50)::48 + MarkupStartTag - [2..17)::15 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + MarkupAttributeBlock - [6..16)::10 - [ bar="baz"] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..10)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [baz] + MarkupTextLiteral - [12..15)::3 - [baz] - Gen - SpanEditHandler;Accepts:Any + Text;[baz]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [17..44)::27 + MarkupStartTag - [17..22)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[biz]; + CloseAngle;[>]; + MarkupElement - [22..38)::16 + MarkupStartTag - [22..38)::16 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[boz]; + MarkupAttributeBlock - [26..36)::10 - [ zoop=zork] + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [27..31)::4 - [zoop] - Gen - SpanEditHandler;Accepts:Any + Text;[zoop]; + Equals;[=]; + GenericBlock - [32..36)::4 + MarkupLiteralAttributeValue - [32..36)::4 - [zork] + MarkupTextLiteral - [32..36)::4 - [zork] - Gen - SpanEditHandler;Accepts:Any + Text;[zork]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupEndTag - [38..44)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[biz]; + CloseAngle;[>]; + MarkupEndTag - [44..50)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [50..50)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [50..51)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [51..51)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.cspans.txt new file mode 100644 index 0000000000..33bfa139cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (2:0,2 [28] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.diag.txt new file mode 100644 index 0000000000..5c6d4706b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,3): Error RZ1024: End of file or an unexpected character was reached before the "" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                    ") or have matching end tags ("

                    Hello

                    "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.stree.txt new file mode 100644 index 0000000000..9d0b8c5e64 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TagWithoutCloseAngleDoesNotTerminateBlock.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..30)::30 - [@{< LF ] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpStatement - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..30)::29 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + MarkupBlock - [2..30)::28 + MarkupElement - [2..30)::28 + MarkupStartTag - [2..30)::28 - [< LF ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMiscAttributeContent - [3..30)::27 + MarkupTextLiteral - [3..30)::27 - [ LF ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + Whitespace;[ ]; + CloseAngle;[]; + RazorMetaCode - [30..30)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.cspans.txt new file mode 100644 index 0000000000..4f1792ca17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Code span at (7:0,7 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.diag.txt new file mode 100644 index 0000000000..f87f5f62ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "foo" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.stree.txt new file mode 100644 index 0000000000..2bce5971f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOF.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..7)::7 - [@{] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpStatement - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..7)::6 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..7)::5 + MarkupBlock - [2..7)::5 + MarkupElement - [2..7)::5 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [7..7)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [7..7)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.cspans.txt new file mode 100644 index 0000000000..1886686774 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (2:0,2 [9] ) (Accepts:None) - Parent: Markup block at (2:0,2 [9] ) +Code span at (11:0,11 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.stree.txt new file mode 100644 index 0000000000..41cb0f1c0a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesAtEOFWhenParsingComment.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..11)::11 - [@{-->}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupCommentBlock - [7..24)::17 + MarkupTextLiteral - [7..11)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [24..27)::3 - [-->] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [27..33)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesSGMLDeclarationAtFirstCloseAngle.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesSGMLDeclarationAtFirstCloseAngle.cspans.txt new file mode 100644 index 0000000000..88839eca6a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesSGMLDeclarationAtFirstCloseAngle.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [18] ) (Accepts:None) - Parent: Markup block at (2:0,2 [34] ) +Markup span at (25:0,25 [5] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [34] ) +Markup span at (30:0,30 [6] ) (Accepts:None) - Parent: Tag block at (30:0,30 [6] ) +Code span at (36:0,36 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (37:0,37 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesSGMLDeclarationAtFirstCloseAngle.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesSGMLDeclarationAtFirstCloseAngle.stree.txt new file mode 100644 index 0000000000..628b15a7af --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesSGMLDeclarationAtFirstCloseAngle.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..37)::37 - [@{ baz>}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..37)::37 + CSharpStatement - [0..37)::37 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..37)::36 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..36)::34 + MarkupBlock - [2..36)::34 + MarkupElement - [2..36)::34 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..25)::18 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[DOCTYPE]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + Text;[bar]; + CloseAngle;[>]; + MarkupTextLiteral - [25..30)::5 - [ baz>] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[baz]; + CloseAngle;[>]; + MarkupEndTag - [30..36)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [37..37)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair.cspans.txt new file mode 100644 index 0000000000..5d7825701c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [19] ) (Accepts:None) - Parent: Markup block at (2:0,2 [34] ) +Markup span at (26:0,26 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [34] ) +Markup span at (30:0,30 [6] ) (Accepts:None) - Parent: Tag block at (30:0,30 [6] ) +Code span at (36:0,36 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (37:0,37 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair.stree.txt new file mode 100644 index 0000000000..3b00cf06f2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..37)::37 - [@{ baz}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..37)::37 + CSharpStatement - [0..37)::37 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..37)::36 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..36)::34 + MarkupBlock - [2..36)::34 + MarkupElement - [2..36)::34 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..26)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + Text;[bar]; + Whitespace;[ ]; + Text;[baz]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupTextLiteral - [26..30)::4 - [ baz] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[baz]; + MarkupEndTag - [30..36)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [37..37)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.cspans.txt new file mode 100644 index 0000000000..2a4e59b07d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [13] ) (Accepts:None) - Parent: Tag block at (7:0,7 [13] ) +Markup span at (20:0,20 [6] ) (Accepts:None) - Parent: Tag block at (20:0,20 [6] ) +Code span at (26:0,26 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.diag.txt new file mode 100644 index 0000000000..628d44579e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.diag.txt @@ -0,0 +1,2 @@ +(1,4): Error RZ1025: The "foo" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,23): Error RZ1026: Encountered end tag "foo" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.stree.txt new file mode 100644 index 0000000000..4d2b3bc02d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/TreatsMalformedTagsAsContent.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..27)::27 - [@{}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupElement - [7..20)::13 + MarkupEndTag - [7..20)::13 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + MarkupMiscAttributeContent - [9..19)::10 + MarkupTextLiteral - [9..19)::10 - [!-- bar --] - Gen - SpanEditHandler;Accepts:Any + Bang;[!]; + DoubleHyphen;[--]; + Whitespace;[ ]; + Text;[bar]; + Whitespace;[ ]; + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupBlock - [20..26)::6 + MarkupElement - [20..26)::6 + MarkupEndTag - [20..26)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/WithSelfClosingTagJustEmitsTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/WithSelfClosingTagJustEmitsTag.cspans.txt new file mode 100644 index 0000000000..a94530c9bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/WithSelfClosingTagJustEmitsTag.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (2:0,2 [7] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Code span at (9:0,9 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/WithSelfClosingTagJustEmitsTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/WithSelfClosingTagJustEmitsTag.stree.txt new file mode 100644 index 0000000000..948a2dc1f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlBlockTest/WithSelfClosingTagJustEmitsTag.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..10)::10 - [@{}] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + MarkupBlock - [2..9)::7 + MarkupElement - [2..9)::7 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [9..9)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsEndTagWithNoMatchingStartTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsEndTagWithNoMatchingStartTag.cspans.txt new file mode 100644 index 0000000000..aa2e0c80e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsEndTagWithNoMatchingStartTag.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Markup span at (4:0,4 [6] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [6] ) +Markup span at (10:0,10 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsEndTagWithNoMatchingStartTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsEndTagWithNoMatchingStartTag.stree.txt new file mode 100644 index 0000000000..da9b272fd0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsEndTagWithNoMatchingStartTag.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..14)::14 - [Foo
                  • Bar] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..4)::4 - [Foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + MarkupElement - [4..10)::6 + MarkupEndTag - [4..10)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [10..14)::4 - [ Bar] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Bar]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.cspans.txt new file mode 100644 index 0000000000..cd03a1193c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [1] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [1] ) +Code span at (1:0,1 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [1] ) +Markup span at (1:0,1 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.diag.txt new file mode 100644 index 0000000000..c6d6925451 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.stree.txt new file mode 100644 index 0000000000..1b3a186cb6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..1)::1 - [@] + MarkupBlock - [0..1)::1 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..1)::1 + CSharpImplicitExpression - [0..1)::1 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..1)::0 + CSharpCodeBlock - [1..1)::0 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [1..1)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesOddlySpacedHTMLElements.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesOddlySpacedHTMLElements.cspans.txt new file mode 100644 index 0000000000..d0a7399fbb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesOddlySpacedHTMLElements.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [6] ) +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [17] ) +Markup span at (8:0,8 [10] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [14] ) +Markup span at (18:0,18 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [14] ) +Markup span at (21:0,21 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [14] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [17] ) +Markup span at (23:0,23 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Markup span at (28:0,28 [4] ) (Accepts:Any) - Parent: Tag block at (28:0,28 [4] ) +Markup span at (32:0,32 [7] ) (Accepts:Any) - Parent: Tag block at (32:0,32 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesOddlySpacedHTMLElements.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesOddlySpacedHTMLElements.stree.txt new file mode 100644 index 0000000000..22a277385d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesOddlySpacedHTMLElements.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..39)::39 - [

                    Foo

                    ] + MarkupBlock - [0..39)::39 + MarkupElement - [0..39)::39 + MarkupStartTag - [0..6)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupMiscAttributeContent - [4..5)::1 + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupElement - [6..32)::26 + MarkupStartTag - [6..23)::17 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupAttributeBlock - [8..22)::14 - [ class = 'bar'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Equals;[=]; + MarkupTextLiteral - [16..18)::2 - [ '] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + SingleQuote;[']; + GenericBlock - [18..21)::3 + MarkupLiteralAttributeValue - [18..21)::3 - [bar] + MarkupTextLiteral - [18..21)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [23..28)::5 - [ Foo ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Foo]; + Whitespace;[ ]; + MarkupEndTag - [28..32)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [32..39)::7 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + MarkupMiscAttributeContent - [37..38)::1 + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.cspans.txt new file mode 100644 index 0000000000..5d0ddc2940 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (9:0,9 [12] ) +Code span at (10:0,10 [11] ) (Accepts:Any) - Parent: Statement block at (9:0,9 [12] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (25:0,25 [6] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.stree.txt new file mode 100644 index 0000000000..259ac75bfb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..31)::31 - [
                    Foo @if(true) {} Bar
                    ] + MarkupBlock - [0..31)::31 + MarkupElement - [0..31)::31 + MarkupStartTag - [0..5)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [5..9)::4 - [Foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + CSharpCodeBlock - [9..21)::12 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [10..21)::11 - [if(true) {}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + RightBrace;[}]; + MarkupTextLiteral - [21..25)::4 - [ Bar] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Bar]; + MarkupEndTag - [25..31)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreNewLineAtTheEndOfMarkupBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreNewLineAtTheEndOfMarkupBlock.cspans.txt new file mode 100644 index 0000000000..bc666a56c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreNewLineAtTheEndOfMarkupBlock.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (5:1,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Markup span at (7:2,0 [6] ) (Accepts:Any) - Parent: Tag block at (7:2,0 [6] ) +Markup span at (13:2,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreNewLineAtTheEndOfMarkupBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreNewLineAtTheEndOfMarkupBlock.stree.txt new file mode 100644 index 0000000000..fabfa3c78f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreNewLineAtTheEndOfMarkupBlock.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..15)::15 - [@{LF}LFLF] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..4)::2 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + RazorMetaCode - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [5..7)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [7..15)::8 + MarkupStartTag - [7..13)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; + MarkupTextLiteral - [13..15)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent.cspans.txt new file mode 100644 index 0000000000..dc0d803cca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (5:1,1 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Markup span at (9:1,5 [6] ) (Accepts:Any) - Parent: Tag block at (9:1,5 [6] ) +Markup span at (15:1,11 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent.stree.txt new file mode 100644 index 0000000000..2e72f13a9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..17)::17 - [@{LF} LF] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..4)::2 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + RazorMetaCode - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [5..9)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [9..17)::8 + MarkupStartTag - [9..15)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; + MarkupTextLiteral - [15..17)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock.cspans.txt new file mode 100644 index 0000000000..3377e6030e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (5:1,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Markup span at (7:2,0 [6] ) (Accepts:Any) - Parent: Tag block at (7:2,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock.stree.txt new file mode 100644 index 0000000000..851d431f02 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..13)::13 - [@{LF}LF] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..4)::2 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + RazorMetaCode - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [5..7)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [7..13)::6 + MarkupStartTag - [7..13)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock.cspans.txt new file mode 100644 index 0000000000..f0a0bcd1d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (5:1,1 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Markup span at (9:2,0 [6] ) (Accepts:Any) - Parent: Tag block at (9:2,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock.stree.txt new file mode 100644 index 0000000000..33396e0ba8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..15)::15 - [@{LF} LF] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..4)::2 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + RazorMetaCode - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [5..9)::4 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupElement - [9..15)::6 + MarkupStartTag - [9..15)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp.cspans.txt new file mode 100644 index 0000000000..64066d4763 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [17] ) +Transition span at (12:0,12 [7] ) (Accepts:None) - Parent: Tag block at (12:0,12 [7] ) +Code span at (19:0,19 [4] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (23:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (24:2,1 [6] ) (Accepts:Any) - Parent: Tag block at (24:2,1 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp.stree.txt new file mode 100644 index 0000000000..b1b8a4a26f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..30)::30 - [@{BlahLFLF}] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [8..12)::4 - [Blah] - Gen - SpanEditHandler;Accepts:Any + Text;[Blah]; + MarkupEndTag - [12..19)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..23)::4 - [LFLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + NewLine;[LF]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupElement - [24..30)::6 + MarkupStartTag - [24..30)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotReturnErrorOnMismatchedTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotReturnErrorOnMismatchedTags.cspans.txt new file mode 100644 index 0000000000..171db96fab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotReturnErrorOnMismatchedTags.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Markup span at (4:0,4 [5] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [5] ) +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [3] ) +Markup span at (12:0,12 [4] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [4] ) +Markup span at (16:0,16 [4] ) (Accepts:Any) - Parent: Tag block at (16:0,16 [4] ) +Markup span at (20:0,20 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotReturnErrorOnMismatchedTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotReturnErrorOnMismatchedTags.stree.txt new file mode 100644 index 0000000000..8943facbf6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotReturnErrorOnMismatchedTags.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..24)::24 - [Foo

                    Baz] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..4)::4 - [Foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + MarkupElement - [4..24)::20 + MarkupStartTag - [4..9)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupElement - [9..16)::7 + MarkupStartTag - [9..12)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [12..16)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [16..20)::4 + MarkupEndTag - [16..20)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [20..24)::4 - [ Baz] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.cspans.txt new file mode 100644 index 0000000000..00a1a77d55 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [39] ) +Markup span at (2:0,2 [7] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [36] ) +Markup span at (9:0,9 [28] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [36] ) +Markup span at (37:0,37 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [36] ) +Markup span at (38:0,38 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [39] ) +Markup span at (39:0,39 [8] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Markup span at (47:0,47 [4] ) (Accepts:Any) - Parent: Tag block at (47:0,47 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.stree.txt new file mode 100644 index 0000000000..e311d83d19 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..51)::51 - [Email me] + MarkupBlock - [0..51)::51 + MarkupElement - [0..51)::51 + MarkupStartTag - [0..39)::39 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [2..38)::36 - [ href="mailto:example@microsoft.com"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..7)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [8..9)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [9..37)::28 + MarkupLiteralAttributeValue - [9..37)::28 - [mailto:example@microsoft.com] + MarkupTextLiteral - [9..37)::28 - [mailto:example@microsoft.com] - Gen - SpanEditHandler;Accepts:Any + Text;[mailto:example@microsoft.com]; + MarkupTextLiteral - [37..38)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [39..47)::8 - [Email me] - Gen - SpanEditHandler;Accepts:Any + Text;[Email]; + Whitespace;[ ]; + Text;[me]; + MarkupEndTag - [47..51)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[a]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.cspans.txt new file mode 100644 index 0000000000..88ff154777 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (4:0,4 [1] ) (Accepts:None) - Parent: Expression block at (4:0,4 [1] ) +Code span at (5:0,5 [0] ) (Accepts:NonWhitespace) - Parent: Expression block at (4:0,4 [1] ) +Markup span at (5:0,5 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.diag.txt new file mode 100644 index 0000000000..bc2525ce53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.stree.txt new file mode 100644 index 0000000000..5f52cafeba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsAtSignAsMarkupIfAtEndOfFile.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..5)::5 - [foo @] + MarkupBlock - [0..5)::5 + MarkupTextLiteral - [0..4)::4 - [foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Whitespace;[ ]; + CSharpCodeBlock - [4..5)::1 + CSharpImplicitExpression - [4..5)::1 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [5..5)::0 + CSharpCodeBlock - [5..5)::0 + CSharpExpressionLiteral - [5..5)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Marker;[]; + MarkupTextLiteral - [5..5)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsCodeBlockIfFirstCharacterIsSwapCharacter.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsCodeBlockIfFirstCharacterIsSwapCharacter.cspans.txt new file mode 100644 index 0000000000..490eb4a82f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsCodeBlockIfFirstCharacterIsSwapCharacter.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Expression block at (0:0,0 [4] ) +Code span at (1:0,1 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (0:0,0 [4] ) +Markup span at (4:0,4 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsCodeBlockIfFirstCharacterIsSwapCharacter.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsCodeBlockIfFirstCharacterIsSwapCharacter.stree.txt new file mode 100644 index 0000000000..14decc3757 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/EmitsCodeBlockIfFirstCharacterIsSwapCharacter.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..4)::4 - [@bar] + MarkupBlock - [0..4)::4 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..4)::4 + CSharpImplicitExpression - [0..4)::4 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [1..4)::3 + CSharpCodeBlock - [1..4)::3 + CSharpExpressionLiteral - [1..4)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [4..4)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesExtraNewLineBeforeMarkupInNestedBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesExtraNewLineBeforeMarkupInNestedBlock.cspans.txt new file mode 100644 index 0000000000..7217cc651e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesExtraNewLineBeforeMarkupInNestedBlock.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +Transition span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (4:1,0 [13] ) +Code span at (5:1,1 [12] ) (Accepts:Any) - Parent: Statement block at (4:1,0 [13] ) +Code span at (17:2,1 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (20:3,0 [7] ) (Accepts:None) - Parent: Tag block at (20:3,0 [7] ) +Markup span at (27:3,7 [3] ) (Accepts:None) - Parent: Markup block at (20:3,0 [10] ) +Code span at (30:4,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (30:4,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (31:4,1 [6] ) (Accepts:Any) - Parent: Tag block at (31:4,1 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesExtraNewLineBeforeMarkupInNestedBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesExtraNewLineBeforeMarkupInNestedBlock.stree.txt new file mode 100644 index 0000000000..99d6c80a8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesExtraNewLineBeforeMarkupInNestedBlock.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..37)::37 - [@{LF@if(true){LF} LF LF}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + CSharpStatement - [0..31)::31 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..31)::30 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + CSharpCodeBlock - [4..17)::13 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [5..17)::12 - [if(true){LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + CSharpStatementLiteral - [17..20)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + MarkupBlock - [20..30)::10 + MarkupElement - [20..27)::7 + MarkupStartTag - [20..27)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTextLiteral - [27..30)::3 - [ LF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + NewLine;[LF]; + CSharpStatementLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupElement - [31..37)::6 + MarkupStartTag - [31..37)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineAndMarkupInNestedBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineAndMarkupInNestedBlock.cspans.txt new file mode 100644 index 0000000000..a77a720a46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineAndMarkupInNestedBlock.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +Transition span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (4:1,0 [13] ) +Code span at (5:1,1 [12] ) (Accepts:Any) - Parent: Statement block at (4:1,0 [13] ) +Markup span at (17:2,1 [1] ) (Accepts:Any) - Parent: Markup block at (17:2,1 [9] ) +Markup span at (18:2,2 [7] ) (Accepts:None) - Parent: Tag block at (18:2,2 [7] ) +Markup span at (25:2,9 [1] ) (Accepts:None) - Parent: Markup block at (17:2,1 [9] ) +Code span at (26:2,10 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:2,10 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:2,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineAndMarkupInNestedBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineAndMarkupInNestedBlock.stree.txt new file mode 100644 index 0000000000..fe8f98cf28 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineAndMarkupInNestedBlock.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..27)::27 - [@{LF@if(true){LF} }] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + CSharpCodeBlock - [4..17)::13 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [5..17)::12 - [if(true){LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + MarkupBlock - [17..26)::9 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [18..25)::7 + MarkupStartTag - [18..25)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineInNestedBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineInNestedBlock.cspans.txt new file mode 100644 index 0000000000..bcf75ec253 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineInNestedBlock.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +Transition span at (4:1,0 [1] ) (Accepts:None) - Parent: Statement block at (4:1,0 [13] ) +Code span at (5:1,1 [12] ) (Accepts:Any) - Parent: Statement block at (4:1,0 [13] ) +Code span at (17:2,1 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:3,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:3,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Markup span at (23:4,0 [6] ) (Accepts:Any) - Parent: Tag block at (23:4,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineInNestedBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineInNestedBlock.stree.txt new file mode 100644 index 0000000000..8e2d005143 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandlesNewLineInNestedBlock.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..29)::29 - [@{LF@if(true){LF} LF}LF] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + CSharpCodeBlock - [4..17)::13 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [5..17)::12 - [if(true){LF}] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + LeftBrace;[{]; + NewLine;[LF]; + RightBrace;[}]; + CSharpStatementLiteral - [17..20)::3 - [ LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + NewLine;[LF]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [21..23)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [23..29)::6 + MarkupStartTag - [23..29)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput.cspans.txt new file mode 100644 index 0000000000..55bb03e494 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (4:0,4 [1] ) (Accepts:None) - Parent: Expression block at (4:0,4 [4] ) +Code span at (5:0,5 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (4:0,4 [4] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput.stree.txt new file mode 100644 index 0000000000..112b5dc463 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..12)::12 - [foo @bar baz] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..4)::4 - [foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Whitespace;[ ]; + CSharpCodeBlock - [4..8)::4 + CSharpImplicitExpression - [4..8)::4 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [5..8)::3 + CSharpCodeBlock - [5..8)::3 + CSharpExpressionLiteral - [5..8)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [8..12)::4 - [ baz] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/IgnoresTagsInContentsOfScriptTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/IgnoresTagsInContentsOfScriptTag.cspans.txt new file mode 100644 index 0000000000..5d433efd31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/IgnoresTagsInContentsOfScriptTag.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [4] ) +Code span at (22:0,22 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [4] ) +Markup span at (25:0,25 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Markup span at (27:0,27 [9] ) (Accepts:Any) - Parent: Tag block at (27:0,27 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/IgnoresTagsInContentsOfScriptTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/IgnoresTagsInContentsOfScriptTag.stree.txt new file mode 100644 index 0000000000..1bade1e988 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/IgnoresTagsInContentsOfScriptTag.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..36)::36 - [] + MarkupBlock - [0..36)::36 + MarkupElement - [0..36)::36 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.cspans.txt new file mode 100644 index 0000000000..ae1f1aa184 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [52] ) +Code span at (1:0,1 [12] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [52] ) +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Statement block at (13:0,13 [37] ) +Code span at (14:0,14 [11] ) (Accepts:Any) - Parent: Statement block at (13:0,13 [37] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (25:0,25 [24] ) +Markup span at (26:0,26 [5] ) (Accepts:None) - Parent: Tag block at (26:0,26 [5] ) +Markup span at (31:0,31 [0] ) (Accepts:Any) - Parent: Markup block at (25:0,25 [24] ) +Transition span at (31:0,31 [1] ) (Accepts:None) - Parent: Expression block at (31:0,31 [10] ) +Code span at (32:0,32 [9] ) (Accepts:NonWhitespace) - Parent: Expression block at (31:0,31 [10] ) +Markup span at (41:0,41 [1] ) (Accepts:Any) - Parent: Markup block at (25:0,25 [24] ) +Markup span at (42:0,42 [6] ) (Accepts:None) - Parent: Tag block at (42:0,42 [6] ) +Markup span at (48:0,48 [1] ) (Accepts:None) - Parent: Markup block at (25:0,25 [24] ) +Code span at (49:0,49 [1] ) (Accepts:Any) - Parent: Statement block at (13:0,13 [37] ) +Code span at (50:0,50 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [52] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.stree.txt new file mode 100644 index 0000000000..3ad32ce552 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NestedCodeBlockWithMarkupSetsDotAsMarkup.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..52)::52 - [@if (true) { @if(false) {
                    @something.
                    } }] + MarkupBlock - [0..52)::52 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..52)::52 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [1..13)::12 - [if (true) { ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [13..50)::37 + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [14..25)::11 - [if(false) {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + LeftParenthesis;[(]; + Keyword;[false]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + MarkupBlock - [25..49)::24 + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [26..48)::22 + MarkupStartTag - [26..31)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [31..41)::10 + CSharpImplicitExpression - [31..41)::10 + CSharpTransition - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [32..41)::9 + CSharpCodeBlock - [32..41)::9 + CSharpExpressionLiteral - [32..41)::9 - [something] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[something]; + MarkupTextLiteral - [41..42)::1 - [.] - Gen - SpanEditHandler;Accepts:Any + Text;[.]; + MarkupEndTag - [42..48)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [48..49)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [49..50)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + RightBrace;[}]; + CSharpStatementLiteral - [50..52)::2 - [ }] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBrace;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NoLongerSupportsDollarOpenBraceCombination.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NoLongerSupportsDollarOpenBraceCombination.cspans.txt new file mode 100644 index 0000000000..8a3272c5b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NoLongerSupportsDollarOpenBraceCombination.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NoLongerSupportsDollarOpenBraceCombination.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NoLongerSupportsDollarOpenBraceCombination.stree.txt new file mode 100644 index 0000000000..b636dfcedc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/NoLongerSupportsDollarOpenBraceCombination.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..17)::17 - [${bar}] + MarkupBlock - [0..17)::17 + MarkupElement - [0..17)::17 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..11)::6 - [${bar}] - Gen - SpanEditHandler;Accepts:Any + Text;[${bar}]; + MarkupEndTag - [11..17)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString.cspans.txt new file mode 100644 index 0000000000..a7687acf26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [0] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString.stree.txt new file mode 100644 index 0000000000..dcd6e30919 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString.stree.txt @@ -0,0 +1,4 @@ +RazorDocument - [0..0)::0 - [] + MarkupBlock - [0..0)::0 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan.cspans.txt new file mode 100644 index 0000000000..24b53ba184 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [10] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan.stree.txt new file mode 100644 index 0000000000..8ba87c13e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan.stree.txt @@ -0,0 +1,4 @@ +RazorDocument - [0..10)::10 - [ ] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..10)::10 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText.cspans.txt new file mode 100644 index 0000000000..fdb12c7ba5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [21] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText.stree.txt new file mode 100644 index 0000000000..d745d52162 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText.stree.txt @@ -0,0 +1,4 @@ +RazorDocument - [0..21)::21 - [example@microsoft.com] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..21)::21 - [example@microsoft.com] - Gen - SpanEditHandler;Accepts:Any + Text;[example@microsoft.com]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseSectionIgnoresTagsInContentsOfScriptTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseSectionIgnoresTagsInContentsOfScriptTag.cspans.txt new file mode 100644 index 0000000000..3b00db2835 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseSectionIgnoresTagsInContentsOfScriptTag.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [53] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [53] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [53] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [53] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [53] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [53] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [38] ) +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (23:0,23 [13] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [38] ) +Transition span at (36:0,36 [1] ) (Accepts:None) - Parent: Expression block at (36:0,36 [4] ) +Code span at (37:0,37 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (36:0,36 [4] ) +Markup span at (40:0,40 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [38] ) +Markup span at (42:0,42 [9] ) (Accepts:Any) - Parent: Tag block at (42:0,42 [9] ) +Markup span at (51:0,51 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [38] ) +MetaCode span at (52:0,52 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [53] ) +Markup span at (53:0,53 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseSectionIgnoresTagsInContentsOfScriptTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseSectionIgnoresTagsInContentsOfScriptTag.stree.txt new file mode 100644 index 0000000000..6d1d25d388 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParseSectionIgnoresTagsInContentsOfScriptTag.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..53)::53 - [@section Foo { }] + MarkupBlock - [0..53)::53 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..53)::53 + RazorDirective - [0..53)::53 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..53)::52 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..53)::45 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..52)::38 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..51)::36 + MarkupStartTag - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTextLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [53..53)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered.cspans.txt new file mode 100644 index 0000000000..5b9dbcd8aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered.stree.txt new file mode 100644 index 0000000000..30659bb00b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered.stree.txt @@ -0,0 +1,6 @@ +RazorDocument - [0..7)::7 - [foo baz] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..7)::7 - [foo baz] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + Whitespace;[ ]; + Text;[baz]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml.cspans.txt new file mode 100644 index 0000000000..f77279dbd9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [38] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Transition span at (12:0,12 [7] ) (Accepts:None) - Parent: Tag block at (12:0,12 [7] ) +Markup span at (19:0,19 [2] ) (Accepts:None) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (21:1,0 [8] ) (Accepts:None) - Parent: Tag block at (21:1,0 [8] ) +Markup span at (29:1,8 [2] ) (Accepts:None) - Parent: Markup block at (21:1,0 [10] ) +Code span at (31:2,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:2,1 [6] ) (Accepts:Any) - Parent: Tag block at (32:2,1 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml.stree.txt new file mode 100644 index 0000000000..c9a55ee938 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..38)::38 - [@{BlahLFLF}] + MarkupBlock - [0..38)::38 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..21)::19 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [8..12)::4 - [Blah] - Gen - SpanEditHandler;Accepts:Any + Text;[Blah]; + MarkupEndTag - [12..19)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [19..21)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [21..31)::10 + MarkupElement - [21..29)::8 + MarkupStartTag - [21..29)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [29..31)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupElement - [32..38)::6 + MarkupStartTag - [32..38)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition.cspans.txt new file mode 100644 index 0000000000..74b05993f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Transition span at (12:0,12 [7] ) (Accepts:None) - Parent: Tag block at (12:0,12 [7] ) +Markup span at (19:0,19 [2] ) (Accepts:None) - Parent: Markup block at (2:0,2 [19] ) +Transition span at (21:1,0 [1] ) (Accepts:None) - Parent: Markup block at (21:1,0 [9] ) +MetaCode span at (22:1,1 [1] ) (Accepts:Any) - Parent: Markup block at (21:1,0 [9] ) +Markup span at (23:1,2 [7] ) (Accepts:None) - Parent: Markup block at (21:1,0 [9] ) +Code span at (30:2,0 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (30:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (31:2,1 [6] ) (Accepts:Any) - Parent: Tag block at (31:2,1 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition.stree.txt new file mode 100644 index 0000000000..66dd22c8ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..37)::37 - [@{BlahLF@: BlehLF}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + CSharpStatement - [0..31)::31 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..31)::30 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + MarkupBlock - [2..21)::19 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [8..12)::4 - [Blah] - Gen - SpanEditHandler;Accepts:Any + Text;[Blah]; + MarkupEndTag - [12..19)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [19..21)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + MarkupBlock - [21..30)::9 + MarkupTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [23..30)::7 - [ BlehLF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[Bleh]; + NewLine;[LF]; + CSharpStatementLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupElement - [31..37)::6 + MarkupStartTag - [31..37)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[html]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersTextPseudoTagAsMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersTextPseudoTagAsMarkup.cspans.txt new file mode 100644 index 0000000000..4df286098a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersTextPseudoTagAsMarkup.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Markup span at (4:0,4 [6] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [6] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Markup span at (13:0,13 [7] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersTextPseudoTagAsMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersTextPseudoTagAsMarkup.stree.txt new file mode 100644 index 0000000000..668a7dba33 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/RendersTextPseudoTagAsMarkup.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..20)::20 - [Foo Foo] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..4)::4 - [Foo ] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + Whitespace;[ ]; + MarkupElement - [4..20)::16 + MarkupStartTag - [4..10)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [10..13)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [13..20)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered.cspans.txt new file mode 100644 index 0000000000..056f638ae3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (7:0,7 [4] ) (Accepts:None) - Parent: HtmlComment block at (7:0,7 [10] ) +Markup span at (11:0,11 [3] ) (Accepts:Whitespace) - Parent: HtmlComment block at (7:0,7 [10] ) +Markup span at (14:0,14 [3] ) (Accepts:None) - Parent: HtmlComment block at (7:0,7 [10] ) +Markup span at (17:0,17 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (20:0,20 [10] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered.stree.txt new file mode 100644 index 0000000000..e9fd31b945 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..30)::30 - [Foo BazBar] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [17..20)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupTextLiteral - [20..30)::10 - [ Bar}] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpStatement - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..17)::16 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..16)::14 + MarkupBlock - [2..13)::11 + MarkupCommentBlock - [2..12)::10 + MarkupTextLiteral - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [13..16)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Identifier;[Bar]; + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/DocTypeTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/DocTypeTag.cspans.txt new file mode 100644 index 0000000000..597866b0ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/DocTypeTag.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [15] ) (Accepts:None) - Parent: Markup block at (2:0,2 [16] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [16] ) +Code span at (18:0,18 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/DocTypeTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/DocTypeTag.stree.txt new file mode 100644 index 0000000000..e5d4508525 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/DocTypeTag.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..22)::22 - [@{ foo}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..18)::16 + MarkupTextLiteral - [2..17)::15 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[DOCTYPE]; + Whitespace;[ ]; + Text;[html]; + CloseAngle;[>]; + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [18..21)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ElementTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ElementTags.cspans.txt new file mode 100644 index 0000000000..539ba5c383 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ElementTags.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (2:0,2 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [3] ) +Markup span at (5:0,5 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [11] ) +Markup span at (8:0,8 [4] ) (Accepts:None) - Parent: Tag block at (8:0,8 [4] ) +Markup span at (12:0,12 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [11] ) +Code span at (13:0,13 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ElementTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ElementTags.stree.txt new file mode 100644 index 0000000000..c864f0ee6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ElementTags.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..17)::17 - [@{

                    Foo

                    Bar}] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpStatement - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..17)::16 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..16)::14 + MarkupBlock - [2..13)::11 + MarkupElement - [2..12)::10 + MarkupStartTag - [2..5)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [5..8)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [8..12)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [13..16)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Identifier;[Bar]; + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTag.cspans.txt new file mode 100644 index 0000000000..134c16b6ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTag.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Markup span at (2:0,2 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [2] ) +Markup span at (4:0,4 [3] ) (Accepts:None) - Parent: Tag block at (4:0,4 [3] ) +Markup span at (7:0,7 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [6] ) +Code span at (8:0,8 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTag.stree.txt new file mode 100644 index 0000000000..8f2dd2a56c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTag.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..12)::12 - [@{<> Bar}] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + CSharpStatement - [0..12)::12 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..12)::11 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..11)::9 + MarkupBlock - [2..8)::6 + MarkupElement - [2..7)::5 + MarkupStartTag - [2..4)::2 - [<>] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[]; + CloseAngle;[>]; + MarkupEndTag - [4..7)::3 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[>]; + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [8..11)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Identifier;[Bar]; + RazorMetaCode - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [12..12)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.cspans.txt new file mode 100644 index 0000000000..dc05e218a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +Markup span at (2:0,2 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [3] ) +Markup span at (5:0,5 [3] ) (Accepts:None) - Parent: Tag block at (5:0,5 [3] ) +Markup span at (8:0,8 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [7] ) +Code span at (9:0,9 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [13] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +Markup span at (13:0,13 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.diag.txt new file mode 100644 index 0000000000..6c6136553e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1025: The "p" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.stree.txt new file mode 100644 index 0000000000..52be2f619c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/EmptyTagNestsLikeNormalTag.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..13)::13 - [@{

                    Bar}] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + CSharpStatement - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..13)::12 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..12)::10 + MarkupBlock - [2..9)::7 + MarkupElement - [2..8)::6 + MarkupStartTag - [2..5)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [5..8)::3 + MarkupEndTag - [5..8)::3 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[>]; + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Identifier;[Bar]; + RazorMetaCode - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [13..13)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.cspans.txt new file mode 100644 index 0000000000..12cae5de6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.cspans.txt @@ -0,0 +1,36 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [344] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [344] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [344] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [344] ) +Markup span at (4:1,0 [6] ) (Accepts:None) - Parent: Tag block at (4:1,0 [6] ) +Markup span at (10:1,6 [15] ) (Accepts:Any) - Parent: Tag block at (10:1,6 [15] ) +Markup span at (25:4,0 [6] ) (Accepts:None) - Parent: Tag block at (25:4,0 [6] ) +Markup span at (31:4,6 [15] ) (Accepts:Any) - Parent: Tag block at (31:4,6 [15] ) +Markup span at (46:7,0 [4] ) (Accepts:None) - Parent: Tag block at (46:7,0 [4] ) +Markup span at (50:7,4 [13] ) (Accepts:Any) - Parent: Tag block at (50:7,4 [13] ) +Markup span at (63:10,0 [5] ) (Accepts:None) - Parent: Tag block at (63:10,0 [5] ) +Markup span at (68:10,5 [14] ) (Accepts:Any) - Parent: Tag block at (68:10,5 [14] ) +Markup span at (82:13,0 [9] ) (Accepts:None) - Parent: Tag block at (82:13,0 [9] ) +Markup span at (91:13,9 [18] ) (Accepts:Any) - Parent: Tag block at (91:13,9 [18] ) +Markup span at (109:16,0 [7] ) (Accepts:None) - Parent: Tag block at (109:16,0 [7] ) +Markup span at (116:16,7 [16] ) (Accepts:Any) - Parent: Tag block at (116:16,7 [16] ) +Markup span at (132:19,0 [4] ) (Accepts:None) - Parent: Tag block at (132:19,0 [4] ) +Markup span at (136:19,4 [13] ) (Accepts:Any) - Parent: Tag block at (136:19,4 [13] ) +Markup span at (149:22,0 [5] ) (Accepts:None) - Parent: Tag block at (149:22,0 [5] ) +Markup span at (154:22,5 [14] ) (Accepts:Any) - Parent: Tag block at (154:22,5 [14] ) +Markup span at (168:25,0 [7] ) (Accepts:None) - Parent: Tag block at (168:25,0 [7] ) +Markup span at (175:25,7 [16] ) (Accepts:Any) - Parent: Tag block at (175:25,7 [16] ) +Markup span at (191:28,0 [8] ) (Accepts:None) - Parent: Tag block at (191:28,0 [8] ) +Markup span at (199:28,8 [17] ) (Accepts:Any) - Parent: Tag block at (199:28,8 [17] ) +Markup span at (216:31,0 [6] ) (Accepts:None) - Parent: Tag block at (216:31,0 [6] ) +Markup span at (222:31,6 [15] ) (Accepts:Any) - Parent: Tag block at (222:31,6 [15] ) +Markup span at (237:34,0 [6] ) (Accepts:None) - Parent: Tag block at (237:34,0 [6] ) +Markup span at (243:34,6 [15] ) (Accepts:Any) - Parent: Tag block at (243:34,6 [15] ) +Markup span at (258:37,0 [7] ) (Accepts:None) - Parent: Tag block at (258:37,0 [7] ) +Markup span at (265:37,7 [16] ) (Accepts:Any) - Parent: Tag block at (265:37,7 [16] ) +Markup span at (281:40,0 [8] ) (Accepts:None) - Parent: Tag block at (281:40,0 [8] ) +Markup span at (289:40,8 [17] ) (Accepts:Any) - Parent: Tag block at (289:40,8 [17] ) +Markup span at (306:43,0 [7] ) (Accepts:None) - Parent: Tag block at (306:43,0 [7] ) +Markup span at (313:43,7 [16] ) (Accepts:Any) - Parent: Tag block at (313:43,7 [16] ) +Markup span at (329:46,0 [5] ) (Accepts:None) - Parent: Tag block at (329:46,0 [5] ) +Markup span at (334:46,5 [10] ) (Accepts:Any) - Parent: Tag block at (334:46,5 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.diag.txt new file mode 100644 index 0000000000..1ced8c1b88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.stree.txt new file mode 100644 index 0000000000..c130d59e5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/IncompleteVoidElementEndTag.stree.txt @@ -0,0 +1,317 @@ +RazorDocument - [0..344)::344 - [@{LF - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..344)::344 + CSharpStatement - [0..344)::344 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..344)::343 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..344)::342 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL + NewLine;[LF]; + MarkupBlock - [4..25)::21 + MarkupElement - [4..25)::21 + MarkupStartTag - [4..10)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[area]; + CloseAngle;[>]; + MarkupEndTag - [10..25)::15 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[area]; + MarkupMiscAttributeContent - [16..25)::9 + MarkupTextLiteral - [16..25)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [25..46)::21 + MarkupElement - [25..46)::21 + MarkupStartTag - [25..31)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[base]; + CloseAngle;[>]; + MarkupEndTag - [31..46)::15 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[base]; + MarkupMiscAttributeContent - [37..46)::9 + MarkupTextLiteral - [37..46)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [46..63)::17 + MarkupElement - [46..63)::17 + MarkupStartTag - [46..50)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupEndTag - [50..63)::13 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[br]; + MarkupMiscAttributeContent - [54..63)::9 + MarkupTextLiteral - [54..63)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [63..82)::19 + MarkupElement - [63..82)::19 + MarkupStartTag - [63..68)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[col]; + CloseAngle;[>]; + MarkupEndTag - [68..82)::14 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[col]; + MarkupMiscAttributeContent - [73..82)::9 + MarkupTextLiteral - [73..82)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [82..109)::27 + MarkupElement - [82..109)::27 + MarkupStartTag - [82..91)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[command]; + CloseAngle;[>]; + MarkupEndTag - [91..109)::18 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[command]; + MarkupMiscAttributeContent - [100..109)::9 + MarkupTextLiteral - [100..109)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [109..132)::23 + MarkupElement - [109..132)::23 + MarkupStartTag - [109..116)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[embed]; + CloseAngle;[>]; + MarkupEndTag - [116..132)::16 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[embed]; + MarkupMiscAttributeContent - [123..132)::9 + MarkupTextLiteral - [123..132)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [132..149)::17 + MarkupElement - [132..149)::17 + MarkupStartTag - [132..136)::4 - [


                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[hr]; + CloseAngle;[>]; + MarkupEndTag - [136..149)::13 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[hr]; + MarkupMiscAttributeContent - [140..149)::9 + MarkupTextLiteral - [140..149)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [149..168)::19 + MarkupElement - [149..168)::19 + MarkupStartTag - [149..154)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[img]; + CloseAngle;[>]; + MarkupEndTag - [154..168)::14 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[img]; + MarkupMiscAttributeContent - [159..168)::9 + MarkupTextLiteral - [159..168)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [168..191)::23 + MarkupElement - [168..191)::23 + MarkupStartTag - [168..175)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupEndTag - [175..191)::16 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + MarkupMiscAttributeContent - [182..191)::9 + MarkupTextLiteral - [182..191)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [191..216)::25 + MarkupElement - [191..216)::25 + MarkupStartTag - [191..199)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[keygen]; + CloseAngle;[>]; + MarkupEndTag - [199..216)::17 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[keygen]; + MarkupMiscAttributeContent - [207..216)::9 + MarkupTextLiteral - [207..216)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [216..237)::21 + MarkupElement - [216..237)::21 + MarkupStartTag - [216..222)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[link]; + CloseAngle;[>]; + MarkupEndTag - [222..237)::15 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[link]; + MarkupMiscAttributeContent - [228..237)::9 + MarkupTextLiteral - [228..237)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [237..258)::21 + MarkupElement - [237..258)::21 + MarkupStartTag - [237..243)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[meta]; + CloseAngle;[>]; + MarkupEndTag - [243..258)::15 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[meta]; + MarkupMiscAttributeContent - [249..258)::9 + MarkupTextLiteral - [249..258)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [258..281)::23 + MarkupElement - [258..281)::23 + MarkupStartTag - [258..265)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[param]; + CloseAngle;[>]; + MarkupEndTag - [265..281)::16 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[param]; + MarkupMiscAttributeContent - [272..281)::9 + MarkupTextLiteral - [272..281)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [281..306)::25 + MarkupElement - [281..306)::25 + MarkupStartTag - [281..289)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[source]; + CloseAngle;[>]; + MarkupEndTag - [289..306)::17 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[source]; + MarkupMiscAttributeContent - [297..306)::9 + MarkupTextLiteral - [297..306)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [306..329)::23 + MarkupElement - [306..329)::23 + MarkupStartTag - [306..313)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[track]; + CloseAngle;[>]; + MarkupEndTag - [313..329)::16 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[track]; + MarkupMiscAttributeContent - [320..329)::9 + MarkupTextLiteral - [320..329)::9 - [LF}LF@{LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Transition;[@]; + Text;[{]; + NewLine;[LF]; + CloseAngle;[]; + MarkupBlock - [329..344)::15 + MarkupElement - [329..344)::15 + MarkupStartTag - [329..334)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[wbr]; + CloseAngle;[>]; + MarkupEndTag - [334..344)::10 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[wbr]; + MarkupMiscAttributeContent - [339..344)::5 + MarkupTextLiteral - [339..344)::5 - [LF}LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + CloseAngle;[]; + RazorMetaCode - [344..344)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ProcessingInstructionTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ProcessingInstructionTag.cspans.txt new file mode 100644 index 0000000000..88fd9b67b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ProcessingInstructionTag.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (2:0,2 [22] ) (Accepts:None) - Parent: Markup block at (2:0,2 [23] ) +Markup span at (24:0,24 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [23] ) +Code span at (25:0,25 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ProcessingInstructionTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ProcessingInstructionTag.stree.txt new file mode 100644 index 0000000000..e4bedcf75e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ProcessingInstructionTag.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..29)::29 - [@{ foo}] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpStatement - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..29)::28 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..28)::26 + MarkupBlock - [2..25)::23 + MarkupTextLiteral - [2..24)::22 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + Text;[version]; + Equals;[=]; + DoubleQuote;["]; + Text;[1.0]; + DoubleQuote;["]; + Whitespace;[ ]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [25..28)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Identifier;[foo]; + RazorMetaCode - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag.cspans.txt new file mode 100644 index 0000000000..aa831f9744 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [51] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [68] ) +Markup span at (59:0,59 [9] ) (Accepts:Any) - Parent: Tag block at (59:0,59 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag.stree.txt new file mode 100644 index 0000000000..4db3b75673 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..68)::68 - [] + MarkupBlock - [0..68)::68 + MarkupElement - [0..68)::68 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_Incomplete.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_Incomplete.cspans.txt new file mode 100644 index 0000000000..e0d652c62f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_Incomplete.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [13] ) +Markup span at (7:0,7 [6] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_Incomplete.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_Incomplete.stree.txt new file mode 100644 index 0000000000..ba558cdc92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_Incomplete.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..13)::13 - [ }] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + MarkupBlock - [2..24)::22 + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [3..23)::20 + MarkupStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + MarkupMiscAttributeContent - [19..22)::3 + MarkupTextLiteral - [19..22)::3 - [ @ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Transition;[@]; + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedBeginTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedBeginTag.cspans.txt new file mode 100644 index 0000000000..1ef22bf26d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedBeginTag.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Markup span at (11:0,11 [9] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedBeginTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedBeginTag.stree.txt new file mode 100644 index 0000000000..f083678670 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedBeginTag.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..20)::20 - [] + MarkupBlock - [0..20)::20 + MarkupElement - [0..20)::20 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedEndTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedEndTag.cspans.txt new file mode 100644 index 0000000000..57d975f8cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedEndTag.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Markup span at (12:0,12 [9] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedEndTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedEndTag.stree.txt new file mode 100644 index 0000000000..1c46bd12be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedEndTag.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..21)::21 - [] + MarkupBlock - [0..21)::21 + MarkupElement - [0..21)::21 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedMalformedTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedMalformedTag.cspans.txt new file mode 100644 index 0000000000..b041429d2d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedMalformedTag.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Markup span at (30:0,30 [9] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedMalformedTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedMalformedTag.stree.txt new file mode 100644 index 0000000000..28f8e4f59a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedMalformedTag.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..39)::39 - [] + MarkupBlock - [0..39)::39 + MarkupElement - [0..39)::39 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedTag.cspans.txt new file mode 100644 index 0000000000..be319647e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedTag.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Markup span at (15:0,15 [9] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedTag.stree.txt new file mode 100644 index 0000000000..b9e7bb8625 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/ScriptTag_WithNestedTag.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupElement - [0..24)::24 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/TextTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/TextTags.cspans.txt new file mode 100644 index 0000000000..b1018a5336 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/TextTags.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [16] ) +Transition span at (11:0,11 [7] ) (Accepts:None) - Parent: Tag block at (11:0,11 [7] ) +Code span at (18:0,18 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/TextTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/TextTags.stree.txt new file mode 100644 index 0000000000..1cad8510ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/TextTags.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..19)::19 - [@{Foo}] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpStatement - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..19)::18 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..18)::16 + MarkupBlock - [2..18)::16 + MarkupElement - [2..18)::16 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [8..11)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [11..18)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByCloseTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByCloseTag.cspans.txt new file mode 100644 index 0000000000..20e96c9595 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByCloseTag.cspans.txt @@ -0,0 +1,145 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (4:1,0 [6] ) (Accepts:None) - Parent: Tag block at (4:1,0 [6] ) +Markup span at (10:1,6 [1] ) (Accepts:Any) - Parent: Markup block at (4:1,0 [14] ) +Markup span at (11:1,7 [7] ) (Accepts:None) - Parent: Tag block at (11:1,7 [7] ) +Code span at (18:1,14 [15] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:2,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (36:3,0 [1] ) (Accepts:None) - Parent: Statement block at (36:3,0 [34] ) +MetaCode span at (37:3,1 [1] ) (Accepts:None) - Parent: Statement block at (36:3,0 [34] ) +Code span at (38:3,2 [2] ) (Accepts:Any) - Parent: Statement block at (36:3,0 [34] ) +Markup span at (40:4,0 [6] ) (Accepts:None) - Parent: Tag block at (40:4,0 [6] ) +Markup span at (46:4,6 [1] ) (Accepts:Any) - Parent: Markup block at (40:4,0 [14] ) +Markup span at (47:4,7 [7] ) (Accepts:None) - Parent: Tag block at (47:4,7 [7] ) +Code span at (54:4,14 [15] ) (Accepts:Any) - Parent: Statement block at (36:3,0 [34] ) +MetaCode span at (69:5,0 [1] ) (Accepts:None) - Parent: Statement block at (36:3,0 [34] ) +Markup span at (70:5,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (72:6,0 [1] ) (Accepts:None) - Parent: Statement block at (72:6,0 [30] ) +MetaCode span at (73:6,1 [1] ) (Accepts:None) - Parent: Statement block at (72:6,0 [30] ) +Code span at (74:6,2 [2] ) (Accepts:Any) - Parent: Statement block at (72:6,0 [30] ) +Markup span at (76:7,0 [4] ) (Accepts:None) - Parent: Tag block at (76:7,0 [4] ) +Markup span at (80:7,4 [1] ) (Accepts:Any) - Parent: Markup block at (76:7,0 [10] ) +Markup span at (81:7,5 [5] ) (Accepts:None) - Parent: Tag block at (81:7,5 [5] ) +Code span at (86:7,10 [15] ) (Accepts:Any) - Parent: Statement block at (72:6,0 [30] ) +MetaCode span at (101:8,0 [1] ) (Accepts:None) - Parent: Statement block at (72:6,0 [30] ) +Markup span at (102:8,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (104:9,0 [1] ) (Accepts:None) - Parent: Statement block at (104:9,0 [32] ) +MetaCode span at (105:9,1 [1] ) (Accepts:None) - Parent: Statement block at (104:9,0 [32] ) +Code span at (106:9,2 [2] ) (Accepts:Any) - Parent: Statement block at (104:9,0 [32] ) +Markup span at (108:10,0 [5] ) (Accepts:None) - Parent: Tag block at (108:10,0 [5] ) +Markup span at (113:10,5 [1] ) (Accepts:Any) - Parent: Markup block at (108:10,0 [12] ) +Markup span at (114:10,6 [6] ) (Accepts:None) - Parent: Tag block at (114:10,6 [6] ) +Code span at (120:10,12 [15] ) (Accepts:Any) - Parent: Statement block at (104:9,0 [32] ) +MetaCode span at (135:11,0 [1] ) (Accepts:None) - Parent: Statement block at (104:9,0 [32] ) +Markup span at (136:11,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (138:12,0 [1] ) (Accepts:None) - Parent: Statement block at (138:12,0 [40] ) +MetaCode span at (139:12,1 [1] ) (Accepts:None) - Parent: Statement block at (138:12,0 [40] ) +Code span at (140:12,2 [2] ) (Accepts:Any) - Parent: Statement block at (138:12,0 [40] ) +Markup span at (142:13,0 [9] ) (Accepts:None) - Parent: Tag block at (142:13,0 [9] ) +Markup span at (151:13,9 [1] ) (Accepts:Any) - Parent: Markup block at (142:13,0 [20] ) +Markup span at (152:13,10 [10] ) (Accepts:None) - Parent: Tag block at (152:13,10 [10] ) +Code span at (162:13,20 [15] ) (Accepts:Any) - Parent: Statement block at (138:12,0 [40] ) +MetaCode span at (177:14,0 [1] ) (Accepts:None) - Parent: Statement block at (138:12,0 [40] ) +Markup span at (178:14,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (180:15,0 [1] ) (Accepts:None) - Parent: Statement block at (180:15,0 [36] ) +MetaCode span at (181:15,1 [1] ) (Accepts:None) - Parent: Statement block at (180:15,0 [36] ) +Code span at (182:15,2 [2] ) (Accepts:Any) - Parent: Statement block at (180:15,0 [36] ) +Markup span at (184:16,0 [7] ) (Accepts:None) - Parent: Tag block at (184:16,0 [7] ) +Markup span at (191:16,7 [1] ) (Accepts:Any) - Parent: Markup block at (184:16,0 [16] ) +Markup span at (192:16,8 [8] ) (Accepts:None) - Parent: Tag block at (192:16,8 [8] ) +Code span at (200:16,16 [15] ) (Accepts:Any) - Parent: Statement block at (180:15,0 [36] ) +MetaCode span at (215:17,0 [1] ) (Accepts:None) - Parent: Statement block at (180:15,0 [36] ) +Markup span at (216:17,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (218:18,0 [1] ) (Accepts:None) - Parent: Statement block at (218:18,0 [30] ) +MetaCode span at (219:18,1 [1] ) (Accepts:None) - Parent: Statement block at (218:18,0 [30] ) +Code span at (220:18,2 [2] ) (Accepts:Any) - Parent: Statement block at (218:18,0 [30] ) +Markup span at (222:19,0 [4] ) (Accepts:None) - Parent: Tag block at (222:19,0 [4] ) +Markup span at (226:19,4 [1] ) (Accepts:Any) - Parent: Markup block at (222:19,0 [10] ) +Markup span at (227:19,5 [5] ) (Accepts:None) - Parent: Tag block at (227:19,5 [5] ) +Code span at (232:19,10 [15] ) (Accepts:Any) - Parent: Statement block at (218:18,0 [30] ) +MetaCode span at (247:20,0 [1] ) (Accepts:None) - Parent: Statement block at (218:18,0 [30] ) +Markup span at (248:20,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (250:21,0 [1] ) (Accepts:None) - Parent: Statement block at (250:21,0 [32] ) +MetaCode span at (251:21,1 [1] ) (Accepts:None) - Parent: Statement block at (250:21,0 [32] ) +Code span at (252:21,2 [2] ) (Accepts:Any) - Parent: Statement block at (250:21,0 [32] ) +Markup span at (254:22,0 [5] ) (Accepts:None) - Parent: Tag block at (254:22,0 [5] ) +Markup span at (259:22,5 [1] ) (Accepts:Any) - Parent: Markup block at (254:22,0 [12] ) +Markup span at (260:22,6 [6] ) (Accepts:None) - Parent: Tag block at (260:22,6 [6] ) +Code span at (266:22,12 [15] ) (Accepts:Any) - Parent: Statement block at (250:21,0 [32] ) +MetaCode span at (281:23,0 [1] ) (Accepts:None) - Parent: Statement block at (250:21,0 [32] ) +Markup span at (282:23,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (284:24,0 [1] ) (Accepts:None) - Parent: Statement block at (284:24,0 [36] ) +MetaCode span at (285:24,1 [1] ) (Accepts:None) - Parent: Statement block at (284:24,0 [36] ) +Code span at (286:24,2 [2] ) (Accepts:Any) - Parent: Statement block at (284:24,0 [36] ) +Markup span at (288:25,0 [7] ) (Accepts:None) - Parent: Tag block at (288:25,0 [7] ) +Markup span at (295:25,7 [1] ) (Accepts:Any) - Parent: Markup block at (288:25,0 [16] ) +Markup span at (296:25,8 [8] ) (Accepts:None) - Parent: Tag block at (296:25,8 [8] ) +Code span at (304:25,16 [15] ) (Accepts:Any) - Parent: Statement block at (284:24,0 [36] ) +MetaCode span at (319:26,0 [1] ) (Accepts:None) - Parent: Statement block at (284:24,0 [36] ) +Markup span at (320:26,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (322:27,0 [1] ) (Accepts:None) - Parent: Statement block at (322:27,0 [38] ) +MetaCode span at (323:27,1 [1] ) (Accepts:None) - Parent: Statement block at (322:27,0 [38] ) +Code span at (324:27,2 [2] ) (Accepts:Any) - Parent: Statement block at (322:27,0 [38] ) +Markup span at (326:28,0 [8] ) (Accepts:None) - Parent: Tag block at (326:28,0 [8] ) +Markup span at (334:28,8 [1] ) (Accepts:Any) - Parent: Markup block at (326:28,0 [18] ) +Markup span at (335:28,9 [9] ) (Accepts:None) - Parent: Tag block at (335:28,9 [9] ) +Code span at (344:28,18 [15] ) (Accepts:Any) - Parent: Statement block at (322:27,0 [38] ) +MetaCode span at (359:29,0 [1] ) (Accepts:None) - Parent: Statement block at (322:27,0 [38] ) +Markup span at (360:29,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (362:30,0 [1] ) (Accepts:None) - Parent: Statement block at (362:30,0 [34] ) +MetaCode span at (363:30,1 [1] ) (Accepts:None) - Parent: Statement block at (362:30,0 [34] ) +Code span at (364:30,2 [2] ) (Accepts:Any) - Parent: Statement block at (362:30,0 [34] ) +Markup span at (366:31,0 [6] ) (Accepts:None) - Parent: Tag block at (366:31,0 [6] ) +Markup span at (372:31,6 [1] ) (Accepts:Any) - Parent: Markup block at (366:31,0 [14] ) +Markup span at (373:31,7 [7] ) (Accepts:None) - Parent: Tag block at (373:31,7 [7] ) +Code span at (380:31,14 [15] ) (Accepts:Any) - Parent: Statement block at (362:30,0 [34] ) +MetaCode span at (395:32,0 [1] ) (Accepts:None) - Parent: Statement block at (362:30,0 [34] ) +Markup span at (396:32,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (398:33,0 [1] ) (Accepts:None) - Parent: Statement block at (398:33,0 [34] ) +MetaCode span at (399:33,1 [1] ) (Accepts:None) - Parent: Statement block at (398:33,0 [34] ) +Code span at (400:33,2 [2] ) (Accepts:Any) - Parent: Statement block at (398:33,0 [34] ) +Markup span at (402:34,0 [6] ) (Accepts:None) - Parent: Tag block at (402:34,0 [6] ) +Markup span at (408:34,6 [1] ) (Accepts:Any) - Parent: Markup block at (402:34,0 [14] ) +Markup span at (409:34,7 [7] ) (Accepts:None) - Parent: Tag block at (409:34,7 [7] ) +Code span at (416:34,14 [15] ) (Accepts:Any) - Parent: Statement block at (398:33,0 [34] ) +MetaCode span at (431:35,0 [1] ) (Accepts:None) - Parent: Statement block at (398:33,0 [34] ) +Markup span at (432:35,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (434:36,0 [1] ) (Accepts:None) - Parent: Statement block at (434:36,0 [36] ) +MetaCode span at (435:36,1 [1] ) (Accepts:None) - Parent: Statement block at (434:36,0 [36] ) +Code span at (436:36,2 [2] ) (Accepts:Any) - Parent: Statement block at (434:36,0 [36] ) +Markup span at (438:37,0 [7] ) (Accepts:None) - Parent: Tag block at (438:37,0 [7] ) +Markup span at (445:37,7 [1] ) (Accepts:Any) - Parent: Markup block at (438:37,0 [16] ) +Markup span at (446:37,8 [8] ) (Accepts:None) - Parent: Tag block at (446:37,8 [8] ) +Code span at (454:37,16 [15] ) (Accepts:Any) - Parent: Statement block at (434:36,0 [36] ) +MetaCode span at (469:38,0 [1] ) (Accepts:None) - Parent: Statement block at (434:36,0 [36] ) +Markup span at (470:38,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (472:39,0 [1] ) (Accepts:None) - Parent: Statement block at (472:39,0 [38] ) +MetaCode span at (473:39,1 [1] ) (Accepts:None) - Parent: Statement block at (472:39,0 [38] ) +Code span at (474:39,2 [2] ) (Accepts:Any) - Parent: Statement block at (472:39,0 [38] ) +Markup span at (476:40,0 [8] ) (Accepts:None) - Parent: Tag block at (476:40,0 [8] ) +Markup span at (484:40,8 [1] ) (Accepts:Any) - Parent: Markup block at (476:40,0 [18] ) +Markup span at (485:40,9 [9] ) (Accepts:None) - Parent: Tag block at (485:40,9 [9] ) +Code span at (494:40,18 [15] ) (Accepts:Any) - Parent: Statement block at (472:39,0 [38] ) +MetaCode span at (509:41,0 [1] ) (Accepts:None) - Parent: Statement block at (472:39,0 [38] ) +Markup span at (510:41,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (512:42,0 [1] ) (Accepts:None) - Parent: Statement block at (512:42,0 [36] ) +MetaCode span at (513:42,1 [1] ) (Accepts:None) - Parent: Statement block at (512:42,0 [36] ) +Code span at (514:42,2 [2] ) (Accepts:Any) - Parent: Statement block at (512:42,0 [36] ) +Markup span at (516:43,0 [7] ) (Accepts:None) - Parent: Tag block at (516:43,0 [7] ) +Markup span at (523:43,7 [1] ) (Accepts:Any) - Parent: Markup block at (516:43,0 [16] ) +Markup span at (524:43,8 [8] ) (Accepts:None) - Parent: Tag block at (524:43,8 [8] ) +Code span at (532:43,16 [15] ) (Accepts:Any) - Parent: Statement block at (512:42,0 [36] ) +MetaCode span at (547:44,0 [1] ) (Accepts:None) - Parent: Statement block at (512:42,0 [36] ) +Markup span at (548:44,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) +Transition span at (550:45,0 [1] ) (Accepts:None) - Parent: Statement block at (550:45,0 [32] ) +MetaCode span at (551:45,1 [1] ) (Accepts:None) - Parent: Statement block at (550:45,0 [32] ) +Code span at (552:45,2 [2] ) (Accepts:Any) - Parent: Statement block at (550:45,0 [32] ) +Markup span at (554:46,0 [5] ) (Accepts:None) - Parent: Tag block at (554:46,0 [5] ) +Markup span at (559:46,5 [1] ) (Accepts:Any) - Parent: Markup block at (554:46,0 [12] ) +Markup span at (560:46,6 [6] ) (Accepts:None) - Parent: Tag block at (560:46,6 [6] ) +Code span at (566:46,12 [15] ) (Accepts:Any) - Parent: Statement block at (550:45,0 [32] ) +MetaCode span at (581:47,0 [1] ) (Accepts:None) - Parent: Statement block at (550:45,0 [32] ) +Markup span at (582:47,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [584] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByCloseTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByCloseTag.stree.txt new file mode 100644 index 0000000000..35aacfaf7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByCloseTag.stree.txt @@ -0,0 +1,596 @@ +RazorDocument - [0..584)::584 - [@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF

                    var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF
                    var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF@{LF var x = true;LF}LF] + MarkupBlock - [0..584)::584 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [4..18)::14 + MarkupElement - [4..18)::14 + MarkupStartTag - [4..10)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[area]; + CloseAngle;[>]; + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [11..18)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[area]; + CloseAngle;[>]; + CSharpStatementLiteral - [18..33)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [34..36)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [36..70)::34 + CSharpStatement - [36..70)::34 + CSharpTransition - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [37..70)::33 + RazorMetaCode - [37..38)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [38..69)::31 + CSharpStatementLiteral - [38..40)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [40..54)::14 + MarkupElement - [40..54)::14 + MarkupStartTag - [40..46)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[base]; + CloseAngle;[>]; + MarkupTextLiteral - [46..47)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [47..54)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[base]; + CloseAngle;[>]; + CSharpStatementLiteral - [54..69)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [69..70)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [70..72)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [72..102)::30 + CSharpStatement - [72..102)::30 + CSharpTransition - [72..73)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [73..102)::29 + RazorMetaCode - [73..74)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [74..101)::27 + CSharpStatementLiteral - [74..76)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [76..86)::10 + MarkupElement - [76..86)::10 + MarkupStartTag - [76..80)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTextLiteral - [80..81)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [81..86)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[br]; + CloseAngle;[>]; + CSharpStatementLiteral - [86..101)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [101..102)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [102..104)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [104..136)::32 + CSharpStatement - [104..136)::32 + CSharpTransition - [104..105)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [105..136)::31 + RazorMetaCode - [105..106)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [106..135)::29 + CSharpStatementLiteral - [106..108)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [108..120)::12 + MarkupElement - [108..120)::12 + MarkupStartTag - [108..113)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[col]; + CloseAngle;[>]; + MarkupTextLiteral - [113..114)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [114..120)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[col]; + CloseAngle;[>]; + CSharpStatementLiteral - [120..135)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [135..136)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [136..138)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [138..178)::40 + CSharpStatement - [138..178)::40 + CSharpTransition - [138..139)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [139..178)::39 + RazorMetaCode - [139..140)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [140..177)::37 + CSharpStatementLiteral - [140..142)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [142..162)::20 + MarkupElement - [142..162)::20 + MarkupStartTag - [142..151)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[command]; + CloseAngle;[>]; + MarkupTextLiteral - [151..152)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [152..162)::10 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[command]; + CloseAngle;[>]; + CSharpStatementLiteral - [162..177)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [177..178)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [178..180)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [180..216)::36 + CSharpStatement - [180..216)::36 + CSharpTransition - [180..181)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [181..216)::35 + RazorMetaCode - [181..182)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [182..215)::33 + CSharpStatementLiteral - [182..184)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [184..200)::16 + MarkupElement - [184..200)::16 + MarkupStartTag - [184..191)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[embed]; + CloseAngle;[>]; + MarkupTextLiteral - [191..192)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [192..200)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[embed]; + CloseAngle;[>]; + CSharpStatementLiteral - [200..215)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [215..216)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [216..218)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [218..248)::30 + CSharpStatement - [218..248)::30 + CSharpTransition - [218..219)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [219..248)::29 + RazorMetaCode - [219..220)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [220..247)::27 + CSharpStatementLiteral - [220..222)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [222..232)::10 + MarkupElement - [222..232)::10 + MarkupStartTag - [222..226)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[hr]; + CloseAngle;[>]; + MarkupTextLiteral - [226..227)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [227..232)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[hr]; + CloseAngle;[>]; + CSharpStatementLiteral - [232..247)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [247..248)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [248..250)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [250..282)::32 + CSharpStatement - [250..282)::32 + CSharpTransition - [250..251)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [251..282)::31 + RazorMetaCode - [251..252)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [252..281)::29 + CSharpStatementLiteral - [252..254)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [254..266)::12 + MarkupElement - [254..266)::12 + MarkupStartTag - [254..259)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[img]; + CloseAngle;[>]; + MarkupTextLiteral - [259..260)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [260..266)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[img]; + CloseAngle;[>]; + CSharpStatementLiteral - [266..281)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [281..282)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [282..284)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [284..320)::36 + CSharpStatement - [284..320)::36 + CSharpTransition - [284..285)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [285..320)::35 + RazorMetaCode - [285..286)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [286..319)::33 + CSharpStatementLiteral - [286..288)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [288..304)::16 + MarkupElement - [288..304)::16 + MarkupStartTag - [288..295)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTextLiteral - [295..296)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [296..304)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; + CSharpStatementLiteral - [304..319)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [319..320)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [320..322)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [322..360)::38 + CSharpStatement - [322..360)::38 + CSharpTransition - [322..323)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [323..360)::37 + RazorMetaCode - [323..324)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [324..359)::35 + CSharpStatementLiteral - [324..326)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [326..344)::18 + MarkupElement - [326..344)::18 + MarkupStartTag - [326..334)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[keygen]; + CloseAngle;[>]; + MarkupTextLiteral - [334..335)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [335..344)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[keygen]; + CloseAngle;[>]; + CSharpStatementLiteral - [344..359)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [359..360)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [360..362)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [362..396)::34 + CSharpStatement - [362..396)::34 + CSharpTransition - [362..363)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [363..396)::33 + RazorMetaCode - [363..364)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [364..395)::31 + CSharpStatementLiteral - [364..366)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [366..380)::14 + MarkupElement - [366..380)::14 + MarkupStartTag - [366..372)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[link]; + CloseAngle;[>]; + MarkupTextLiteral - [372..373)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [373..380)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[link]; + CloseAngle;[>]; + CSharpStatementLiteral - [380..395)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [395..396)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [396..398)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [398..432)::34 + CSharpStatement - [398..432)::34 + CSharpTransition - [398..399)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [399..432)::33 + RazorMetaCode - [399..400)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [400..431)::31 + CSharpStatementLiteral - [400..402)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [402..416)::14 + MarkupElement - [402..416)::14 + MarkupStartTag - [402..408)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[meta]; + CloseAngle;[>]; + MarkupTextLiteral - [408..409)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [409..416)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[meta]; + CloseAngle;[>]; + CSharpStatementLiteral - [416..431)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [431..432)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [432..434)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [434..470)::36 + CSharpStatement - [434..470)::36 + CSharpTransition - [434..435)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [435..470)::35 + RazorMetaCode - [435..436)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [436..469)::33 + CSharpStatementLiteral - [436..438)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [438..454)::16 + MarkupElement - [438..454)::16 + MarkupStartTag - [438..445)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[param]; + CloseAngle;[>]; + MarkupTextLiteral - [445..446)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [446..454)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[param]; + CloseAngle;[>]; + CSharpStatementLiteral - [454..469)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [469..470)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [470..472)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [472..510)::38 + CSharpStatement - [472..510)::38 + CSharpTransition - [472..473)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [473..510)::37 + RazorMetaCode - [473..474)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [474..509)::35 + CSharpStatementLiteral - [474..476)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [476..494)::18 + MarkupElement - [476..494)::18 + MarkupStartTag - [476..484)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[source]; + CloseAngle;[>]; + MarkupTextLiteral - [484..485)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [485..494)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[source]; + CloseAngle;[>]; + CSharpStatementLiteral - [494..509)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [509..510)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [510..512)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [512..548)::36 + CSharpStatement - [512..548)::36 + CSharpTransition - [512..513)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [513..548)::35 + RazorMetaCode - [513..514)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [514..547)::33 + CSharpStatementLiteral - [514..516)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [516..532)::16 + MarkupElement - [516..532)::16 + MarkupStartTag - [516..523)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[track]; + CloseAngle;[>]; + MarkupTextLiteral - [523..524)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [524..532)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[track]; + CloseAngle;[>]; + CSharpStatementLiteral - [532..547)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [547..548)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [548..550)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [550..582)::32 + CSharpStatement - [550..582)::32 + CSharpTransition - [550..551)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [551..582)::31 + RazorMetaCode - [551..552)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [552..581)::29 + CSharpStatementLiteral - [552..554)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [554..566)::12 + MarkupElement - [554..566)::12 + MarkupStartTag - [554..559)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[wbr]; + CloseAngle;[>]; + MarkupTextLiteral - [559..560)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [560..566)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[wbr]; + CloseAngle;[>]; + CSharpStatementLiteral - [566..581)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [581..582)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [582..584)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByContent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByContent.cspans.txt new file mode 100644 index 0000000000..162d793f47 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByContent.cspans.txt @@ -0,0 +1,113 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (2:0,2 [2] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (4:1,0 [6] ) (Accepts:None) - Parent: Tag block at (4:1,0 [6] ) +Code span at (10:1,6 [15] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (25:2,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (26:2,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (28:3,0 [1] ) (Accepts:None) - Parent: Statement block at (28:3,0 [26] ) +MetaCode span at (29:3,1 [1] ) (Accepts:None) - Parent: Statement block at (28:3,0 [26] ) +Code span at (30:3,2 [2] ) (Accepts:Any) - Parent: Statement block at (28:3,0 [26] ) +Markup span at (32:4,0 [6] ) (Accepts:None) - Parent: Tag block at (32:4,0 [6] ) +Code span at (38:4,6 [15] ) (Accepts:Any) - Parent: Statement block at (28:3,0 [26] ) +MetaCode span at (53:5,0 [1] ) (Accepts:None) - Parent: Statement block at (28:3,0 [26] ) +Markup span at (54:5,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (56:6,0 [1] ) (Accepts:None) - Parent: Statement block at (56:6,0 [24] ) +MetaCode span at (57:6,1 [1] ) (Accepts:None) - Parent: Statement block at (56:6,0 [24] ) +Code span at (58:6,2 [2] ) (Accepts:Any) - Parent: Statement block at (56:6,0 [24] ) +Markup span at (60:7,0 [4] ) (Accepts:None) - Parent: Tag block at (60:7,0 [4] ) +Code span at (64:7,4 [15] ) (Accepts:Any) - Parent: Statement block at (56:6,0 [24] ) +MetaCode span at (79:8,0 [1] ) (Accepts:None) - Parent: Statement block at (56:6,0 [24] ) +Markup span at (80:8,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (82:9,0 [1] ) (Accepts:None) - Parent: Statement block at (82:9,0 [25] ) +MetaCode span at (83:9,1 [1] ) (Accepts:None) - Parent: Statement block at (82:9,0 [25] ) +Code span at (84:9,2 [2] ) (Accepts:Any) - Parent: Statement block at (82:9,0 [25] ) +Markup span at (86:10,0 [5] ) (Accepts:None) - Parent: Tag block at (86:10,0 [5] ) +Code span at (91:10,5 [15] ) (Accepts:Any) - Parent: Statement block at (82:9,0 [25] ) +MetaCode span at (106:11,0 [1] ) (Accepts:None) - Parent: Statement block at (82:9,0 [25] ) +Markup span at (107:11,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (109:12,0 [1] ) (Accepts:None) - Parent: Statement block at (109:12,0 [29] ) +MetaCode span at (110:12,1 [1] ) (Accepts:None) - Parent: Statement block at (109:12,0 [29] ) +Code span at (111:12,2 [2] ) (Accepts:Any) - Parent: Statement block at (109:12,0 [29] ) +Markup span at (113:13,0 [9] ) (Accepts:None) - Parent: Tag block at (113:13,0 [9] ) +Code span at (122:13,9 [15] ) (Accepts:Any) - Parent: Statement block at (109:12,0 [29] ) +MetaCode span at (137:14,0 [1] ) (Accepts:None) - Parent: Statement block at (109:12,0 [29] ) +Markup span at (138:14,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (140:15,0 [1] ) (Accepts:None) - Parent: Statement block at (140:15,0 [27] ) +MetaCode span at (141:15,1 [1] ) (Accepts:None) - Parent: Statement block at (140:15,0 [27] ) +Code span at (142:15,2 [2] ) (Accepts:Any) - Parent: Statement block at (140:15,0 [27] ) +Markup span at (144:16,0 [7] ) (Accepts:None) - Parent: Tag block at (144:16,0 [7] ) +Code span at (151:16,7 [15] ) (Accepts:Any) - Parent: Statement block at (140:15,0 [27] ) +MetaCode span at (166:17,0 [1] ) (Accepts:None) - Parent: Statement block at (140:15,0 [27] ) +Markup span at (167:17,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (169:18,0 [1] ) (Accepts:None) - Parent: Statement block at (169:18,0 [24] ) +MetaCode span at (170:18,1 [1] ) (Accepts:None) - Parent: Statement block at (169:18,0 [24] ) +Code span at (171:18,2 [2] ) (Accepts:Any) - Parent: Statement block at (169:18,0 [24] ) +Markup span at (173:19,0 [4] ) (Accepts:None) - Parent: Tag block at (173:19,0 [4] ) +Code span at (177:19,4 [15] ) (Accepts:Any) - Parent: Statement block at (169:18,0 [24] ) +MetaCode span at (192:20,0 [1] ) (Accepts:None) - Parent: Statement block at (169:18,0 [24] ) +Markup span at (193:20,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (195:21,0 [1] ) (Accepts:None) - Parent: Statement block at (195:21,0 [25] ) +MetaCode span at (196:21,1 [1] ) (Accepts:None) - Parent: Statement block at (195:21,0 [25] ) +Code span at (197:21,2 [2] ) (Accepts:Any) - Parent: Statement block at (195:21,0 [25] ) +Markup span at (199:22,0 [5] ) (Accepts:None) - Parent: Tag block at (199:22,0 [5] ) +Code span at (204:22,5 [15] ) (Accepts:Any) - Parent: Statement block at (195:21,0 [25] ) +MetaCode span at (219:23,0 [1] ) (Accepts:None) - Parent: Statement block at (195:21,0 [25] ) +Markup span at (220:23,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (222:24,0 [1] ) (Accepts:None) - Parent: Statement block at (222:24,0 [27] ) +MetaCode span at (223:24,1 [1] ) (Accepts:None) - Parent: Statement block at (222:24,0 [27] ) +Code span at (224:24,2 [2] ) (Accepts:Any) - Parent: Statement block at (222:24,0 [27] ) +Markup span at (226:25,0 [7] ) (Accepts:None) - Parent: Tag block at (226:25,0 [7] ) +Code span at (233:25,7 [15] ) (Accepts:Any) - Parent: Statement block at (222:24,0 [27] ) +MetaCode span at (248:26,0 [1] ) (Accepts:None) - Parent: Statement block at (222:24,0 [27] ) +Markup span at (249:26,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (251:27,0 [1] ) (Accepts:None) - Parent: Statement block at (251:27,0 [28] ) +MetaCode span at (252:27,1 [1] ) (Accepts:None) - Parent: Statement block at (251:27,0 [28] ) +Code span at (253:27,2 [2] ) (Accepts:Any) - Parent: Statement block at (251:27,0 [28] ) +Markup span at (255:28,0 [8] ) (Accepts:None) - Parent: Tag block at (255:28,0 [8] ) +Code span at (263:28,8 [15] ) (Accepts:Any) - Parent: Statement block at (251:27,0 [28] ) +MetaCode span at (278:29,0 [1] ) (Accepts:None) - Parent: Statement block at (251:27,0 [28] ) +Markup span at (279:29,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (281:30,0 [1] ) (Accepts:None) - Parent: Statement block at (281:30,0 [26] ) +MetaCode span at (282:30,1 [1] ) (Accepts:None) - Parent: Statement block at (281:30,0 [26] ) +Code span at (283:30,2 [2] ) (Accepts:Any) - Parent: Statement block at (281:30,0 [26] ) +Markup span at (285:31,0 [6] ) (Accepts:None) - Parent: Tag block at (285:31,0 [6] ) +Code span at (291:31,6 [15] ) (Accepts:Any) - Parent: Statement block at (281:30,0 [26] ) +MetaCode span at (306:32,0 [1] ) (Accepts:None) - Parent: Statement block at (281:30,0 [26] ) +Markup span at (307:32,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (309:33,0 [1] ) (Accepts:None) - Parent: Statement block at (309:33,0 [26] ) +MetaCode span at (310:33,1 [1] ) (Accepts:None) - Parent: Statement block at (309:33,0 [26] ) +Code span at (311:33,2 [2] ) (Accepts:Any) - Parent: Statement block at (309:33,0 [26] ) +Markup span at (313:34,0 [6] ) (Accepts:None) - Parent: Tag block at (313:34,0 [6] ) +Code span at (319:34,6 [15] ) (Accepts:Any) - Parent: Statement block at (309:33,0 [26] ) +MetaCode span at (334:35,0 [1] ) (Accepts:None) - Parent: Statement block at (309:33,0 [26] ) +Markup span at (335:35,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (337:36,0 [1] ) (Accepts:None) - Parent: Statement block at (337:36,0 [27] ) +MetaCode span at (338:36,1 [1] ) (Accepts:None) - Parent: Statement block at (337:36,0 [27] ) +Code span at (339:36,2 [2] ) (Accepts:Any) - Parent: Statement block at (337:36,0 [27] ) +Markup span at (341:37,0 [7] ) (Accepts:None) - Parent: Tag block at (341:37,0 [7] ) +Code span at (348:37,7 [15] ) (Accepts:Any) - Parent: Statement block at (337:36,0 [27] ) +MetaCode span at (363:38,0 [1] ) (Accepts:None) - Parent: Statement block at (337:36,0 [27] ) +Markup span at (364:38,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (366:39,0 [1] ) (Accepts:None) - Parent: Statement block at (366:39,0 [28] ) +MetaCode span at (367:39,1 [1] ) (Accepts:None) - Parent: Statement block at (366:39,0 [28] ) +Code span at (368:39,2 [2] ) (Accepts:Any) - Parent: Statement block at (366:39,0 [28] ) +Markup span at (370:40,0 [8] ) (Accepts:None) - Parent: Tag block at (370:40,0 [8] ) +Code span at (378:40,8 [15] ) (Accepts:Any) - Parent: Statement block at (366:39,0 [28] ) +MetaCode span at (393:41,0 [1] ) (Accepts:None) - Parent: Statement block at (366:39,0 [28] ) +Markup span at (394:41,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (396:42,0 [1] ) (Accepts:None) - Parent: Statement block at (396:42,0 [27] ) +MetaCode span at (397:42,1 [1] ) (Accepts:None) - Parent: Statement block at (396:42,0 [27] ) +Code span at (398:42,2 [2] ) (Accepts:Any) - Parent: Statement block at (396:42,0 [27] ) +Markup span at (400:43,0 [7] ) (Accepts:None) - Parent: Tag block at (400:43,0 [7] ) +Code span at (407:43,7 [15] ) (Accepts:Any) - Parent: Statement block at (396:42,0 [27] ) +MetaCode span at (422:44,0 [1] ) (Accepts:None) - Parent: Statement block at (396:42,0 [27] ) +Markup span at (423:44,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) +Transition span at (425:45,0 [1] ) (Accepts:None) - Parent: Statement block at (425:45,0 [25] ) +MetaCode span at (426:45,1 [1] ) (Accepts:None) - Parent: Statement block at (425:45,0 [25] ) +Code span at (427:45,2 [2] ) (Accepts:Any) - Parent: Statement block at (425:45,0 [25] ) +Markup span at (429:46,0 [5] ) (Accepts:None) - Parent: Tag block at (429:46,0 [5] ) +Code span at (434:46,5 [15] ) (Accepts:Any) - Parent: Statement block at (425:45,0 [25] ) +MetaCode span at (449:47,0 [1] ) (Accepts:None) - Parent: Statement block at (425:45,0 [25] ) +Markup span at (450:47,1 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [452] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByContent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByContent.stree.txt new file mode 100644 index 0000000000..3f081bc072 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByContent.stree.txt @@ -0,0 +1,484 @@ +RazorDocument - [0..452)::452 - [@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LF
                    var x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LF
                    var x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF@{LFvar x = true;LF}LF] + MarkupBlock - [0..452)::452 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..25)::23 + CSharpStatementLiteral - [2..4)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [4..10)::6 + MarkupElement - [4..10)::6 + MarkupStartTag - [4..10)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[area]; + CloseAngle;[>]; + CSharpStatementLiteral - [10..25)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [26..28)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [28..54)::26 + CSharpStatement - [28..54)::26 + CSharpTransition - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [29..54)::25 + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [30..53)::23 + CSharpStatementLiteral - [30..32)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [32..38)::6 + MarkupElement - [32..38)::6 + MarkupStartTag - [32..38)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[base]; + CloseAngle;[>]; + CSharpStatementLiteral - [38..53)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [54..56)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [56..80)::24 + CSharpStatement - [56..80)::24 + CSharpTransition - [56..57)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [57..80)::23 + RazorMetaCode - [57..58)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [58..79)::21 + CSharpStatementLiteral - [58..60)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [60..64)::4 + MarkupElement - [60..64)::4 + MarkupStartTag - [60..64)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + CSharpStatementLiteral - [64..79)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [79..80)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [80..82)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [82..107)::25 + CSharpStatement - [82..107)::25 + CSharpTransition - [82..83)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [83..107)::24 + RazorMetaCode - [83..84)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [84..106)::22 + CSharpStatementLiteral - [84..86)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [86..91)::5 + MarkupElement - [86..91)::5 + MarkupStartTag - [86..91)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[col]; + CloseAngle;[>]; + CSharpStatementLiteral - [91..106)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [106..107)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [107..109)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [109..138)::29 + CSharpStatement - [109..138)::29 + CSharpTransition - [109..110)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [110..138)::28 + RazorMetaCode - [110..111)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [111..137)::26 + CSharpStatementLiteral - [111..113)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [113..122)::9 + MarkupElement - [113..122)::9 + MarkupStartTag - [113..122)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[command]; + CloseAngle;[>]; + CSharpStatementLiteral - [122..137)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [137..138)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [138..140)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [140..167)::27 + CSharpStatement - [140..167)::27 + CSharpTransition - [140..141)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [141..167)::26 + RazorMetaCode - [141..142)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [142..166)::24 + CSharpStatementLiteral - [142..144)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [144..151)::7 + MarkupElement - [144..151)::7 + MarkupStartTag - [144..151)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[embed]; + CloseAngle;[>]; + CSharpStatementLiteral - [151..166)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [166..167)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [167..169)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [169..193)::24 + CSharpStatement - [169..193)::24 + CSharpTransition - [169..170)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [170..193)::23 + RazorMetaCode - [170..171)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [171..192)::21 + CSharpStatementLiteral - [171..173)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [173..177)::4 + MarkupElement - [173..177)::4 + MarkupStartTag - [173..177)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[hr]; + CloseAngle;[>]; + CSharpStatementLiteral - [177..192)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [192..193)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [193..195)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [195..220)::25 + CSharpStatement - [195..220)::25 + CSharpTransition - [195..196)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [196..220)::24 + RazorMetaCode - [196..197)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [197..219)::22 + CSharpStatementLiteral - [197..199)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [199..204)::5 + MarkupElement - [199..204)::5 + MarkupStartTag - [199..204)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[img]; + CloseAngle;[>]; + CSharpStatementLiteral - [204..219)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [219..220)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [220..222)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [222..249)::27 + CSharpStatement - [222..249)::27 + CSharpTransition - [222..223)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [223..249)::26 + RazorMetaCode - [223..224)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [224..248)::24 + CSharpStatementLiteral - [224..226)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [226..233)::7 + MarkupElement - [226..233)::7 + MarkupStartTag - [226..233)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + CSharpStatementLiteral - [233..248)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [248..249)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [249..251)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [251..279)::28 + CSharpStatement - [251..279)::28 + CSharpTransition - [251..252)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [252..279)::27 + RazorMetaCode - [252..253)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [253..278)::25 + CSharpStatementLiteral - [253..255)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [255..263)::8 + MarkupElement - [255..263)::8 + MarkupStartTag - [255..263)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[keygen]; + CloseAngle;[>]; + CSharpStatementLiteral - [263..278)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [278..279)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [279..281)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [281..307)::26 + CSharpStatement - [281..307)::26 + CSharpTransition - [281..282)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [282..307)::25 + RazorMetaCode - [282..283)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [283..306)::23 + CSharpStatementLiteral - [283..285)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [285..291)::6 + MarkupElement - [285..291)::6 + MarkupStartTag - [285..291)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[link]; + CloseAngle;[>]; + CSharpStatementLiteral - [291..306)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [306..307)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [307..309)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [309..335)::26 + CSharpStatement - [309..335)::26 + CSharpTransition - [309..310)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [310..335)::25 + RazorMetaCode - [310..311)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [311..334)::23 + CSharpStatementLiteral - [311..313)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [313..319)::6 + MarkupElement - [313..319)::6 + MarkupStartTag - [313..319)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[meta]; + CloseAngle;[>]; + CSharpStatementLiteral - [319..334)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [334..335)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [335..337)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [337..364)::27 + CSharpStatement - [337..364)::27 + CSharpTransition - [337..338)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [338..364)::26 + RazorMetaCode - [338..339)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [339..363)::24 + CSharpStatementLiteral - [339..341)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [341..348)::7 + MarkupElement - [341..348)::7 + MarkupStartTag - [341..348)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[param]; + CloseAngle;[>]; + CSharpStatementLiteral - [348..363)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [363..364)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [364..366)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [366..394)::28 + CSharpStatement - [366..394)::28 + CSharpTransition - [366..367)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [367..394)::27 + RazorMetaCode - [367..368)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [368..393)::25 + CSharpStatementLiteral - [368..370)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [370..378)::8 + MarkupElement - [370..378)::8 + MarkupStartTag - [370..378)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[source]; + CloseAngle;[>]; + CSharpStatementLiteral - [378..393)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [393..394)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [394..396)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [396..423)::27 + CSharpStatement - [396..423)::27 + CSharpTransition - [396..397)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [397..423)::26 + RazorMetaCode - [397..398)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [398..422)::24 + CSharpStatementLiteral - [398..400)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [400..407)::7 + MarkupElement - [400..407)::7 + MarkupStartTag - [400..407)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[track]; + CloseAngle;[>]; + CSharpStatementLiteral - [407..422)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [422..423)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [423..425)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [425..450)::25 + CSharpStatement - [425..450)::25 + CSharpTransition - [425..426)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [426..450)::24 + RazorMetaCode - [426..427)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [427..449)::22 + CSharpStatementLiteral - [427..429)::2 - [LF] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + NewLine;[LF]; + MarkupBlock - [429..434)::5 + MarkupElement - [429..434)::5 + MarkupStartTag - [429..434)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[wbr]; + CloseAngle;[>]; + CSharpStatementLiteral - [434..449)::15 - [var x = true;LF] - Gen - SpanEditHandler;Accepts:Any + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Keyword;[true]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [449..450)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [450..452)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByOtherTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByOtherTag.cspans.txt new file mode 100644 index 0000000000..22605d5bf1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByOtherTag.cspans.txt @@ -0,0 +1,49 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (3:1,0 [6] ) (Accepts:Any) - Parent: Tag block at (3:1,0 [6] ) +Markup span at (9:1,6 [7] ) (Accepts:Any) - Parent: Tag block at (9:1,6 [7] ) +Markup span at (16:1,13 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (38:4,0 [6] ) (Accepts:Any) - Parent: Tag block at (38:4,0 [6] ) +Markup span at (44:4,6 [7] ) (Accepts:Any) - Parent: Tag block at (44:4,6 [7] ) +Markup span at (51:4,13 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (73:7,0 [4] ) (Accepts:Any) - Parent: Tag block at (73:7,0 [4] ) +Markup span at (77:7,4 [7] ) (Accepts:Any) - Parent: Tag block at (77:7,4 [7] ) +Markup span at (84:7,11 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (106:10,0 [5] ) (Accepts:Any) - Parent: Tag block at (106:10,0 [5] ) +Markup span at (111:10,5 [7] ) (Accepts:Any) - Parent: Tag block at (111:10,5 [7] ) +Markup span at (118:10,12 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (140:13,0 [9] ) (Accepts:Any) - Parent: Tag block at (140:13,0 [9] ) +Markup span at (149:13,9 [7] ) (Accepts:Any) - Parent: Tag block at (149:13,9 [7] ) +Markup span at (156:13,16 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (178:16,0 [7] ) (Accepts:Any) - Parent: Tag block at (178:16,0 [7] ) +Markup span at (185:16,7 [7] ) (Accepts:Any) - Parent: Tag block at (185:16,7 [7] ) +Markup span at (192:16,14 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (214:19,0 [4] ) (Accepts:Any) - Parent: Tag block at (214:19,0 [4] ) +Markup span at (218:19,4 [7] ) (Accepts:Any) - Parent: Tag block at (218:19,4 [7] ) +Markup span at (225:19,11 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (247:22,0 [5] ) (Accepts:Any) - Parent: Tag block at (247:22,0 [5] ) +Markup span at (252:22,5 [7] ) (Accepts:Any) - Parent: Tag block at (252:22,5 [7] ) +Markup span at (259:22,12 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (281:25,0 [7] ) (Accepts:Any) - Parent: Tag block at (281:25,0 [7] ) +Markup span at (288:25,7 [7] ) (Accepts:Any) - Parent: Tag block at (288:25,7 [7] ) +Markup span at (295:25,14 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (317:28,0 [8] ) (Accepts:Any) - Parent: Tag block at (317:28,0 [8] ) +Markup span at (325:28,8 [7] ) (Accepts:Any) - Parent: Tag block at (325:28,8 [7] ) +Markup span at (332:28,15 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (354:31,0 [6] ) (Accepts:Any) - Parent: Tag block at (354:31,0 [6] ) +Markup span at (360:31,6 [7] ) (Accepts:Any) - Parent: Tag block at (360:31,6 [7] ) +Markup span at (367:31,13 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (389:34,0 [6] ) (Accepts:Any) - Parent: Tag block at (389:34,0 [6] ) +Markup span at (395:34,6 [7] ) (Accepts:Any) - Parent: Tag block at (395:34,6 [7] ) +Markup span at (402:34,13 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (424:37,0 [7] ) (Accepts:Any) - Parent: Tag block at (424:37,0 [7] ) +Markup span at (431:37,7 [7] ) (Accepts:Any) - Parent: Tag block at (431:37,7 [7] ) +Markup span at (438:37,14 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (460:40,0 [8] ) (Accepts:Any) - Parent: Tag block at (460:40,0 [8] ) +Markup span at (468:40,8 [7] ) (Accepts:Any) - Parent: Tag block at (468:40,8 [7] ) +Markup span at (475:40,15 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (497:43,0 [7] ) (Accepts:Any) - Parent: Tag block at (497:43,0 [7] ) +Markup span at (504:43,7 [7] ) (Accepts:Any) - Parent: Tag block at (504:43,7 [7] ) +Markup span at (511:43,14 [22] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) +Markup span at (533:46,0 [5] ) (Accepts:Any) - Parent: Tag block at (533:46,0 [5] ) +Markup span at (538:46,5 [7] ) (Accepts:Any) - Parent: Tag block at (538:46,5 [7] ) +Markup span at (545:46,12 [19] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [564] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByOtherTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByOtherTag.stree.txt new file mode 100644 index 0000000000..d323273f6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlTagsTest/VoidElementFollowedByOtherTag.stree.txt @@ -0,0 +1,387 @@ +RazorDocument - [0..564)::564 - [{LF var x = true;LF}LF{LF var x = true;LF}LF{LF
                    var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF
                    var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF{LF var x = true;LF}LF] + MarkupBlock - [0..564)::564 + MarkupTextLiteral - [0..3)::3 - [{LF] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + NewLine;[LF]; + MarkupElement - [3..9)::6 + MarkupStartTag - [3..9)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[area]; + CloseAngle;[>]; + MarkupElement - [9..564)::555 + MarkupStartTag - [9..16)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [16..38)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [38..44)::6 + MarkupStartTag - [38..44)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[base]; + CloseAngle;[>]; + MarkupElement - [44..564)::520 + MarkupStartTag - [44..51)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [51..73)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [73..77)::4 + MarkupStartTag - [73..77)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupElement - [77..564)::487 + MarkupStartTag - [77..84)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [84..106)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [106..111)::5 + MarkupStartTag - [106..111)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[col]; + CloseAngle;[>]; + MarkupElement - [111..564)::453 + MarkupStartTag - [111..118)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [118..140)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [140..149)::9 + MarkupStartTag - [140..149)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[command]; + CloseAngle;[>]; + MarkupElement - [149..564)::415 + MarkupStartTag - [149..156)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [156..178)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [178..185)::7 + MarkupStartTag - [178..185)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[embed]; + CloseAngle;[>]; + MarkupElement - [185..564)::379 + MarkupStartTag - [185..192)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [192..214)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [214..218)::4 + MarkupStartTag - [214..218)::4 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[hr]; + CloseAngle;[>]; + MarkupElement - [218..564)::346 + MarkupStartTag - [218..225)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [225..247)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [247..252)::5 + MarkupStartTag - [247..252)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[img]; + CloseAngle;[>]; + MarkupElement - [252..564)::312 + MarkupStartTag - [252..259)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [259..281)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [281..288)::7 + MarkupStartTag - [281..288)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupElement - [288..564)::276 + MarkupStartTag - [288..295)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [295..317)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [317..325)::8 + MarkupStartTag - [317..325)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[keygen]; + CloseAngle;[>]; + MarkupElement - [325..564)::239 + MarkupStartTag - [325..332)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [332..354)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [354..360)::6 + MarkupStartTag - [354..360)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[link]; + CloseAngle;[>]; + MarkupElement - [360..564)::204 + MarkupStartTag - [360..367)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [367..389)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [389..395)::6 + MarkupStartTag - [389..395)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[meta]; + CloseAngle;[>]; + MarkupElement - [395..564)::169 + MarkupStartTag - [395..402)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [402..424)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [424..431)::7 + MarkupStartTag - [424..431)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[param]; + CloseAngle;[>]; + MarkupElement - [431..564)::133 + MarkupStartTag - [431..438)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [438..460)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [460..468)::8 + MarkupStartTag - [460..468)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[source]; + CloseAngle;[>]; + MarkupElement - [468..564)::96 + MarkupStartTag - [468..475)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [475..497)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [497..504)::7 + MarkupStartTag - [497..504)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[track]; + CloseAngle;[>]; + MarkupElement - [504..564)::60 + MarkupStartTag - [504..511)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [511..533)::22 - [ var x = true;LF}LF{LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; + Text;[{]; + NewLine;[LF]; + MarkupElement - [533..538)::5 + MarkupStartTag - [533..538)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[wbr]; + CloseAngle;[>]; + MarkupElement - [538..564)::26 + MarkupStartTag - [538..545)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[other]; + CloseAngle;[>]; + MarkupTextLiteral - [545..564)::19 - [ var x = true;LF}LF] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[var]; + Whitespace;[ ]; + Text;[x]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[true;]; + NewLine;[LF]; + Text;[}]; + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode.cspans.txt new file mode 100644 index 0000000000..8e11fb5c0b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [98] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [98] ) +Code span at (2:0,2 [3] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [98] ) +Markup span at (5:0,5 [4] ) (Accepts:None) - Parent: Tag block at (5:0,5 [4] ) +Markup span at (9:0,9 [6] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [92] ) +Transition span at (15:1,4 [1] ) (Accepts:None) - Parent: Statement block at (15:1,4 [71] ) +Code span at (16:1,5 [38] ) (Accepts:Any) - Parent: Statement block at (15:1,4 [71] ) +Markup span at (54:2,8 [4] ) (Accepts:None) - Parent: Tag block at (54:2,8 [4] ) +Markup span at (58:2,12 [9] ) (Accepts:Any) - Parent: Markup block at (54:2,8 [25] ) +Transition span at (67:2,21 [1] ) (Accepts:None) - Parent: Expression block at (67:2,21 [7] ) +Code span at (68:2,22 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (67:2,21 [7] ) +Markup span at (74:2,28 [5] ) (Accepts:None) - Parent: Tag block at (74:2,28 [5] ) +Code span at (79:2,33 [7] ) (Accepts:None) - Parent: Statement block at (15:1,4 [71] ) +Markup span at (86:3,5 [6] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [92] ) +Markup span at (92:4,4 [5] ) (Accepts:None) - Parent: Tag block at (92:4,4 [5] ) +Code span at (97:4,9 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [98] ) +MetaCode span at (97:4,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [98] ) +Markup span at (98:4,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode.stree.txt new file mode 100644 index 0000000000..a29f4be9a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/CSharpCodeParserDoesNotAcceptLeadingOrTrailingWhitespaceInDesignMode.stree.txt @@ -0,0 +1,83 @@ +RazorDocument - [0..98)::98 - [@{
                      LF @foreach(var p in Products) {LF
                    • Product: @p.Name
                    • LF }LF
                    }] + MarkupBlock - [0..98)::98 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..98)::98 + CSharpStatement - [0..98)::98 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..98)::97 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..97)::95 + CSharpStatementLiteral - [2..5)::3 - [ ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + MarkupBlock - [5..97)::92 + MarkupElement - [5..97)::92 + MarkupStartTag - [5..9)::4 - [
                      ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[ul]; + CloseAngle;[>]; + MarkupTextLiteral - [9..15)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + CSharpCodeBlock - [15..86)::71 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [16..54)::38 - [foreach(var p in Products) {LF ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[p]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Products]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupBlock - [54..79)::25 + MarkupElement - [54..79)::25 + MarkupStartTag - [54..58)::4 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [58..67)::9 - [Product: ] - Gen - SpanEditHandler;Accepts:Any + Text;[Product:]; + Whitespace;[ ]; + CSharpCodeBlock - [67..74)::7 + CSharpImplicitExpression - [67..74)::7 + CSharpTransition - [67..68)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [68..74)::6 + CSharpCodeBlock - [68..74)::6 + CSharpExpressionLiteral - [68..74)::6 - [p.Name] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[p]; + Dot;[.]; + Identifier;[Name]; + MarkupEndTag - [74..79)::5 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[li]; + CloseAngle;[>]; + CSharpStatementLiteral - [79..86)::7 - [LF }] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + MarkupTextLiteral - [86..92)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupEndTag - [92..97)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; + CSharpStatementLiteral - [97..97)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [97..98)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [98..98)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.cspans.txt new file mode 100644 index 0000000000..cba8fd92de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [38] ) +Markup span at (4:0,4 [7] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [35] ) +Markup span at (11:0,11 [27] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [35] ) +Markup span at (38:0,38 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [35] ) +Markup span at (39:0,39 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [38] ) +Markup span at (40:0,40 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [50] ) +Markup span at (48:0,48 [4] ) (Accepts:None) - Parent: Tag block at (48:0,48 [4] ) +Code span at (52:0,52 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [53] ) +MetaCode span at (52:0,52 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [53] ) +Markup span at (53:0,53 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.stree.txt new file mode 100644 index 0000000000..99335b990d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInAttribute.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..53)::53 - [@{Email me}] + MarkupBlock - [0..53)::53 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..53)::53 + CSharpStatement - [0..53)::53 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..53)::52 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..52)::50 + MarkupBlock - [2..52)::50 + MarkupElement - [2..52)::50 + MarkupStartTag - [2..40)::38 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[a]; + MarkupAttributeBlock - [4..39)::35 - [ href="mailto:anurse@microsoft.com"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..9)::4 - [href] - Gen - SpanEditHandler;Accepts:Any + Text;[href]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..38)::27 + MarkupLiteralAttributeValue - [11..38)::27 - [mailto:anurse@microsoft.com] + MarkupTextLiteral - [11..38)::27 - [mailto:anurse@microsoft.com] - Gen - SpanEditHandler;Accepts:Any + Text;[mailto:anurse@microsoft.com]; + MarkupTextLiteral - [38..39)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [40..48)::8 - [Email me] - Gen - SpanEditHandler;Accepts:Any + Text;[Email]; + Whitespace;[ ]; + Text;[me]; + MarkupEndTag - [48..52)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[a]; + CloseAngle;[>]; + CSharpStatementLiteral - [52..52)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [52..53)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [53..53)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInText.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInText.cspans.txt new file mode 100644 index 0000000000..c0bfd264c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInText.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [20] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [31] ) +Markup span at (27:0,27 [6] ) (Accepts:None) - Parent: Tag block at (27:0,27 [6] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInText.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInText.stree.txt new file mode 100644 index 0000000000..41310fb85e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/DoesNotSwitchToCodeOnEmailAddressInText.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..34)::34 - [@{anurse@microsoft.com}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..27)::20 - [anurse@microsoft.com] - Gen - SpanEditHandler;Accepts:Any + Text;[anurse@microsoft.com]; + MarkupEndTag - [27..33)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt new file mode 100644 index 0000000000..769e4eeb3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt @@ -0,0 +1,22 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [98] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [98] ) +Markup span at (2:0,2 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [95] ) +Markup span at (5:0,5 [4] ) (Accepts:None) - Parent: Tag block at (5:0,5 [4] ) +Markup span at (9:0,9 [2] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [95] ) +Code span at (11:1,0 [4] ) (Accepts:Any) - Parent: Statement block at (11:1,0 [77] ) +Transition span at (15:1,4 [1] ) (Accepts:None) - Parent: Statement block at (11:1,0 [77] ) +Code span at (16:1,5 [30] ) (Accepts:Any) - Parent: Statement block at (11:1,0 [77] ) +Markup span at (46:2,0 [8] ) (Accepts:Any) - Parent: Markup block at (46:2,0 [35] ) +Markup span at (54:2,8 [4] ) (Accepts:None) - Parent: Tag block at (54:2,8 [4] ) +Markup span at (58:2,12 [9] ) (Accepts:Any) - Parent: Markup block at (46:2,0 [35] ) +Transition span at (67:2,21 [1] ) (Accepts:None) - Parent: Expression block at (67:2,21 [7] ) +Code span at (68:2,22 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (67:2,21 [7] ) +Markup span at (74:2,28 [5] ) (Accepts:None) - Parent: Tag block at (74:2,28 [5] ) +Markup span at (79:2,33 [2] ) (Accepts:None) - Parent: Markup block at (46:2,0 [35] ) +Code span at (81:3,0 [7] ) (Accepts:None) - Parent: Statement block at (11:1,0 [77] ) +Markup span at (88:4,0 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [95] ) +Markup span at (92:4,4 [5] ) (Accepts:None) - Parent: Tag block at (92:4,4 [5] ) +Code span at (97:4,9 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [98] ) +MetaCode span at (97:4,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [98] ) +Markup span at (98:4,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [98] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt new file mode 100644 index 0000000000..1025586c6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/GivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt @@ -0,0 +1,86 @@ +RazorDocument - [0..98)::98 - [@{
                      LF @foreach(var p in Products) {LF
                    • Product: @p.Name
                    • LF }LF
                    }] + MarkupBlock - [0..98)::98 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..98)::98 + CSharpStatement - [0..98)::98 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..98)::97 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..97)::95 + MarkupBlock - [2..97)::95 + MarkupTextLiteral - [2..5)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [5..97)::92 + MarkupStartTag - [5..9)::4 - [
                      ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[ul]; + CloseAngle;[>]; + MarkupTextLiteral - [9..11)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [11..88)::77 + CSharpStatementLiteral - [11..15)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [16..46)::30 - [foreach(var p in Products) {LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[p]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Products]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [46..81)::35 + MarkupTextLiteral - [46..54)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [54..79)::25 + MarkupStartTag - [54..58)::4 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [58..67)::9 - [Product: ] - Gen - SpanEditHandler;Accepts:Any + Text;[Product:]; + Whitespace;[ ]; + CSharpCodeBlock - [67..74)::7 + CSharpImplicitExpression - [67..74)::7 + CSharpTransition - [67..68)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [68..74)::6 + CSharpCodeBlock - [68..74)::6 + CSharpExpressionLiteral - [68..74)::6 - [p.Name] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[p]; + Dot;[.]; + Identifier;[Name]; + MarkupEndTag - [74..79)::5 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [79..81)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [81..88)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [88..92)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [92..97)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; + CSharpStatementLiteral - [97..97)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [97..98)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [98..98)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt new file mode 100644 index 0000000000..5b382487b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) +Markup span at (3:0,3 [4] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) +Markup span at (7:0,7 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) +Code span at (9:1,0 [4] ) (Accepts:Any) - Parent: Statement block at (9:1,0 [77] ) +Transition span at (13:1,4 [1] ) (Accepts:None) - Parent: Statement block at (9:1,0 [77] ) +Code span at (14:1,5 [30] ) (Accepts:Any) - Parent: Statement block at (9:1,0 [77] ) +Markup span at (44:2,0 [8] ) (Accepts:Any) - Parent: Markup block at (44:2,0 [35] ) +Markup span at (52:2,8 [4] ) (Accepts:None) - Parent: Tag block at (52:2,8 [4] ) +Markup span at (56:2,12 [9] ) (Accepts:Any) - Parent: Markup block at (44:2,0 [35] ) +Transition span at (65:2,21 [1] ) (Accepts:None) - Parent: Expression block at (65:2,21 [7] ) +Code span at (66:2,22 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (65:2,21 [7] ) +Markup span at (72:2,28 [5] ) (Accepts:None) - Parent: Tag block at (72:2,28 [5] ) +Markup span at (77:2,33 [2] ) (Accepts:None) - Parent: Markup block at (44:2,0 [35] ) +Code span at (79:3,0 [7] ) (Accepts:None) - Parent: Statement block at (9:1,0 [77] ) +Markup span at (86:4,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [95] ) +Markup span at (90:4,4 [5] ) (Accepts:Any) - Parent: Tag block at (90:4,4 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt new file mode 100644 index 0000000000..bdb122a309 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt @@ -0,0 +1,69 @@ +RazorDocument - [0..95)::95 - [
                      LF @foreach(var p in Products) {LF
                    • Product: @p.Name
                    • LF }LF
                    ] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..3)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [3..95)::92 + MarkupStartTag - [3..7)::4 - [
                      ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[ul]; + CloseAngle;[>]; + MarkupTextLiteral - [7..9)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [9..86)::77 + CSharpStatementLiteral - [9..13)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [14..44)::30 - [foreach(var p in Products) {LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[p]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Products]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [44..79)::35 + MarkupTextLiteral - [44..52)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [52..77)::25 + MarkupStartTag - [52..56)::4 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [56..65)::9 - [Product: ] - Gen - SpanEditHandler;Accepts:Any + Text;[Product:]; + Whitespace;[ ]; + CSharpCodeBlock - [65..72)::7 + CSharpImplicitExpression - [65..72)::7 + CSharpTransition - [65..66)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [66..72)::6 + CSharpCodeBlock - [66..72)::6 + CSharpExpressionLiteral - [66..72)::6 - [p.Name] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[p]; + Dot;[.]; + Identifier;[Name]; + MarkupEndTag - [72..77)::5 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [77..79)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [79..86)::7 - [ }LF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [86..90)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [90..95)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence.cspans.txt new file mode 100644 index 0000000000..f524279da0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Markup span at (6:0,6 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Markup span at (7:0,7 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Markup span at (8:0,8 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (9:0,9 [4] ) +Code span at (10:0,10 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (9:0,9 [4] ) +Markup span at (13:0,13 [6] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence.stree.txt new file mode 100644 index 0000000000..66e1ca4faa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsPairsOfAtSignsAsEscapeSequence.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..19)::19 - [@@@@@bar] + MarkupBlock - [0..19)::19 + MarkupElement - [0..19)::19 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupEphemeralTextLiteral - [5..6)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [6..7)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupEphemeralTextLiteral - [7..8)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [8..9)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + CSharpCodeBlock - [9..13)::4 + CSharpImplicitExpression - [9..13)::4 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [10..13)::3 + CSharpCodeBlock - [10..13)::3 + CSharpExpressionLiteral - [10..13)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupEndTag - [13..19)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsTwoAtSignsAsEscapeSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsTwoAtSignsAsEscapeSequence.cspans.txt new file mode 100644 index 0000000000..beb66d05e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsTwoAtSignsAsEscapeSequence.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Markup span at (6:0,6 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Markup span at (10:0,10 [6] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsTwoAtSignsAsEscapeSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsTwoAtSignsAsEscapeSequence.stree.txt new file mode 100644 index 0000000000..9408db763d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParseDocumentTreatsTwoAtSignsAsEscapeSequence.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..16)::16 - [@@bar] + MarkupBlock - [0..16)::16 + MarkupElement - [0..16)::16 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupEphemeralTextLiteral - [5..6)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [6..10)::4 - [@bar] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Text;[bar]; + MarkupEndTag - [10..16)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParsesCodeWithinSingleLineMarkup.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParsesCodeWithinSingleLineMarkup.cspans.txt new file mode 100644 index 0000000000..a25c9be457 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParsesCodeWithinSingleLineMarkup.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Markup block at (2:0,2 [20] ) +MetaCode span at (3:0,3 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [20] ) +Markup span at (4:0,4 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [20] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [4] ) +Code span at (13:0,13 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [4] ) +Markup span at (16:0,16 [6] ) (Accepts:None) - Parent: Markup block at (2:0,2 [20] ) +Code span at (22:1,0 [4] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:1,4 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:1,5 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParsesCodeWithinSingleLineMarkup.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParsesCodeWithinSingleLineMarkup.stree.txt new file mode 100644 index 0000000000..20c3e121d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/ParsesCodeWithinSingleLineMarkup.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..27)::27 - [@{@:
                  • Foo @Bar BazLFbork}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..22)::20 + MarkupTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorMetaCode - [3..4)::1 - Gen - SpanEditHandler;Accepts:Any + Colon;[:]; + MarkupTextLiteral - [4..12)::8 - [
                  • Foo ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + Text;[Foo]; + Whitespace;[ ]; + CSharpCodeBlock - [12..16)::4 + CSharpImplicitExpression - [12..16)::4 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..16)::3 + CSharpCodeBlock - [13..16)::3 + CSharpExpressionLiteral - [13..16)::3 - [Bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[Bar]; + MarkupTextLiteral - [16..22)::6 - [ BazLF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[Baz]; + NewLine;[LF]; + CSharpStatementLiteral - [22..26)::4 - [bork] - Gen - SpanEditHandler;Accepts:Any + Identifier;[bork]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsPairsOfAtSignsAsEscapeSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsPairsOfAtSignsAsEscapeSequence.cspans.txt new file mode 100644 index 0000000000..27a97571b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsPairsOfAtSignsAsEscapeSequence.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [36] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [36] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [36] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [36] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [36] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [36] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [21] ) +Markup span at (15:0,15 [5] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [5] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [21] ) +Markup span at (21:0,21 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [21] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [21] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [21] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Expression block at (24:0,24 [4] ) +Code span at (25:0,25 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (24:0,24 [4] ) +Markup span at (28:0,28 [6] ) (Accepts:Any) - Parent: Tag block at (28:0,28 [6] ) +Markup span at (34:0,34 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [21] ) +MetaCode span at (35:0,35 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [36] ) +Markup span at (36:0,36 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsPairsOfAtSignsAsEscapeSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsPairsOfAtSignsAsEscapeSequence.stree.txt new file mode 100644 index 0000000000..e490f7e131 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsPairsOfAtSignsAsEscapeSequence.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..36)::36 - [@section Foo { @@@@@bar }] + MarkupBlock - [0..36)::36 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..36)::36 + RazorDirective - [0..36)::36 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..36)::35 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..36)::28 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..35)::21 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..34)::19 + MarkupStartTag - [15..20)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupEphemeralTextLiteral - [20..21)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [21..22)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupEphemeralTextLiteral - [22..23)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [23..24)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + CSharpCodeBlock - [24..28)::4 + CSharpImplicitExpression - [24..28)::4 + CSharpTransition - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [25..28)::3 + CSharpCodeBlock - [25..28)::3 + CSharpExpressionLiteral - [25..28)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[bar]; + MarkupEndTag - [28..34)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [35..36)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsTwoAtSignsAsEscapeSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsTwoAtSignsAsEscapeSequence.cspans.txt new file mode 100644 index 0000000000..f966801338 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsTwoAtSignsAsEscapeSequence.cspans.txt @@ -0,0 +1,15 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (9:0,9 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [33] ) +None span at (12:0,12 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [18] ) +Markup span at (15:0,15 [5] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [5] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [18] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [18] ) +Markup span at (25:0,25 [6] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [6] ) +Markup span at (31:0,31 [1] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [18] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsTwoAtSignsAsEscapeSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsTwoAtSignsAsEscapeSequence.stree.txt new file mode 100644 index 0000000000..eb51d6aa1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionBodyTreatsTwoAtSignsAsEscapeSequence.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..33)::33 - [@section Foo { @@bar }] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + RazorDirective - [0..33)::33 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..33)::32 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..33)::25 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..12)::3 - [Foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Foo]; + UnclassifiedTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [14..32)::18 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [15..31)::16 + MarkupStartTag - [15..20)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupEphemeralTextLiteral - [20..21)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [21..25)::4 - [@bar] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Text;[bar]; + MarkupEndTag - [25..31)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt new file mode 100644 index 0000000000..3529ce293f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.cspans.txt @@ -0,0 +1,31 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [130] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [130] ) +Code span at (2:0,2 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [130] ) +Transition span at (2:0,2 [1] ) (Accepts:None) - Parent: Directive block at (2:0,2 [127] ) +MetaCode span at (3:0,3 [7] ) (Accepts:None) - Parent: Directive block at (2:0,2 [127] ) +Code span at (10:0,10 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:0,2 [127] ) +Code span at (11:0,11 [3] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:0,2 [127] ) +None span at (14:0,14 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (2:0,2 [127] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (2:0,2 [127] ) +Markup span at (16:0,16 [6] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [112] ) +Markup span at (22:1,4 [4] ) (Accepts:Any) - Parent: Tag block at (22:1,4 [4] ) +Markup span at (26:1,8 [2] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [112] ) +Code span at (28:2,0 [8] ) (Accepts:Any) - Parent: Statement block at (28:2,0 [89] ) +Transition span at (36:2,8 [1] ) (Accepts:None) - Parent: Statement block at (28:2,0 [89] ) +Code span at (37:2,9 [30] ) (Accepts:Any) - Parent: Statement block at (28:2,0 [89] ) +Markup span at (67:3,0 [12] ) (Accepts:Any) - Parent: Markup block at (67:3,0 [39] ) +Markup span at (79:3,12 [4] ) (Accepts:None) - Parent: Tag block at (79:3,12 [4] ) +Markup span at (83:3,16 [9] ) (Accepts:Any) - Parent: Markup block at (67:3,0 [39] ) +Transition span at (92:3,25 [1] ) (Accepts:None) - Parent: Expression block at (92:3,25 [7] ) +Code span at (93:3,26 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (92:3,25 [7] ) +Markup span at (99:3,32 [5] ) (Accepts:None) - Parent: Tag block at (99:3,32 [5] ) +Markup span at (104:3,37 [2] ) (Accepts:None) - Parent: Markup block at (67:3,0 [39] ) +Code span at (106:4,0 [11] ) (Accepts:None) - Parent: Statement block at (28:2,0 [89] ) +Markup span at (117:5,0 [4] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [112] ) +Markup span at (121:5,4 [5] ) (Accepts:Any) - Parent: Tag block at (121:5,4 [5] ) +Markup span at (126:5,9 [2] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [112] ) +MetaCode span at (128:6,0 [1] ) (Accepts:None) - Parent: Directive block at (2:0,2 [127] ) +Code span at (129:6,1 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [130] ) +MetaCode span at (129:6,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [130] ) +Markup span at (130:6,2 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.diag.txt new file mode 100644 index 0000000000..82834fee1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2005: The 'section` directive must appear at the start of the line. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt new file mode 100644 index 0000000000..3f3c933778 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SectionContextGivesWhitespacePreceedingToCodeIfThereIsNoMarkupOnThatLine.stree.txt @@ -0,0 +1,109 @@ +RazorDocument - [0..130)::130 - [@{@section foo {LF
                      LF @foreach(var p in Products) {LF
                    • Product: @p.Name
                    • LF }LF
                    LF}}] + MarkupBlock - [0..130)::130 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..130)::130 + CSharpStatement - [0..130)::130 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..130)::129 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..129)::127 + CSharpStatementLiteral - [2..2)::0 - [] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Marker;[]; + CSharpCodeBlock - [2..129)::127 + RazorDirective - [2..129)::127 - Directive:{section;RazorBlock;Unrestricted} [RZ2005(3:0,3 [7] )] + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..129)::126 + RazorMetaCode - [3..10)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [10..129)::119 + CSharpStatementLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [11..14)::3 - [foo] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[foo]; + UnclassifiedTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [15..16)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [16..128)::112 + MarkupTextLiteral - [16..22)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [22..126)::104 + MarkupStartTag - [22..26)::4 - [
                      ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[ul]; + CloseAngle;[>]; + MarkupTextLiteral - [26..28)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [28..117)::89 + CSharpStatementLiteral - [28..36)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpTransition - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [37..67)::30 - [foreach(var p in Products) {LF] - Gen - SpanEditHandler;Accepts:Any + Keyword;[foreach]; + LeftParenthesis;[(]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[p]; + Whitespace;[ ]; + Keyword;[in]; + Whitespace;[ ]; + Identifier;[Products]; + RightParenthesis;[)]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [67..106)::39 + MarkupTextLiteral - [67..79)::12 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [79..104)::25 + MarkupStartTag - [79..83)::4 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [83..92)::9 - [Product: ] - Gen - SpanEditHandler;Accepts:Any + Text;[Product:]; + Whitespace;[ ]; + CSharpCodeBlock - [92..99)::7 + CSharpImplicitExpression - [92..99)::7 + CSharpTransition - [92..93)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [93..99)::6 + CSharpCodeBlock - [93..99)::6 + CSharpExpressionLiteral - [93..99)::6 - [p.Name] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 + Identifier;[p]; + Dot;[.]; + Identifier;[Name]; + MarkupEndTag - [99..104)::5 - [
                    • ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[li]; + CloseAngle;[>]; + MarkupTextLiteral - [104..106)::2 - [LF] - Gen - SpanEditHandler;Accepts:None + NewLine;[LF]; + CSharpStatementLiteral - [106..117)::11 - [ }LF] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [117..121)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupEndTag - [121..126)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; + MarkupTextLiteral - [126..128)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + RazorMetaCode - [128..129)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + CSharpStatementLiteral - [129..129)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [129..130)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [130..130)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinCDataDeclaration.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinCDataDeclaration.cspans.txt new file mode 100644 index 0000000000..371d673f22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinCDataDeclaration.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [14] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [36] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [4] ) +Code span at (22:0,22 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [4] ) +Markup span at (25:0,25 [7] ) (Accepts:None) - Parent: Markup block at (2:0,2 [36] ) +Markup span at (32:0,32 [6] ) (Accepts:None) - Parent: Tag block at (32:0,32 [6] ) +Code span at (38:0,38 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [39] ) +MetaCode span at (38:0,38 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [39] ) +Markup span at (39:0,39 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinCDataDeclaration.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinCDataDeclaration.stree.txt new file mode 100644 index 0000000000..4a63f88741 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinCDataDeclaration.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..39)::39 - [@{}] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..39)::39 + CSharpStatement - [0..39)::39 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..39)::38 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..38)::36 + MarkupBlock - [2..38)::36 + MarkupElement - [2..38)::36 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..21)::14 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + LeftBracket;[[]; + Text;[CDATA]; + LeftBracket;[[]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + CSharpCodeBlock - [21..25)::4 + CSharpImplicitExpression - [21..25)::4 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..25)::3 + CSharpCodeBlock - [22..25)::3 + CSharpExpressionLiteral - [22..25)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [25..32)::7 - [ baz]]>] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[baz]; + RightBracket;[]]; + RightBracket;[]]; + CloseAngle;[>]; + MarkupEndTag - [32..38)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [38..38)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [38..39)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [39..39)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinComment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinComment.cspans.txt new file mode 100644 index 0000000000..d8bbd6e465 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinComment.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [4] ) (Accepts:None) - Parent: HtmlComment block at (7:0,7 [13] ) +Markup span at (11:0,11 [1] ) (Accepts:Whitespace) - Parent: HtmlComment block at (7:0,7 [13] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [4] ) +Code span at (13:0,13 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [4] ) +Markup span at (16:0,16 [1] ) (Accepts:Whitespace) - Parent: HtmlComment block at (7:0,7 [13] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: HtmlComment block at (7:0,7 [13] ) +Markup span at (20:0,20 [6] ) (Accepts:None) - Parent: Tag block at (20:0,20 [6] ) +Code span at (26:0,26 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinComment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinComment.stree.txt new file mode 100644 index 0000000000..ae10fe3b1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinComment.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..27)::27 - [@{}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..26)::24 + MarkupElement - [2..26)::24 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupCommentBlock - [7..20)::13 + MarkupTextLiteral - [7..11)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [20..26)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinSGMLDeclaration.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinSGMLDeclaration.cspans.txt new file mode 100644 index 0000000000..154020ea7c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinSGMLDeclaration.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [14] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [34] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [4] ) +Code span at (22:0,22 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [4] ) +Markup span at (25:0,25 [5] ) (Accepts:None) - Parent: Markup block at (2:0,2 [34] ) +Markup span at (30:0,30 [6] ) (Accepts:None) - Parent: Tag block at (30:0,30 [6] ) +Code span at (36:0,36 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [37] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [37] ) +Markup span at (37:0,37 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinSGMLDeclaration.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinSGMLDeclaration.stree.txt new file mode 100644 index 0000000000..72803b9925 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinSGMLDeclaration.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..37)::37 - [@{}] + MarkupBlock - [0..37)::37 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..37)::37 + CSharpStatement - [0..37)::37 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..37)::36 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..36)::34 + MarkupBlock - [2..36)::34 + MarkupElement - [2..36)::34 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..21)::14 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[DOCTYPE]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + CSharpCodeBlock - [21..25)::4 + CSharpImplicitExpression - [21..25)::4 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..25)::3 + CSharpCodeBlock - [22..25)::3 + CSharpExpressionLiteral - [22..25)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [25..30)::5 - [ baz>] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[baz]; + CloseAngle;[>]; + MarkupEndTag - [30..36)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [36..36)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [37..37)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinXMLProcessingInstruction.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinXMLProcessingInstruction.cspans.txt new file mode 100644 index 0000000000..a1e6d33dba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinXMLProcessingInstruction.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [10] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [31] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Expression block at (17:0,17 [4] ) +Code span at (18:0,18 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (17:0,17 [4] ) +Markup span at (21:0,21 [6] ) (Accepts:None) - Parent: Markup block at (2:0,2 [31] ) +Markup span at (27:0,27 [6] ) (Accepts:None) - Parent: Tag block at (27:0,27 [6] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinXMLProcessingInstruction.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinXMLProcessingInstruction.stree.txt new file mode 100644 index 0000000000..9a734b0002 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SupportsCodeWithinXMLProcessingInstruction.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..34)::34 - [@{}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..17)::10 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + Text;[foo]; + Whitespace;[ ]; + CSharpCodeBlock - [17..21)::4 + CSharpImplicitExpression - [17..21)::4 + CSharpTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [18..21)::3 + CSharpCodeBlock - [18..21)::3 + CSharpExpressionLiteral - [18..21)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [21..27)::6 - [ baz?>] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Text;[baz]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupEndTag - [27..33)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue.cspans.txt new file mode 100644 index 0000000000..90f540af15 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [11] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [4] ) +Code span at (13:0,13 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [4] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (6:0,6 [11] ) +Markup span at (17:0,17 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [18] ) +Code span at (20:0,20 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue.stree.txt new file mode 100644 index 0000000000..bd98e054cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..21)::21 - [@{}] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..20)::18 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + MarkupAttributeBlock - [6..17)::11 - [ bar="@baz"] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..10)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [12..16)::4 + MarkupDynamicAttributeValue - [12..16)::4 - [@baz] + GenericBlock - [12..16)::4 + CSharpCodeBlock - [12..16)::4 + CSharpImplicitExpression - [12..16)::4 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..16)::3 + CSharpCodeBlock - [13..16)::3 + CSharpExpressionLiteral - [13..16)::3 - [baz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[baz]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInTagContent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInTagContent.cspans.txt new file mode 100644 index 0000000000..5cd3fa4a4e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInTagContent.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [0] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [30] ) +Transition span at (7:0,7 [1] ) (Accepts:None) - Parent: Expression block at (7:0,7 [4] ) +Code span at (8:0,8 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (7:0,7 [4] ) +Markup span at (11:0,11 [5] ) (Accepts:None) - Parent: Tag block at (11:0,11 [5] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [30] ) +Transition span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (16:0,16 [4] ) +Code span at (17:0,17 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (16:0,16 [4] ) +Markup span at (20:0,20 [6] ) (Accepts:None) - Parent: Tag block at (20:0,20 [6] ) +Markup span at (26:0,26 [6] ) (Accepts:None) - Parent: Tag block at (26:0,26 [6] ) +Code span at (32:0,32 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInTagContent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInTagContent.stree.txt new file mode 100644 index 0000000000..2b06ed1e3a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredInTagContent.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..33)::33 - [@{@bar@boz}] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + CSharpStatement - [0..33)::33 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..33)::32 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..32)::30 + MarkupBlock - [2..32)::30 + MarkupElement - [2..32)::30 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [7..7)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [7..11)::4 + CSharpImplicitExpression - [7..11)::4 + CSharpTransition - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [8..11)::3 + CSharpCodeBlock - [8..11)::3 + CSharpExpressionLiteral - [8..11)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupElement - [11..26)::15 + MarkupStartTag - [11..16)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[baz]; + CloseAngle;[>]; + MarkupTextLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [16..20)::4 + CSharpImplicitExpression - [16..20)::4 + CSharpTransition - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [17..20)::3 + CSharpCodeBlock - [17..20)::3 + CSharpExpressionLiteral - [17..20)::3 - [boz] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[boz]; + MarkupEndTag - [20..26)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[baz]; + CloseAngle;[>]; + MarkupEndTag - [26..32)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredMidTag.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredMidTag.cspans.txt new file mode 100644 index 0000000000..d760958c1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredMidTag.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (2:0,2 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [12] ) +Transition span at (7:0,7 [1] ) (Accepts:None) - Parent: Expression block at (7:0,7 [4] ) +Code span at (8:0,8 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (7:0,7 [4] ) +Markup span at (11:0,11 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [12] ) +Code span at (14:0,14 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (14:0,14 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (15:0,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredMidTag.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredMidTag.stree.txt new file mode 100644 index 0000000000..96573d5697 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesToCodeWhenSwapCharacterEncounteredMidTag.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..15)::15 - [@{}] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..14)::12 + MarkupBlock - [2..14)::12 + MarkupElement - [2..14)::12 + MarkupStartTag - [2..14)::12 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + MarkupMiscAttributeContent - [6..12)::6 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [7..11)::4 + CSharpImplicitExpression - [7..11)::4 + CSharpTransition - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [8..11)::3 + CSharpCodeBlock - [8..11)::3 + CSharpExpressionLiteral - [8..11)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric.cspans.txt new file mode 100644 index 0000000000..3286136c58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (2:0,2 [3] ) (Accepts:None) - Parent: Tag block at (2:0,2 [3] ) +Markup span at (5:0,5 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [13] ) +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (9:0,9 [2] ) +Code span at (10:0,10 [1] ) (Accepts:NonWhitespace) - Parent: Expression block at (9:0,9 [2] ) +Markup span at (11:0,11 [4] ) (Accepts:None) - Parent: Tag block at (11:0,11 [4] ) +Code span at (15:0,15 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric.stree.txt new file mode 100644 index 0000000000..6f286f4bb4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..16)::16 - [@{

                    foo#@i

                    }] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + CSharpStatement - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..16)::15 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..15)::13 + MarkupBlock - [2..15)::13 + MarkupElement - [2..15)::13 + MarkupStartTag - [2..5)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [5..9)::4 - [foo#] - Gen - SpanEditHandler;Accepts:Any + Text;[foo#]; + CSharpCodeBlock - [9..11)::2 + CSharpImplicitExpression - [9..11)::2 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [10..11)::1 + CSharpCodeBlock - [10..11)::1 + CSharpExpressionLiteral - [10..11)::1 - [i] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[i]; + MarkupEndTag - [11..15)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsPairsOfAtSignsAsEscapeSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsPairsOfAtSignsAsEscapeSequence.cspans.txt new file mode 100644 index 0000000000..5a030d3cd8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsPairsOfAtSignsAsEscapeSequence.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (8:0,8 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (9:0,9 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [19] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [4] ) +Code span at (12:0,12 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (11:0,11 [4] ) +Markup span at (15:0,15 [6] ) (Accepts:None) - Parent: Tag block at (15:0,15 [6] ) +Code span at (21:0,21 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (21:0,21 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsPairsOfAtSignsAsEscapeSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsPairsOfAtSignsAsEscapeSequence.stree.txt new file mode 100644 index 0000000000..e90372344a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsPairsOfAtSignsAsEscapeSequence.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..22)::22 - [@{@@@@@bar}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupElement - [2..21)::19 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupEphemeralTextLiteral - [7..8)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [8..9)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupEphemeralTextLiteral - [9..10)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [10..11)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + CSharpCodeBlock - [11..15)::4 + CSharpImplicitExpression - [11..15)::4 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [12..15)::3 + CSharpCodeBlock - [12..15)::3 + CSharpExpressionLiteral - [12..15)::3 - [bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[bar]; + MarkupEndTag - [15..21)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsTwoAtSignsAsEscapeSequence.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsTwoAtSignsAsEscapeSequence.cspans.txt new file mode 100644 index 0000000000..5f80e5cc3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsTwoAtSignsAsEscapeSequence.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (2:0,2 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (7:0,7 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [16] ) +Markup span at (8:0,8 [4] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [16] ) +Markup span at (12:0,12 [6] ) (Accepts:None) - Parent: Tag block at (12:0,12 [6] ) +Code span at (18:0,18 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsTwoAtSignsAsEscapeSequence.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsTwoAtSignsAsEscapeSequence.stree.txt new file mode 100644 index 0000000000..a71a04cfef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlToCodeSwitchTest/TreatsTwoAtSignsAsEscapeSequence.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..19)::19 - [@{@@bar}] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpStatement - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..19)::18 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..18)::16 + MarkupBlock - [2..18)::16 + MarkupElement - [2..18)::16 + MarkupStartTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupEphemeralTextLiteral - [7..8)::1 - [@] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + MarkupTextLiteral - [8..12)::4 - [@bar] - Gen - SpanEditHandler;Accepts:Any + Transition;[@]; + Text;[bar]; + MarkupEndTag - [12..18)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; + CSharpStatementLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_DoesNotSpecialCase_VoidTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_DoesNotSpecialCase_VoidTags.cspans.txt new file mode 100644 index 0000000000..d9ab213c73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_DoesNotSpecialCase_VoidTags.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Markup span at (2:1,0 [7] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [7] ) +Markup span at (9:1,7 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Markup span at (12:1,10 [8] ) (Accepts:Any) - Parent: Tag block at (12:1,10 [8] ) +Markup span at (20:1,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_DoesNotSpecialCase_VoidTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_DoesNotSpecialCase_VoidTags.stree.txt new file mode 100644 index 0000000000..62169fa2ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_DoesNotSpecialCase_VoidTags.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..22)::22 - [LFFooLF] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..20)::18 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTextLiteral - [9..12)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [12..20)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; + MarkupTextLiteral - [20..22)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_EndTagsWithMissingStartTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_EndTagsWithMissingStartTags.cspans.txt new file mode 100644 index 0000000000..017a6ad437 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_EndTagsWithMissingStartTags.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Markup span at (5:1,3 [6] ) (Accepts:Any) - Parent: Tag block at (5:1,3 [6] ) +Markup span at (11:1,9 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_EndTagsWithMissingStartTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_EndTagsWithMissingStartTags.stree.txt new file mode 100644 index 0000000000..1f16c2f83b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_EndTagsWithMissingStartTags.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..13)::13 - [LFFoo
                  • LF] + MarkupBlock - [0..13)::13 + MarkupTextLiteral - [0..5)::5 - [LFFoo] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Text;[Foo]; + MarkupElement - [5..11)::6 + MarkupEndTag - [5..11)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [11..13)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_IncompleteTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_IncompleteTags.cspans.txt new file mode 100644 index 0000000000..245badb59b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_IncompleteTags.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Markup span at (2:1,0 [1] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [1] ) +Markup span at (3:1,1 [5] ) (Accepts:Any) - Parent: Tag block at (3:1,1 [5] ) +Markup span at (8:1,6 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Markup span at (12:1,10 [2] ) (Accepts:Any) - Parent: Tag block at (12:1,10 [2] ) +Markup span at (14:1,12 [6] ) (Accepts:Any) - Parent: Tag block at (14:1,12 [6] ) +Markup span at (20:1,18 [5] ) (Accepts:Any) - Parent: Tag block at (20:1,18 [5] ) +Markup span at (25:1,23 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_IncompleteTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_IncompleteTags.stree.txt new file mode 100644 index 0000000000..3d6e74006f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_IncompleteTags.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..27)::27 - [LF<
                    >Foo< >LF] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..3)::1 + MarkupStartTag - [2..3)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupElement - [3..20)::17 + MarkupStartTag - [3..8)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [8..12)::4 - [>Foo] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; + Text;[Foo]; + MarkupElement - [12..14)::2 + MarkupEndTag - [12..14)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupEndTag - [14..20)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupElement - [20..27)::7 + MarkupStartTag - [20..25)::5 - [< >] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMiscAttributeContent - [21..24)::3 + MarkupTextLiteral - [21..24)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [25..27)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MalformedTags_RecoversSuccessfully.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MalformedTags_RecoversSuccessfully.cspans.txt new file mode 100644 index 0000000000..616773a7c7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MalformedTags_RecoversSuccessfully.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Markup span at (14:1,12 [7] ) (Accepts:Any) - Parent: Tag block at (14:1,12 [7] ) +Markup span at (21:1,19 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Markup span at (27:1,25 [6] ) (Accepts:Any) - Parent: Tag block at (27:1,25 [6] ) +Markup span at (33:1,31 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MalformedTags_RecoversSuccessfully.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MalformedTags_RecoversSuccessfully.stree.txt new file mode 100644 index 0000000000..156d6a1813 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MalformedTags_RecoversSuccessfully.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..35)::35 - [LF
                    contentfooter
                    LF] + MarkupBlock - [0..35)::35 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..33)::31 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..14)::7 - [content] - Gen - SpanEditHandler;Accepts:Any + Text;[content]; + MarkupElement - [14..21)::7 + MarkupEndTag - [14..21)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [21..27)::6 - [footer] - Gen - SpanEditHandler;Accepts:Any + Text;[footer]; + MarkupEndTag - [27..33)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [33..35)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MisplacedEndTags_RecoversSuccessfully.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MisplacedEndTags_RecoversSuccessfully.cspans.txt new file mode 100644 index 0000000000..d19254baf9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MisplacedEndTags_RecoversSuccessfully.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Markup span at (14:1,12 [6] ) (Accepts:Any) - Parent: Tag block at (14:1,12 [6] ) +Markup span at (20:1,18 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Markup span at (26:1,24 [6] ) (Accepts:Any) - Parent: Tag block at (26:1,24 [6] ) +Markup span at (32:1,30 [7] ) (Accepts:Any) - Parent: Tag block at (32:1,30 [7] ) +Markup span at (39:1,37 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MisplacedEndTags_RecoversSuccessfully.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MisplacedEndTags_RecoversSuccessfully.stree.txt new file mode 100644 index 0000000000..b85048c9f3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_MisplacedEndTags_RecoversSuccessfully.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..41)::41 - [LF
                    contentfooter
                    LF] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..32)::30 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..14)::7 - [content] - Gen - SpanEditHandler;Accepts:Any + Text;[content]; + MarkupElement - [14..26)::12 + MarkupStartTag - [14..20)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [20..26)::6 - [footer] - Gen - SpanEditHandler;Accepts:Any + Text;[footer]; + MarkupEndTag - [26..32)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupElement - [32..39)::7 + MarkupEndTag - [32..39)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [39..41)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SelfClosingTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SelfClosingTags.cspans.txt new file mode 100644 index 0000000000..68917ae59c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SelfClosingTags.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Markup span at (10:1,8 [10] ) (Accepts:Any) - Parent: Tag block at (10:1,8 [10] ) +Markup span at (20:1,18 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SelfClosingTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SelfClosingTags.stree.txt new file mode 100644 index 0000000000..06c963307c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SelfClosingTags.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..22)::22 - [LF
                    FooLF] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..7)::5 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [7..10)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupElement - [10..20)::10 + MarkupStartTag - [10..20)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[custom]; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [20..22)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SpecialCasesVoidTags_WithNoEndTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SpecialCasesVoidTags_WithNoEndTags.cspans.txt new file mode 100644 index 0000000000..621dae62c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SpecialCasesVoidTags_WithNoEndTags.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (2:1,0 [6] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [6] ) +Markup span at (8:1,6 [6] ) (Accepts:Any) - Parent: Tag block at (8:1,6 [6] ) +Markup span at (14:1,12 [1] ) (Accepts:Any) - Parent: Tag block at (14:1,12 [7] ) +MetaCode span at (15:1,13 [1] ) (Accepts:None) - Parent: Tag block at (14:1,12 [7] ) +Markup span at (16:1,14 [5] ) (Accepts:Any) - Parent: Tag block at (14:1,12 [7] ) +Markup span at (21:1,19 [7] ) (Accepts:Any) - Parent: Tag block at (21:1,19 [7] ) +Markup span at (28:1,26 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SpecialCasesVoidTags_WithNoEndTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SpecialCasesVoidTags_WithNoEndTags.stree.txt new file mode 100644 index 0000000000..2aa331e165 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_SpecialCasesVoidTags_WithNoEndTags.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..30)::30 - [LFLF] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..28)::26 + MarkupStartTag - [2..8)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[head]; + CloseAngle;[>]; + MarkupElement - [8..14)::6 + MarkupStartTag - [8..14)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[meta]; + CloseAngle;[>]; + MarkupElement - [14..21)::7 + MarkupStartTag - [14..21)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[meta]; + CloseAngle;[>]; + MarkupEndTag - [21..28)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[head]; + CloseAngle;[>]; + MarkupTextLiteral - [28..30)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_StartTagsWithMissingEndTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_StartTagsWithMissingEndTags.cspans.txt new file mode 100644 index 0000000000..23600f15fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_StartTagsWithMissingEndTags.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [15] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Markup span at (22:3,4 [3] ) (Accepts:Any) - Parent: Tag block at (22:3,4 [3] ) +Markup span at (25:3,7 [23] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Markup span at (48:5,8 [9] ) (Accepts:Any) - Parent: Tag block at (48:5,8 [9] ) +Markup span at (57:5,17 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_StartTagsWithMissingEndTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_StartTagsWithMissingEndTags.stree.txt new file mode 100644 index 0000000000..e71d6cf18d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_StartTagsWithMissingEndTags.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..59)::59 - [LF
                    LF FooLF

                    LF BarLF LF] + MarkupBlock - [0..59)::59 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..59)::57 + MarkupStartTag - [2..7)::5 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..22)::15 - [LF FooLF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Foo]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [22..59)::37 + MarkupStartTag - [22..25)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [25..48)::23 - [LF BarLF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Bar]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [48..57)::9 + MarkupEndTag - [48..57)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [57..59)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTags.cspans.txt new file mode 100644 index 0000000000..63be5f5b10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTags.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [15] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Markup span at (22:3,4 [3] ) (Accepts:Any) - Parent: Tag block at (22:3,4 [3] ) +Markup span at (25:3,7 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Markup span at (28:3,10 [4] ) (Accepts:Any) - Parent: Tag block at (28:3,10 [4] ) +Markup span at (32:3,14 [11] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Markup span at (43:5,0 [6] ) (Accepts:Any) - Parent: Tag block at (43:5,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTags.stree.txt new file mode 100644 index 0000000000..f25fd6b548 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTags.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..49)::49 - [LF

                    LF FooLF

                    Bar

                    LF BazLF
                    ] + MarkupBlock - [0..49)::49 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..49)::47 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..22)::15 - [LF FooLF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Foo]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [22..32)::10 + MarkupStartTag - [22..25)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [25..28)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [28..32)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [32..43)::11 - [LF BazLF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Baz]; + NewLine;[LF]; + MarkupEndTag - [43..49)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTagsMixedWithCode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTagsMixedWithCode.cspans.txt new file mode 100644 index 0000000000..27e228bccf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTagsMixedWithCode.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [15] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) +Markup span at (22:3,4 [3] ) (Accepts:Any) - Parent: Tag block at (22:3,4 [3] ) +Transition span at (25:3,7 [1] ) (Accepts:None) - Parent: Expression block at (25:3,7 [4] ) +Code span at (26:3,8 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (25:3,7 [4] ) +Markup span at (29:3,11 [4] ) (Accepts:Any) - Parent: Tag block at (29:3,11 [4] ) +Markup span at (33:3,15 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) +Code span at (35:4,0 [4] ) (Accepts:Any) - Parent: Statement block at (35:4,0 [21] ) +Transition span at (39:4,4 [1] ) (Accepts:None) - Parent: Statement block at (39:4,4 [17] ) +MetaCode span at (40:4,5 [1] ) (Accepts:None) - Parent: Statement block at (39:4,4 [17] ) +Code span at (41:4,6 [14] ) (Accepts:Any) - Parent: Statement block at (39:4,4 [17] ) +MetaCode span at (55:4,20 [1] ) (Accepts:None) - Parent: Statement block at (39:4,4 [17] ) +Markup span at (56:4,21 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) +Markup span at (58:5,0 [6] ) (Accepts:Any) - Parent: Tag block at (58:5,0 [6] ) +Markup span at (64:5,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [66] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTagsMixedWithCode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTagsMixedWithCode.stree.txt new file mode 100644 index 0000000000..94de02b7b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidNestedTagsMixedWithCode.stree.txt @@ -0,0 +1,67 @@ +RazorDocument - [0..66)::66 - [LF
                    LF FooLF

                    @Bar

                    LF @{ var x = Bar; }LF
                    LF] + MarkupBlock - [0..66)::66 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..64)::62 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..22)::15 - [LF FooLF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Foo]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [22..33)::11 + MarkupStartTag - [22..25)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [25..29)::4 + CSharpImplicitExpression - [25..29)::4 + CSharpTransition - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [26..29)::3 + CSharpCodeBlock - [26..29)::3 + CSharpExpressionLiteral - [26..29)::3 - [Bar] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[Bar]; + MarkupEndTag - [29..33)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [33..35)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [35..56)::21 + CSharpStatementLiteral - [35..39)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpStatement - [39..56)::17 + CSharpTransition - [39..40)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [40..56)::16 + RazorMetaCode - [40..41)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [41..55)::14 + CSharpStatementLiteral - [41..55)::14 - [ var x = Bar; ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[x]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[Bar]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [55..56)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupEphemeralTextLiteral - [56..58)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [58..64)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [64..66)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidTags.cspans.txt new file mode 100644 index 0000000000..cbaaaf3772 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidTags.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (10:1,8 [6] ) (Accepts:Any) - Parent: Tag block at (10:1,8 [6] ) +Markup span at (16:1,14 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (18:2,0 [3] ) (Accepts:Any) - Parent: Tag block at (18:2,0 [3] ) +Markup span at (21:2,3 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Markup span at (24:2,6 [4] ) (Accepts:Any) - Parent: Tag block at (24:2,6 [4] ) +Markup span at (28:2,10 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidTags.stree.txt new file mode 100644 index 0000000000..c38db1f3cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/MarkupElementGroupingTest/Handles_ValidTags.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..30)::30 - [LF
                    Foo
                    LF

                    Bar

                    LF] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..16)::14 + MarkupStartTag - [2..7)::5 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..10)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [10..16)::6 - [
                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [16..18)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [18..28)::10 + MarkupStartTag - [18..21)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..24)::3 - [Bar] - Gen - SpanEditHandler;Accepts:Any + Text;[Bar]; + MarkupEndTag - [24..28)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [28..30)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..90b83a758f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Code span at (14:0,14 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [18] ) +Markup span at (18:0,18 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt new file mode 100644 index 0000000000..c1d5bcd34e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..415af2bb31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..18)::18 - [@addTagHelper Foo"] + MarkupBlock - [0..18)::18 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + RazorDirective - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..18)::17 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..18)::5 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..18)::4 - [Foo"] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + StringLiteral;["];RZ1000(17:0,17 [1] ) + MarkupTextLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..bb83fe7c4c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (14:0,14 [3] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..32eaa73ae7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..17)::17 - [@addTagHelper Foo] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..17)::4 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..17)::3 - [Foo] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_NoValue_Invalid.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_NoValue_Invalid.cspans.txt new file mode 100644 index 0000000000..25806343ae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_NoValue_Invalid.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (14:0,14 [2] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_NoValue_Invalid.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_NoValue_Invalid.stree.txt new file mode 100644 index 0000000000..95e2ab911c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_NoValue_Invalid.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..16)::16 - [@addTagHelper ""] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + RazorDirective - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..16)::15 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..16)::3 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..16)::2 - [""] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;[""]; + MarkupTextLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_RequiresValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_RequiresValue.cspans.txt new file mode 100644 index 0000000000..61be581b1c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_RequiresValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Code span at (14:0,14 [0] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_RequiresValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_RequiresValue.stree.txt new file mode 100644 index 0000000000..660b83b424 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_RequiresValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..14)::14 - [@addTagHelper ] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + RazorDirective - [0..14)::14 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..14)::13 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..14)::1 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Marker;[]; + MarkupTextLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.cspans.txt new file mode 100644 index 0000000000..4810545912 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (14:0,14 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.stree.txt new file mode 100644 index 0000000000..e5a43eb13a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SingleQuotes_AddsError.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..22)::22 - [@addTagHelper '*, Foo'] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + RazorDirective - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..22)::21 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..22)::9 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..22)::8 - ['*, Foo'] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + CharacterLiteral;['*, Foo']; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..90b83a758f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [18] ) +Code span at (14:0,14 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [18] ) +Markup span at (18:0,18 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt new file mode 100644 index 0000000000..859804d1cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt @@ -0,0 +1 @@ +(1,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..92b11e3ec3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..18)::18 - [@addTagHelper "Foo] + MarkupBlock - [0..18)::18 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + RazorDirective - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..18)::17 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..18)::5 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..18)::4 - ["Foo] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["Foo];RZ1000(14:0,14 [1] ) + MarkupTextLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SupportsSpaces.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SupportsSpaces.cspans.txt new file mode 100644 index 0000000000..1a383325f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SupportsSpaces.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (13:0,13 [5] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Code span at (18:0,18 [14] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SupportsSpaces.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SupportsSpaces.stree.txt new file mode 100644 index 0000000000..a1d2a4c464 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_SupportsSpaces.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..32)::32 - [@addTagHelper Foo, Bar ] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + RazorDirective - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..32)::31 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..32)::19 + MarkupTextLiteral - [13..18)::5 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [18..32)::14 - [Foo, Bar ] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..3b7dd42093 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [12] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (14:0,14 [5] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..45498ce535 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/AddTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..19)::19 - [@addTagHelper "Foo"] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + RazorDirective - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..19)::18 + RazorMetaCode - [1..13)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [13..19)::6 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [14..19)::5 - ["Foo"] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["Foo"]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt new file mode 100644 index 0000000000..c6fee76354 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Code span at (2:1,0 [2] ) (Accepts:Any) - Parent: Statement block at (2:1,0 [24] ) +Transition span at (4:1,2 [1] ) (Accepts:None) - Parent: Directive block at (4:1,2 [22] ) +MetaCode span at (5:1,3 [12] ) (Accepts:None) - Parent: Directive block at (4:1,2 [22] ) +Markup span at (17:1,15 [1] ) (Accepts:None) - Parent: Directive block at (4:1,2 [22] ) +Code span at (18:1,16 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (4:1,2 [22] ) +Markup span at (26:1,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt new file mode 100644 index 0000000000..8123d8117f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..26)::26 - [LF @addTagHelper "*, Foo"] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..26)::24 + CSharpEphemeralTextLiteral - [2..4)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorDirective - [4..26)::22 + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [5..26)::21 + RazorMetaCode - [5..17)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [17..26)::9 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [18..26)::8 - ["*, Foo"] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["*, Foo"]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.cspans.txt new file mode 100644 index 0000000000..8caeeee11d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Directive block at (3:0,3 [24] ) +MetaCode span at (4:0,4 [12] ) (Accepts:None) - Parent: Directive block at (3:0,3 [24] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (3:0,3 [24] ) +Code span at (17:0,17 [10] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (3:0,3 [24] ) +Markup span at (27:1,0 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.stree.txt new file mode 100644 index 0000000000..1e622480ba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/BuiltInDirectiveErrorsIfNotAtStartOfLine.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..28)::28 - [{ @addTagHelper "*, Foo"LF}] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..3)::3 - [{ ] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [3..27)::24 + RazorDirective - [3..27)::24 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [4..27)::23 + RazorMetaCode - [4..16)::12 - Gen - SpanEditHandler;Accepts:None + Identifier;[addTagHelper]; + CSharpCodeBlock - [16..27)::11 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..27)::10 - ["*, Foo"LF] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["*, Foo"]; + NewLine;[LF]; + MarkupTextLiteral - [27..28)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.cspans.txt new file mode 100644 index 0000000000..c23d9ce5f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [176] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [176] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [176] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (15:0,15 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (16:0,16 [9] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (25:0,25 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (26:0,26 [21] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (47:0,47 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (48:0,48 [29] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (77:0,77 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (78:0,78 [31] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (109:0,109 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [176] ) +Code span at (110:0,110 [66] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [176] ) +Markup span at (176:0,176 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [176] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.stree.txt new file mode 100644 index 0000000000..cfa73cde1e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsNullableTypes.stree.txt @@ -0,0 +1,80 @@ +RazorDocument - [0..176)::176 - [@custom string? string?[] global::System.Int32? KeyValuePair? KeyValuePair?[] global::System.Collections.Generic.KeyValuePair?[]] + MarkupBlock - [0..176)::176 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..176)::176 + RazorDirective - [0..176)::176 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..176)::175 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..176)::169 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..15)::7 - [string?] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[string]; + QuestionMark;[?]; + CSharpStatementLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [16..25)::9 - [string?[]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[string]; + QuestionMark;[?]; + LeftBracket;[[]; + RightBracket;[]]; + CSharpStatementLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [26..47)::21 - [global::System.Int32?] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Int32]; + QuestionMark;[?]; + CSharpStatementLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [48..77)::29 - [KeyValuePair?] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[KeyValuePair]; + LessThan;[<]; + Keyword;[string]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + GreaterThan;[>]; + QuestionMark;[?]; + CSharpStatementLiteral - [77..78)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [78..109)::31 - [KeyValuePair?[]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[KeyValuePair]; + LessThan;[<]; + Keyword;[string]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + GreaterThan;[>]; + QuestionMark;[?]; + LeftBracket;[[]; + RightBracket;[]]; + CSharpStatementLiteral - [109..110)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [110..176)::66 - [global::System.Collections.Generic.KeyValuePair?[]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Collections]; + Dot;[.]; + Identifier;[Generic]; + Dot;[.]; + Identifier;[KeyValuePair]; + LessThan;[<]; + Keyword;[string]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + GreaterThan;[>]; + QuestionMark;[?]; + LeftBracket;[[]; + RightBracket;[]]; + MarkupTextLiteral - [176..176)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.cspans.txt new file mode 100644 index 0000000000..f0a1ad489a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [246] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [246] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [246] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (8:0,8 [11] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (19:0,19 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (20:0,20 [20] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (40:0,40 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (41:0,41 [29] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (70:0,70 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (71:0,71 [37] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (108:0,108 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (109:0,109 [36] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (145:0,145 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [246] ) +Code span at (146:0,146 [100] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [246] ) +Markup span at (246:0,246 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [246] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.stree.txt new file mode 100644 index 0000000000..bd5ce0d7fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes.stree.txt @@ -0,0 +1,164 @@ +RazorDocument - [0..246)::246 - [@custom (bool, int) (int aa, string bb)? ( int? q , bool w ) ( int ? q, bool ?w ,(long ? [])) ? (List<(int, string)?> aa, string bb) (string ss, (int u, List<(string, int)> k, (Char c, bool b, List l)), global::System.Int32[] a)] + MarkupBlock - [0..246)::246 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..246)::246 + RazorDirective - [0..246)::246 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..246)::245 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..246)::239 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..19)::11 - [(bool, int)] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Keyword;[bool]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[int]; + RightParenthesis;[)]; + CSharpStatementLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [20..40)::20 - [(int aa, string bb)?] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[aa]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[bb]; + RightParenthesis;[)]; + QuestionMark;[?]; + CSharpStatementLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [41..70)::29 - [( int? q , bool w )] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Whitespace;[ ]; + Keyword;[int]; + QuestionMark;[?]; + Whitespace;[ ]; + Identifier;[q]; + Whitespace;[ ]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[bool]; + Whitespace;[ ]; + Identifier;[w]; + Whitespace;[ ]; + RightParenthesis;[)]; + CSharpStatementLiteral - [70..71)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [71..108)::37 - [( int ? q, bool ?w ,(long ? [])) ?] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Whitespace;[ ]; + Keyword;[int]; + Whitespace;[ ]; + QuestionMark;[?]; + Whitespace;[ ]; + Identifier;[q]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[bool]; + Whitespace;[ ]; + QuestionMark;[?]; + Identifier;[w]; + Whitespace;[ ]; + Comma;[,]; + LeftParenthesis;[(]; + Keyword;[long]; + Whitespace;[ ]; + QuestionMark;[?]; + Whitespace;[ ]; + LeftBracket;[[]; + RightBracket;[]]; + RightParenthesis;[)]; + RightParenthesis;[)]; + Whitespace;[ ]; + QuestionMark;[?]; + CSharpStatementLiteral - [108..109)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [109..145)::36 - [(List<(int, string)?> aa, string bb)] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Identifier;[List]; + LessThan;[<]; + LeftParenthesis;[(]; + Keyword;[int]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + RightParenthesis;[)]; + QuestionMark;[?]; + GreaterThan;[>]; + Whitespace;[ ]; + Identifier;[aa]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[bb]; + RightParenthesis;[)]; + CSharpStatementLiteral - [145..146)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [146..246)::100 - [(string ss, (int u, List<(string, int)> k, (Char c, bool b, List l)), global::System.Int32[] a)] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Keyword;[string]; + Whitespace;[ ]; + Identifier;[ss]; + Comma;[,]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[int]; + Whitespace;[ ]; + Identifier;[u]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[List]; + LessThan;[<]; + LeftParenthesis;[(]; + Keyword;[string]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[int]; + RightParenthesis;[)]; + GreaterThan;[>]; + Whitespace;[ ]; + Identifier;[k]; + Comma;[,]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[Char]; + Whitespace;[ ]; + Identifier;[c]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[bool]; + Whitespace;[ ]; + Identifier;[b]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[List]; + LessThan;[<]; + Keyword;[int]; + GreaterThan;[>]; + Whitespace;[ ]; + Identifier;[l]; + RightParenthesis;[)]; + RightParenthesis;[)]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[global]; + DoubleColon;[::]; + Identifier;[System]; + Dot;[.]; + Identifier;[Int32]; + LeftBracket;[[]; + RightBracket;[]]; + Whitespace;[ ]; + Identifier;[a]; + RightParenthesis;[)]; + MarkupTextLiteral - [246..246)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.cspans.txt new file mode 100644 index 0000000000..52a117679c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [23] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [23] ) +Code span at (8:0,8 [12] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [23] ) +None span at (20:0,20 [3] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.stree.txt new file mode 100644 index 0000000000..10efce7060 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsTupleTypes_IgnoresTrailingWhitespace.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..23)::23 - [@custom (bool, int?) ] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + RazorDirective - [0..23)::23 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..23)::22 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..23)::16 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..20)::12 - [(bool, int?)] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftParenthesis;[(]; + Keyword;[bool]; + Comma;[,]; + Whitespace;[ ]; + Keyword;[int]; + QuestionMark;[?]; + RightParenthesis;[)]; + UnclassifiedTextLiteral - [20..23)::3 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.cspans.txt new file mode 100644 index 0000000000..68dfa71c77 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [67] ) +Code span at (7:0,7 [4] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (11:0,11 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (45:0,45 [7] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [67] ) +Code span at (52:0,52 [11] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [67] ) +None span at (63:0,63 [4] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [67] ) +Markup span at (67:0,67 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [67] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.stree.txt new file mode 100644 index 0000000000..1008dcab02 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AllowsWhiteSpaceAroundTokens.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..67)::67 - [@custom System.Text.Encoding.ASCIIEncoding Some_Member ] + MarkupBlock - [0..67)::67 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..67)::67 + RazorDirective - [0..67)::67 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..67)::66 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..67)::60 + CSharpStatementLiteral - [7..11)::4 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [11..45)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + CSharpStatementLiteral - [45..52)::7 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [52..63)::11 - [Some_Member] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Some_Member]; + UnclassifiedTextLiteral - [63..67)::4 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [67..67)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_BalancesBrackets.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_BalancesBrackets.cspans.txt new file mode 100644 index 0000000000..a9da33c82f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_BalancesBrackets.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [43] ) +MetaCode span at (3:1,1 [6] ) (Accepts:None) - Parent: Directive block at (2:1,0 [43] ) +Code span at (9:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [43] ) +Code span at (10:1,8 [35] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [43] ) +Markup span at (45:2,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_BalancesBrackets.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_BalancesBrackets.stree.txt new file mode 100644 index 0000000000..1bd3280f63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_BalancesBrackets.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..45)::45 - [LF@custom [SomeCustom(new int[] { 1, 2, 3 }LF] + MarkupBlock - [0..45)::45 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..45)::43 + RazorDirective - [2..45)::43 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..45)::42 + RazorMetaCode - [3..9)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [9..45)::36 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..45)::35 - [[SomeCustom(new int[] { 1, 2, 3 }LF] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftBracket;[[]; + Identifier;[SomeCustom]; + LeftParenthesis;[(]; + Keyword;[new]; + Whitespace;[ ]; + Keyword;[int]; + LeftBracket;[[]; + RightBracket;[]]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Comma;[,]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Comma;[,]; + Whitespace;[ ]; + IntegerLiteral;[3]; + Whitespace;[ ]; + RightBrace;[}]; + NewLine;[LF]; + MarkupTextLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.cspans.txt new file mode 100644 index 0000000000..96e5261815 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.diag.txt new file mode 100644 index 0000000000..46532eb8d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1037: The 'custom' directive expects a C# attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.stree.txt new file mode 100644 index 0000000000..381265396e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_AttributeToken_ErrorsIfDoesNotStartWithOpenBracket.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..21)::21 - [@custom Serializable]] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1037(8:0,8 [12] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..21)::13 - [Serializable]] - Gen - SpanEditHandler;Accepts:Any + Text;[Serializable]; + RightBracket;[]]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..a2ac1bb1a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.diag.txt new file mode 100644 index 0000000000..7e7735a128 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1014: The 'custom' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.stree.txt new file mode 100644 index 0000000000..2e41bb2bbd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFIncompleteNamespaceTokens.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..15)::15 - [@custom System.] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1014(8:0,8 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..15)::7 - [System.] - Gen - SpanEditHandler;Accepts:Any + Text;[System.]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..0d19696aec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.diag.txt new file mode 100644 index 0000000000..7e7735a128 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1014: The 'custom' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.stree.txt new file mode 100644 index 0000000000..246d5fc4e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleEOFInvalidNamespaceTokens.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..15)::15 - [@custom System<] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1014(8:0,8 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..14)::6 - [System] - Gen - SpanEditHandler;Accepts:Any + Text;[System]; + MarkupElement - [14..15)::1 + MarkupStartTag - [14..15)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..1b4c670d6a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.diag.txt new file mode 100644 index 0000000000..7e7735a128 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1014: The 'custom' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.stree.txt new file mode 100644 index 0000000000..9d6f4a44f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleIncompleteNamespaceTokens.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..17)::17 - [@custom System.LF] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1014(8:0,8 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..17)::9 - [System.LF] - Gen - SpanEditHandler;Accepts:Any + Text;[System.]; + NewLine;[LF]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.cspans.txt new file mode 100644 index 0000000000..7232de595e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.diag.txt new file mode 100644 index 0000000000..7e7735a128 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1014: The 'custom' directive expects a namespace name. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.stree.txt new file mode 100644 index 0000000000..9b3894020f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_CanHandleInvalidNamespaceTokens.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..17)::17 - [@custom System - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1014(8:0,8 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..14)::6 - [System] - Gen - SpanEditHandler;Accepts:Any + Text;[System]; + MarkupElement - [14..17)::3 + MarkupStartTag - [14..17)::3 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMiscAttributeContent - [15..17)::2 + MarkupTextLiteral - [15..17)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.cspans.txt new file mode 100644 index 0000000000..4d02aa2a12 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [16] ) +None span at (15:0,15 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (16:0,16 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.diag.txt new file mode 100644 index 0000000000..bbc8035249 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.diag.txt @@ -0,0 +1 @@ +(1,17): Error RZ1017: Unexpected literal following the 'custom' directive. Expected 'line break'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.stree.txt new file mode 100644 index 0000000000..b06c7343c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsExtraContentAfterDirective.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..23)::23 - [@custom "hello" "world"] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + RazorDirective - [0..16)::16 - Directive:{custom;SingleLine;Unrestricted} [RZ1017(16:0,16 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..16)::15 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..16)::9 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..15)::7 - ["hello"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["hello"]; + UnclassifiedTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [16..23)::7 - ["world"] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + Text;[world]; + DoubleQuote;["]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.cspans.txt new file mode 100644 index 0000000000..59f2a44c20 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [12] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.diag.txt new file mode 100644 index 0000000000..c8a41322a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1015: The 'custom' directive expects an identifier. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.stree.txt new file mode 100644 index 0000000000..ab35f9a32d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsForInvalidMemberTokens.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..20)::20 - [@custom -Some_Member] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1015(8:0,8 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..20)::12 - [-Some_Member] - Gen - SpanEditHandler;Accepts:Any + Text;[-Some_Member]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.cspans.txt new file mode 100644 index 0000000000..66d394bc52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [15] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (15:0,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.diag.txt new file mode 100644 index 0000000000..6bc13c4718 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ1012: Unexpected end of file following the 'custom' directive. Expected '{'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.stree.txt new file mode 100644 index 0000000000..5a51465112 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenEOFBeforeDirectiveBlockStart.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..15)::15 - [@custom "Hello"] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + RazorDirective - [0..15)::15 - Directive:{custom;CodeBlock;Unrestricted} [RZ1012(15:0,15 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..15)::14 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..15)::8 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..15)::7 - ["Hello"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["Hello"]; + MarkupTextLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.cspans.txt new file mode 100644 index 0000000000..9e0b76b5d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [16] ) +None span at (15:0,15 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (16:0,16 [23] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [39] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.diag.txt new file mode 100644 index 0000000000..8227b74116 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.diag.txt @@ -0,0 +1 @@ +(1,17): Error RZ1017: Unexpected literal following the 'custom' directive. Expected '{'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.stree.txt new file mode 100644 index 0000000000..344dee531b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenExtraContentBeforeBlockStart.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..39)::39 - [@custom "Hello" World { foo(); bar(); }] + MarkupBlock - [0..39)::39 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + RazorDirective - [0..16)::16 - Directive:{custom;CodeBlock;Unrestricted} [RZ1017(16:0,16 [5] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..16)::15 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..16)::9 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..15)::7 - ["Hello"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["Hello"]; + UnclassifiedTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + MarkupTextLiteral - [16..39)::23 - [World { foo(); bar(); }] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + Whitespace;[ ]; + Text;[{]; + Whitespace;[ ]; + Text;[foo();]; + Whitespace;[ ]; + Text;[bar();]; + Whitespace;[ ]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.cspans.txt new file mode 100644 index 0000000000..cf1f2e36d5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [17] ) +None span at (15:0,15 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.diag.txt new file mode 100644 index 0000000000..7d15c3c5e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.diag.txt @@ -0,0 +1 @@ +(1,17): Error RZ1006: The custom block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.stree.txt new file mode 100644 index 0000000000..4938afb99f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_ErrorsWhenMissingEndBrace.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..17)::17 - [@custom "Hello" {] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 - Directive:{custom;CodeBlock;Unrestricted} [RZ1006(16:0,16 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..17)::10 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..15)::7 - ["Hello"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["Hello"]; + UnclassifiedTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [16..17)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [17..17)::0 + CSharpStatementLiteral - [17..17)::0 - [] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + Marker;[]; + RazorMetaCode - [17..17)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.cspans.txt new file mode 100644 index 0000000000..5429ef434a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (42:0,42 [2] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (44:1,0 [1] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +MetaCode span at (45:1,1 [6] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +Code span at (51:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (44:1,0 [41] ) +Code span at (52:1,8 [33] ) (Accepts:NonWhitespace) - Parent: Directive block at (44:1,0 [41] ) +Markup span at (85:1,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.stree.txt new file mode 100644 index 0000000000..f9d3383434 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedMultipleOccurring_CanHaveDuplicates.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..85)::85 - [@custom System.Text.Encoding.ASCIIEncodingLF@custom System.Text.Encoding.UTF8Encoding] + MarkupBlock - [0..85)::85 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + RazorDirective - [0..44)::44 - Directive:{custom;SingleLine;FileScopedMultipleOccurring} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..44)::43 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..44)::37 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..42)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupEphemeralTextLiteral - [42..44)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [44..85)::41 + RazorDirective - [44..85)::41 - Directive:{custom;SingleLine;FileScopedMultipleOccurring} + CSharpTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [45..85)::40 + RazorMetaCode - [45..51)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [51..85)::34 + CSharpStatementLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [52..85)::33 - [System.Text.Encoding.UTF8Encoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[UTF8Encoding]; + MarkupTextLiteral - [85..85)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.cspans.txt new file mode 100644 index 0000000000..5429ef434a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (42:0,42 [2] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (44:1,0 [1] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +MetaCode span at (45:1,1 [6] ) (Accepts:None) - Parent: Directive block at (44:1,0 [41] ) +Code span at (51:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (44:1,0 [41] ) +Code span at (52:1,8 [33] ) (Accepts:NonWhitespace) - Parent: Directive block at (44:1,0 [41] ) +Markup span at (85:1,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.diag.txt new file mode 100644 index 0000000000..6e707f9d16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.diag.txt @@ -0,0 +1 @@ +(2,1): Error RZ2001: The 'custom' directive may only occur once per document. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.stree.txt new file mode 100644 index 0000000000..551e79b27c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScopedSinglyOccurring_ErrorsIfDuplicate.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..85)::85 - [@custom System.Text.Encoding.ASCIIEncodingLF@custom System.Text.Encoding.UTF8Encoding] + MarkupBlock - [0..85)::85 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + RazorDirective - [0..44)::44 - Directive:{custom;SingleLine;FileScopedSinglyOccurring} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..44)::43 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..44)::37 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..42)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupEphemeralTextLiteral - [42..44)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [44..85)::41 + RazorDirective - [44..85)::41 - Directive:{custom;SingleLine;FileScopedSinglyOccurring} [RZ2001(44:1,0 [7] )] + CSharpTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [45..85)::40 + RazorMetaCode - [45..51)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [51..85)::34 + CSharpStatementLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [52..85)::33 - [System.Text.Encoding.UTF8Encoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[UTF8Encoding]; + MarkupTextLiteral - [85..85)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.cspans.txt new file mode 100644 index 0000000000..715c97f1c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [44] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (42:0,42 [2] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [44] ) +Markup span at (44:1,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) +Transition span at (44:1,0 [1] ) (Accepts:None) - Parent: Directive block at (44:1,0 [15] ) +MetaCode span at (45:1,1 [9] ) (Accepts:None) - Parent: Directive block at (44:1,0 [15] ) +Code span at (54:1,10 [1] ) (Accepts:Whitespace) - Parent: Directive block at (44:1,0 [15] ) +Code span at (55:1,11 [4] ) (Accepts:NonWhitespace) - Parent: Directive block at (44:1,0 [15] ) +Markup span at (59:1,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [59] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.stree.txt new file mode 100644 index 0000000000..e0591c053d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherDirectives.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..59)::59 - [@custom System.Text.Encoding.ASCIIEncodingLF@something Else] + MarkupBlock - [0..59)::59 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + RazorDirective - [0..44)::44 - Directive:{custom;SingleLine;FileScopedSinglyOccurring} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..44)::43 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..44)::37 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..42)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupEphemeralTextLiteral - [42..44)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [44..59)::15 + RazorDirective - [44..59)::15 - Directive:{something;SingleLine;FileScopedMultipleOccurring} + CSharpTransition - [44..45)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [45..59)::14 + RazorMetaCode - [45..54)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[something]; + CSharpCodeBlock - [54..59)::5 + CSharpStatementLiteral - [54..55)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [55..59)::4 - [Else] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Else]; + MarkupTextLiteral - [59..59)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.cspans.txt new file mode 100644 index 0000000000..b65e57e7d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.cspans.txt @@ -0,0 +1,22 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +Comment span at (2:0,2 [39] ) (Accepts:Any) - Parent: Comment block at (0:0,0 [43] ) +MetaCode span at (41:0,41 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +Transition span at (42:0,42 [1] ) (Accepts:None) - Parent: Comment block at (0:0,0 [43] ) +Markup span at (43:0,43 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (45:1,0 [1] ) (Accepts:None) - Parent: Directive block at (45:1,0 [44] ) +MetaCode span at (46:1,1 [6] ) (Accepts:None) - Parent: Directive block at (45:1,0 [44] ) +Code span at (52:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (45:1,0 [44] ) +Code span at (53:1,8 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (45:1,0 [44] ) +Markup span at (87:1,42 [2] ) (Accepts:Whitespace) - Parent: Directive block at (45:1,0 [44] ) +Markup span at (89:2,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Transition span at (91:3,0 [1] ) (Accepts:None) - Parent: Directive block at (91:3,0 [17] ) +MetaCode span at (92:3,1 [9] ) (Accepts:None) - Parent: Directive block at (91:3,0 [17] ) +Code span at (101:3,10 [1] ) (Accepts:Whitespace) - Parent: Directive block at (91:3,0 [17] ) +Code span at (102:3,11 [4] ) (Accepts:NonWhitespace) - Parent: Directive block at (91:3,0 [17] ) +Markup span at (106:3,15 [2] ) (Accepts:Whitespace) - Parent: Directive block at (91:3,0 [17] ) +Markup span at (108:4,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Markup span at (110:5,0 [3] ) (Accepts:Any) - Parent: Tag block at (110:5,0 [3] ) +Markup span at (113:5,3 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [130] ) +Markup span at (126:5,16 [4] ) (Accepts:Any) - Parent: Tag block at (126:5,16 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.stree.txt new file mode 100644 index 0000000000..22f831367b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_FileScoped_CanBeBeneathOtherWhiteSpaceCommentsAndDirectives.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..130)::130 - [@* There are two directives beneath this *@LF@custom System.Text.Encoding.ASCIIEncodingLFLF@something ElseLFLF

                    This is extra

                    ] + MarkupBlock - [0..130)::130 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorComment - [0..43)::43 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[ There are two directives beneath this ]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupEphemeralTextLiteral - [43..45)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [45..89)::44 + RazorDirective - [45..89)::44 - Directive:{custom;SingleLine;FileScopedSinglyOccurring} + CSharpTransition - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [46..89)::43 + RazorMetaCode - [46..52)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [52..89)::37 + CSharpStatementLiteral - [52..53)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [53..87)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupEphemeralTextLiteral - [87..89)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [89..91)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [91..108)::17 + RazorDirective - [91..108)::17 - Directive:{something;SingleLine;FileScopedMultipleOccurring} + CSharpTransition - [91..92)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [92..108)::16 + RazorMetaCode - [92..101)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[something]; + CSharpCodeBlock - [101..108)::7 + CSharpStatementLiteral - [101..102)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [102..106)::4 - [Else] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Else]; + MarkupEphemeralTextLiteral - [106..108)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [108..110)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [110..130)::20 + MarkupStartTag - [110..113)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [113..126)::13 - [This is extra] - Gen - SpanEditHandler;Accepts:Any + Text;[This]; + Whitespace;[ ]; + Text;[is]; + Whitespace;[ ]; + Text;[extra]; + MarkupEndTag - [126..130)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets.cspans.txt new file mode 100644 index 0000000000..af411e2d6a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [83] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [81] ) +MetaCode span at (3:1,1 [6] ) (Accepts:None) - Parent: Directive block at (2:1,0 [81] ) +Code span at (9:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [81] ) +Code span at (10:1,8 [71] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [81] ) +Markup span at (81:6,6 [2] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [81] ) +Markup span at (83:7,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [83] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets.stree.txt new file mode 100644 index 0000000000..e2b43fc967 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_MultilineAttributeToken_BalancesBrackets.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..83)::83 - [LF@custom [SomeCustom(new int[]LF {LF 1,LF 2,LF 3LF }]LF] + MarkupBlock - [0..83)::83 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..83)::81 + RazorDirective - [2..83)::81 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..83)::80 + RazorMetaCode - [3..9)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [9..83)::74 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..81)::71 - [[SomeCustom(new int[]LF {LF 1,LF 2,LF 3LF }]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftBracket;[[]; + Identifier;[SomeCustom]; + LeftParenthesis;[(]; + Keyword;[new]; + Whitespace;[ ]; + Keyword;[int]; + LeftBracket;[[]; + RightBracket;[]]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + IntegerLiteral;[1]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + IntegerLiteral;[2]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + IntegerLiteral;[3]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + RightBracket;[]]; + MarkupEphemeralTextLiteral - [81..83)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [83..83)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.cspans.txt new file mode 100644 index 0000000000..f44c1c18b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [19] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [19] ) +None span at (15:0,15 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (16:0,16 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (17:0,17 [2] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.stree.txt new file mode 100644 index 0000000000..bd14b1f20c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_NoErrorsSemicolonAfterDirective.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..19)::19 - [@custom "hello" ; ] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + RazorDirective - [0..19)::19 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..19)::18 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..19)::12 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..15)::7 - ["hello"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["hello"]; + UnclassifiedTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:Whitespace + Semicolon;[;]; + MarkupEphemeralTextLiteral - [17..19)::2 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.cspans.txt new file mode 100644 index 0000000000..82186c467a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.diag.txt new file mode 100644 index 0000000000..b7818aa7a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1016: The 'custom' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.stree.txt new file mode 100644 index 0000000000..ec8ed8b511 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForNonStringValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..14)::14 - [@custom {foo?}] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1016(8:0,8 [1] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..14)::6 - [{foo?}] - Gen - SpanEditHandler;Accepts:Any + Text;[{foo]; + QuestionMark;[?]; + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.cspans.txt new file mode 100644 index 0000000000..9e73b54511 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.diag.txt new file mode 100644 index 0000000000..b7818aa7a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1016: The 'custom' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.stree.txt new file mode 100644 index 0000000000..6ad2990a4e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForPartialQuotedValue.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..16)::16 - [@custom AString"] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1016(8:0,8 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [AString"] - Gen - SpanEditHandler;Accepts:Any + Text;[AString]; + DoubleQuote;["]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.cspans.txt new file mode 100644 index 0000000000..d5d9f27aef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.diag.txt new file mode 100644 index 0000000000..b7818aa7a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1016: The 'custom' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.stree.txt new file mode 100644 index 0000000000..eef7233302 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForSingleQuotedValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..17)::17 - [@custom 'AString'] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1016(8:0,8 [9] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..17)::9 - ['AString'] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + Text;[AString]; + SingleQuote;[']; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.cspans.txt new file mode 100644 index 0000000000..5d403c8984 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [7] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.diag.txt new file mode 100644 index 0000000000..b7818aa7a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1016: The 'custom' directive expects a string surrounded by double quotes. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.stree.txt new file mode 100644 index 0000000000..651feb6e9e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_StringToken_ParserErrorForUnquotedValue.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..15)::15 - [@custom AString] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} [RZ1016(8:0,8 [7] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..15)::7 - [AString] - Gen - SpanEditHandler;Accepts:Any + Text;[AString]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.cspans.txt new file mode 100644 index 0000000000..263c7efaa3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [9] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.diag.txt new file mode 100644 index 0000000000..653c80c1d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ1011: The 'custom' directives value(s) must be separated by whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.stree.txt new file mode 100644 index 0000000000..f3d06f68b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_TokensMustBeSeparatedBySpace.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..26)::26 - [@custom "string1""string2"] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 - Directive:{custom;SingleLine;Unrestricted} [RZ1011(17:0,17 [9] )] + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..17)::10 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..17)::9 - ["string1"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["string1"]; + MarkupTextLiteral - [17..26)::9 - ["string2"] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + Text;[string2]; + DoubleQuote;["]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsAttributeTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsAttributeTokens.cspans.txt new file mode 100644 index 0000000000..7911e989b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsAttributeTokens.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [24] ) +MetaCode span at (3:1,1 [6] ) (Accepts:None) - Parent: Directive block at (2:1,0 [24] ) +Code span at (9:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [24] ) +Code span at (10:1,8 [14] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [24] ) +Markup span at (24:1,22 [2] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [24] ) +Markup span at (26:2,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) +Transition span at (26:2,0 [1] ) (Accepts:None) - Parent: Directive block at (26:2,0 [76] ) +MetaCode span at (27:2,1 [6] ) (Accepts:None) - Parent: Directive block at (26:2,0 [76] ) +Code span at (33:2,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (26:2,0 [76] ) +Code span at (34:2,8 [66] ) (Accepts:NonWhitespace) - Parent: Directive block at (26:2,0 [76] ) +Markup span at (100:2,74 [2] ) (Accepts:Whitespace) - Parent: Directive block at (26:2,0 [76] ) +Markup span at (102:3,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [102] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsAttributeTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsAttributeTokens.stree.txt new file mode 100644 index 0000000000..8ae8662dd6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsAttributeTokens.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..102)::102 - [LF@custom [Serializable]LF@custom [DllImport("user32.dll", SetLastError=false, ExactSpelling=false)]LF] + MarkupBlock - [0..102)::102 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..26)::24 + RazorDirective - [2..26)::24 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..26)::23 + RazorMetaCode - [3..9)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [9..26)::17 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..24)::14 - [[Serializable]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftBracket;[[]; + Identifier;[Serializable]; + RightBracket;[]]; + MarkupEphemeralTextLiteral - [24..26)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [26..102)::76 + RazorDirective - [26..102)::76 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [27..102)::75 + RazorMetaCode - [27..33)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [33..102)::69 + CSharpStatementLiteral - [33..34)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [34..100)::66 - [[DllImport("user32.dll", SetLastError=false, ExactSpelling=false)]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + LeftBracket;[[]; + Identifier;[DllImport]; + LeftParenthesis;[(]; + StringLiteral;["user32.dll"]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[SetLastError]; + Assign;[=]; + Keyword;[false]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[ExactSpelling]; + Assign;[=]; + Keyword;[false]; + RightParenthesis;[)]; + RightBracket;[]]; + MarkupEphemeralTextLiteral - [100..102)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [102..102)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.cspans.txt new file mode 100644 index 0000000000..234653b152 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [32] ) +Code span at (8:0,8 [6] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [32] ) +None span at (14:0,14 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Code span at (16:0,16 [15] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.stree.txt new file mode 100644 index 0000000000..c960c4e92d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsCodeBlocks.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..32)::32 - [@custom "Name" { foo(); bar(); }] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + RazorDirective - [0..32)::32 - Directive:{custom;CodeBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..32)::31 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..32)::25 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..14)::6 - ["Name"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["Name"]; + UnclassifiedTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [15..16)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [16..31)::15 + CSharpStatementLiteral - [16..31)::15 - [ foo(); bar(); ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.cspans.txt new file mode 100644 index 0000000000..69febe9867 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [19] ) +Code span at (8:0,8 [11] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.stree.txt new file mode 100644 index 0000000000..d2d51198cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMemberTokens.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..19)::19 - [@custom Some_Member] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + RazorDirective - [0..19)::19 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..19)::18 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..19)::12 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..19)::11 - [Some_Member] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Some_Member]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.cspans.txt new file mode 100644 index 0000000000..9a307ed573 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [64] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [64] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (42:0,42 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (43:0,43 [11] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [64] ) +Markup span at (54:0,54 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [64] ) +Code span at (55:0,55 [9] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [64] ) +Markup span at (64:0,64 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [64] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.stree.txt new file mode 100644 index 0000000000..d2f7b39c4d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsMultipleTokens.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..64)::64 - [@custom System.Text.Encoding.ASCIIEncoding Some_Member "AString"] + MarkupBlock - [0..64)::64 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..64)::64 + RazorDirective - [0..64)::64 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..64)::63 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..64)::57 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..42)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + CSharpStatementLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [43..54)::11 - [Some_Member] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Some_Member]; + MarkupEphemeralTextLiteral - [54..55)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [55..64)::9 - ["AString"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["AString"]; + MarkupTextLiteral - [64..64)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.cspans.txt new file mode 100644 index 0000000000..ccb11164be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [33] ) +Code span at (8:0,8 [8] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [33] ) +None span at (16:0,16 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [33] ) +MetaCode span at (17:0,17 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [14] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [3] ) +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [14] ) +Markup span at (27:0,27 [4] ) (Accepts:Any) - Parent: Tag block at (27:0,27 [4] ) +Markup span at (31:0,31 [1] ) (Accepts:Any) - Parent: Markup block at (18:0,18 [14] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.stree.txt new file mode 100644 index 0000000000..b31e7e4325 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsRazorBlocks.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..33)::33 - [@custom "Header" {

                    F{o}o

                    }] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + RazorDirective - [0..33)::33 - Directive:{custom;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..33)::32 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..33)::26 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..16)::8 - ["Header"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["Header"]; + UnclassifiedTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [17..18)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [18..32)::14 + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [19..31)::12 + MarkupStartTag - [19..22)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [22..27)::5 - [F{o}o] - Gen - SpanEditHandler;Accepts:Any + Text;[F]; + Text;[{]; + Text;[o]; + Text;[}]; + Text;[o]; + MarkupEndTag - [27..31)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.cspans.txt new file mode 100644 index 0000000000..e3413d97ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [17] ) +Code span at (8:0,8 [9] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.stree.txt new file mode 100644 index 0000000000..77987a903f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsStringTokens.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..17)::17 - [@custom "AString"] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..17)::10 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..17)::9 - ["AString"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["AString"]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.cspans.txt new file mode 100644 index 0000000000..fd5256e31f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [42] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [42] ) +Code span at (8:0,8 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [42] ) +Markup span at (42:0,42 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.stree.txt new file mode 100644 index 0000000000..ba28ef0a75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsTypeTokens.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..42)::42 - [@custom System.Text.Encoding.ASCIIEncoding] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + RazorDirective - [0..42)::42 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..42)::41 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..42)::35 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..42)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Class.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Class.cspans.txt new file mode 100644 index 0000000000..35eaf0bb6c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Class.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [6] ) +MetaCode span at (1:0,1 [5] ) (Accepts:None) - Parent: Directive block at (0:0,0 [6] ) +Markup span at (6:0,6 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Class.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Class.stree.txt new file mode 100644 index 0000000000..006f105357 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Class.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..6)::6 - [@class] + MarkupBlock - [0..6)::6 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + RazorDirective - [0..6)::6 - Directive:{class;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..6)::5 + RazorMetaCode - [1..6)::5 - Gen - SpanEditHandler;Accepts:None + Keyword;[class]; + CSharpCodeBlock - [6..6)::0 + MarkupTextLiteral - [6..6)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Namespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Namespace.cspans.txt new file mode 100644 index 0000000000..65fa84c6ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Namespace.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Namespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Namespace.stree.txt new file mode 100644 index 0000000000..9b940ce6e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_CanUseReservedWord_Namespace.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..10)::10 - [@namespace] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + RazorDirective - [0..10)::10 - Directive:{namespace;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..10)::9 + RazorMetaCode - [1..10)::9 - Gen - SpanEditHandler;Accepts:None + Keyword;[namespace]; + CSharpCodeBlock - [10..10)::0 + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_ReservedWordInsideCodeBlock.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_ReservedWordInsideCodeBlock.cspans.txt new file mode 100644 index 0000000000..71420aa95e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_ReservedWordInsideCodeBlock.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Code span at (2:0,2 [7] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_ReservedWordInsideCodeBlock.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_ReservedWordInsideCodeBlock.stree.txt new file mode 100644 index 0000000000..06c87e7534 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Directives_ReservedWordInsideCodeBlock.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..10)::10 - [@{ class }] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + CSharpStatementLiteral - [2..9)::7 - [ class ] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Whitespace;[ ]; + Keyword;[class]; + Whitespace;[ ]; + RazorMetaCode - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/EmptyFunctionsDirective.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/EmptyFunctionsDirective.cspans.txt new file mode 100644 index 0000000000..88828c3534 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/EmptyFunctionsDirective.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Code span at (12:0,12 [1] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [14] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [14] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/EmptyFunctionsDirective.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/EmptyFunctionsDirective.stree.txt new file mode 100644 index 0000000000..4a732dad09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/EmptyFunctionsDirective.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..14)::14 - [@functions { }] + MarkupBlock - [0..14)::14 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..14)::14 + RazorDirective - [0..14)::14 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..14)::13 + RazorMetaCode - [1..10)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [10..14)::4 + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [12..13)::1 + CSharpStatementLiteral - [12..13)::1 - [ ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + Whitespace;[ ]; + RazorMetaCode - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt new file mode 100644 index 0000000000..80b5cd9e14 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Code span at (2:1,0 [2] ) (Accepts:Any) - Parent: Statement block at (2:1,0 [44] ) +Transition span at (4:1,2 [1] ) (Accepts:None) - Parent: Directive block at (4:1,2 [42] ) +MetaCode span at (5:1,3 [6] ) (Accepts:None) - Parent: Directive block at (4:1,2 [42] ) +Code span at (11:1,9 [1] ) (Accepts:Whitespace) - Parent: Directive block at (4:1,2 [42] ) +Code span at (12:1,10 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (4:1,2 [42] ) +Markup span at (46:1,44 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt new file mode 100644 index 0000000000..163880ac97 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveDoesNotErorrIfNotAtStartOfLineBecauseOfWhitespace.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..46)::46 - [LF @custom System.Text.Encoding.ASCIIEncoding] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..46)::44 + CSharpEphemeralTextLiteral - [2..4)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorDirective - [4..46)::42 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [4..5)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [5..46)::41 + RazorMetaCode - [5..11)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [11..46)::35 + CSharpStatementLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [12..46)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.cspans.txt new file mode 100644 index 0000000000..2b00010889 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Directive block at (3:0,3 [44] ) +MetaCode span at (4:0,4 [6] ) (Accepts:None) - Parent: Directive block at (3:0,3 [44] ) +Code span at (10:0,10 [1] ) (Accepts:Whitespace) - Parent: Directive block at (3:0,3 [44] ) +Code span at (11:0,11 [34] ) (Accepts:NonWhitespace) - Parent: Directive block at (3:0,3 [44] ) +Markup span at (45:0,45 [2] ) (Accepts:Whitespace) - Parent: Directive block at (3:0,3 [44] ) +Markup span at (47:1,0 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [48] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.diag.txt new file mode 100644 index 0000000000..1ca018d1a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ2005: The 'custom` directive must appear at the start of the line. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.stree.txt new file mode 100644 index 0000000000..de8aa13386 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/ExtensibleDirectiveErrorsIfNotAtStartOfLine.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..48)::48 - [{ @custom System.Text.Encoding.ASCIIEncodingLF}] + MarkupBlock - [0..48)::48 + MarkupTextLiteral - [0..3)::3 - [{ ] - Gen - SpanEditHandler;Accepts:Any + Text;[{]; + Whitespace;[ ]; + CSharpCodeBlock - [3..47)::44 + RazorDirective - [3..47)::44 - Directive:{custom;SingleLine;Unrestricted} [RZ2005(4:0,4 [6] )] + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [4..47)::43 + RazorMetaCode - [4..10)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [10..47)::37 + CSharpStatementLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [11..45)::34 - [System.Text.Encoding.ASCIIEncoding] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Text]; + Dot;[.]; + Identifier;[Encoding]; + Dot;[.]; + Identifier;[ASCIIEncoding]; + MarkupEphemeralTextLiteral - [45..47)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [47..48)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsArrays.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsArrays.cspans.txt new file mode 100644 index 0000000000..79d48099bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsArrays.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [8] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (9:0,9 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [22] ) +Code span at (10:0,10 [12] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsArrays.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsArrays.stree.txt new file mode 100644 index 0000000000..84882ce25e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsArrays.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..22)::22 - [@inherits string[[]][]] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + RazorDirective - [0..22)::22 - Directive:{inherits;SingleLine;FileScopedSinglyOccurring} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..22)::21 + RazorMetaCode - [1..9)::8 - Gen - SpanEditHandler;Accepts:None + Identifier;[inherits]; + CSharpCodeBlock - [9..22)::13 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..22)::12 - [string[[]][]] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[string]; + LeftBracket;[[]; + LeftBracket;[[]; + RightBracket;[]]; + RightBracket;[]]; + LeftBracket;[[]; + RightBracket;[]]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsNestedGenerics.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsNestedGenerics.cspans.txt new file mode 100644 index 0000000000..4a73c4c8ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsNestedGenerics.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [87] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [87] ) +MetaCode span at (1:0,1 [8] ) (Accepts:None) - Parent: Directive block at (0:0,0 [87] ) +Code span at (9:0,9 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [87] ) +Code span at (10:0,10 [77] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [87] ) +Markup span at (87:0,87 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [87] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsNestedGenerics.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsNestedGenerics.stree.txt new file mode 100644 index 0000000000..b8cf6049cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsNestedGenerics.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..87)::87 - [@inherits System.Web.Mvc.WebViewPage>] + MarkupBlock - [0..87)::87 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..87)::87 + RazorDirective - [0..87)::87 - Directive:{inherits;SingleLine;FileScopedSinglyOccurring} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..87)::86 + RazorMetaCode - [1..9)::8 - Gen - SpanEditHandler;Accepts:None + Identifier;[inherits]; + CSharpCodeBlock - [9..87)::78 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..87)::77 - [System.Web.Mvc.WebViewPage>] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[Web]; + Dot;[.]; + Identifier;[Mvc]; + Dot;[.]; + Identifier;[WebViewPage]; + LessThan;[<]; + Identifier;[IEnumerable]; + LessThan;[<]; + Identifier;[MvcApplication2]; + Dot;[.]; + Identifier;[Models]; + Dot;[.]; + Identifier;[RegisterModel]; + GreaterThan;[>]; + GreaterThan;[>]; + MarkupTextLiteral - [87..87)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsTypeKeywords.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsTypeKeywords.cspans.txt new file mode 100644 index 0000000000..0be18525ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsTypeKeywords.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [8] ) (Accepts:None) - Parent: Directive block at (0:0,0 [16] ) +Code span at (9:0,9 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [16] ) +Code span at (10:0,10 [6] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [16] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsTypeKeywords.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsTypeKeywords.stree.txt new file mode 100644 index 0000000000..12fe4f3b8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/InheritsDirectiveSupportsTypeKeywords.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..16)::16 - [@inherits string] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + RazorDirective - [0..16)::16 - Directive:{inherits;SingleLine;FileScopedSinglyOccurring} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..16)::15 + RazorMetaCode - [1..9)::8 - Gen - SpanEditHandler;Accepts:None + Identifier;[inherits]; + CSharpCodeBlock - [9..16)::7 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..16)::6 - [string] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[string]; + MarkupTextLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_AreSkipped.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_AreSkipped.cspans.txt new file mode 100644 index 0000000000..2afc521ace --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_AreSkipped.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [8] ) +Markup span at (8:0,8 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_AreSkipped.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_AreSkipped.stree.txt new file mode 100644 index 0000000000..592926662b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_AreSkipped.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..8)::8 - [@custom ] + MarkupBlock - [0..8)::8 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + RazorDirective - [0..8)::8 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..8)::7 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..8)::1 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [8..8)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.cspans.txt new file mode 100644 index 0000000000..1b7631b73f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [29] ) +Code span at (8:0,8 [21] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.stree.txt new file mode 100644 index 0000000000..455a063f9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithBraces_AreParsed.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..29)::29 - [@custom "{formaction}?/{id}?"] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + RazorDirective - [0..29)::29 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..29)::28 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..29)::22 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..29)::21 - ["{formaction}?/{id}?"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["{formaction}?/{id}?"]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.cspans.txt new file mode 100644 index 0000000000..d4a6305e23 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [43] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [43] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [43] ) +Code span at (8:0,8 [21] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [43] ) +Code span at (29:0,29 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [43] ) +Code span at (30:0,30 [13] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [43] ) +Markup span at (43:0,43 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.stree.txt new file mode 100644 index 0000000000..de4cde9da7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithMultipleOptionalTokens_AreParsed.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..43)::43 - [@custom "{formaction}?/{id}?" System.String] + MarkupBlock - [0..43)::43 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..43)::43 + RazorDirective - [0..43)::43 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..43)::42 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..43)::36 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..29)::21 - ["{formaction}?/{id}?"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["{formaction}?/{id}?"]; + CSharpStatementLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [30..43)::13 - [System.String] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[System]; + Dot;[.]; + Identifier;[String]; + MarkupTextLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.cspans.txt new file mode 100644 index 0000000000..bd10c900ba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [22] ) +Code span at (8:0,8 [14] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.stree.txt new file mode 100644 index 0000000000..ccd26b5cbe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalDirectiveTokens_WithSimpleTokens_AreParsed.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..22)::22 - [@custom "simple-value"] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + RazorDirective - [0..22)::22 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..22)::21 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..22)::15 + MarkupEphemeralTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..22)::14 - ["simple-value"] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + StringLiteral;["simple-value"]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.cspans.txt new file mode 100644 index 0000000000..0fe58ec33c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [13] ) (Accepts:None) - Parent: Directive block at (0:0,0 [27] ) +Code span at (14:0,14 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [27] ) +Code span at (15:0,15 [12] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.stree.txt new file mode 100644 index 0000000000..adf43bdc9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMemberSpecified_IsParsed.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..27)::27 - [@TestDirective PropertyName] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + RazorDirective - [0..27)::27 - Directive:{TestDirective;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..27)::26 + RazorMetaCode - [1..14)::13 - Gen - SpanEditHandler;Accepts:None + Identifier;[TestDirective]; + CSharpCodeBlock - [14..27)::13 + CSharpStatementLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [15..27)::12 - [PropertyName] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[PropertyName]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.cspans.txt new file mode 100644 index 0000000000..de71313701 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [13] ) (Accepts:None) - Parent: Directive block at (0:0,0 [15] ) +Code span at (14:0,14 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [15] ) +Code span at (15:0,15 [0] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [15] ) +Markup span at (15:0,15 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.stree.txt new file mode 100644 index 0000000000..7a6be62a85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/OptionalMemberTokens_WithMissingMember_IsParsed.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..15)::15 - [@TestDirective ] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + RazorDirective - [0..15)::15 - Directive:{TestDirective;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..15)::14 + RazorMetaCode - [1..14)::13 - Gen - SpanEditHandler;Accepts:None + Identifier;[TestDirective]; + CSharpCodeBlock - [14..15)::1 + CSharpStatementLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [15..15)::0 - [] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Marker;[]; + MarkupTextLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_FunctionsDirective.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_FunctionsDirective.cspans.txt new file mode 100644 index 0000000000..556affaba5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_FunctionsDirective.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [9] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +None span at (10:0,10 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Code span at (12:0,12 [15] ) (Accepts:Any) - Parent: Directive block at (0:0,0 [28] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_FunctionsDirective.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_FunctionsDirective.stree.txt new file mode 100644 index 0000000000..efc89067b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_FunctionsDirective.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..28)::28 - [@functions { foo(); bar(); }] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + RazorDirective - [0..28)::28 - Directive:{functions;CodeBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..28)::27 + RazorMetaCode - [1..10)::9 - Gen - SpanEditHandler;Accepts:None + Identifier;[functions]; + CSharpCodeBlock - [10..28)::18 + UnclassifiedTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [11..12)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + CSharpCodeBlock - [12..27)::15 + CSharpStatementLiteral - [12..27)::15 - [ foo(); bar(); ] - Gen - CodeBlockEditHandler;Accepts:Any;CodeBlock + Whitespace;[ ]; + Identifier;[foo]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + Identifier;[bar]; + LeftParenthesis;[(]; + RightParenthesis;[)]; + Semicolon;[;]; + Whitespace;[ ]; + RazorMetaCode - [27..28)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_SectionDirective.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_SectionDirective.cspans.txt new file mode 100644 index 0000000000..c3fbe4e475 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_SectionDirective.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [7] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Code span at (8:0,8 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [32] ) +Code span at (9:0,9 [6] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [32] ) +None span at (15:0,15 [1] ) (Accepts:AllWhitespace) - Parent: Directive block at (0:0,0 [32] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +Markup span at (18:0,18 [3] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (21:0,21 [5] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +Markup span at (26:0,26 [4] ) (Accepts:Any) - Parent: Tag block at (26:0,26 [4] ) +Markup span at (30:0,30 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_SectionDirective.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_SectionDirective.stree.txt new file mode 100644 index 0000000000..4e1eeb325a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parse_SectionDirective.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..32)::32 - [@section Header {

                    F{o}o

                    }] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + RazorDirective - [0..32)::32 - Directive:{section;RazorBlock;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..32)::31 + RazorMetaCode - [1..8)::7 - Gen - SpanEditHandler;Accepts:None + Identifier;[section]; + CSharpCodeBlock - [8..32)::24 + CSharpStatementLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [9..15)::6 - [Header] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[Header]; + UnclassifiedTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:AllWhitespace + Whitespace;[ ]; + RazorMetaCode - [16..17)::1 - Gen - AutoCompleteEditHandler;Accepts:None,AutoComplete:[];AtEnd + LeftBrace;[{]; + MarkupBlock - [17..31)::14 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [18..30)::12 + MarkupStartTag - [18..21)::3 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [21..26)::5 - [F{o}o] - Gen - SpanEditHandler;Accepts:Any + Text;[F]; + Text;[{]; + Text;[o]; + Text;[}]; + Text;[o]; + MarkupEndTag - [26..30)::4 - [

                    ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.cspans.txt new file mode 100644 index 0000000000..93ef395357 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [29] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [29] ) +Code span at (8:0,8 [21] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.stree.txt new file mode 100644 index 0000000000..4e03f5befe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithMultipleSegments.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..29)::29 - [@custom BaseNamespace.Foo.Bar] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + RazorDirective - [0..29)::29 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..29)::28 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..29)::22 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..29)::21 - [BaseNamespace.Foo.Bar] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[BaseNamespace]; + Dot;[.]; + Identifier;[Foo]; + Dot;[.]; + Identifier;[Bar]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.cspans.txt new file mode 100644 index 0000000000..e096a23423 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [6] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (7:0,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (0:0,0 [21] ) +Code span at (8:0,8 [13] ) (Accepts:NonWhitespace) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.stree.txt new file mode 100644 index 0000000000..1d64e3ae92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/Parser_ParsesNamespaceDirectiveToken_WithSingleSegment.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..21)::21 - [@custom BaseNamespace] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + RazorDirective - [0..21)::21 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..21)::20 + RazorMetaCode - [1..7)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [7..21)::14 + CSharpStatementLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [8..21)::13 - [BaseNamespace] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[BaseNamespace]; + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..b0884a958a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt new file mode 100644 index 0000000000..8420d6c340 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt @@ -0,0 +1 @@ +(1,21): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..9ea983ad50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..21)::21 - [@removeTagHelper Foo"] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + RazorDirective - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..21)::20 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..21)::5 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..21)::4 - [Foo"] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + StringLiteral;["];RZ1000(20:0,20 [1] ) + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..a3ad9a1394 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (17:0,17 [3] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..6ca3c0b460 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..20)::20 - [@removeTagHelper Foo] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + RazorDirective - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..20)::19 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..20)::4 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.cspans.txt new file mode 100644 index 0000000000..0dfe38be7c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (17:0,17 [2] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.stree.txt new file mode 100644 index 0000000000..1fcd5587a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_NoValue_Invalid.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..19)::19 - [@removeTagHelper ""] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + RazorDirective - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..19)::18 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..19)::3 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..19)::2 - [""] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;[""]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_RequiresValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_RequiresValue.cspans.txt new file mode 100644 index 0000000000..a8d324c3dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_RequiresValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_RequiresValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_RequiresValue.stree.txt new file mode 100644 index 0000000000..20a0666a00 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_RequiresValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..17)::17 - [@removeTagHelper ] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Marker;[]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.cspans.txt new file mode 100644 index 0000000000..d9553ee9ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [25] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [25] ) +Code span at (17:0,17 [8] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.stree.txt new file mode 100644 index 0000000000..7584b6d08b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SingleQuotes_AddsError.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..25)::25 - [@removeTagHelper '*, Foo'] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + RazorDirective - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..25)::24 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..25)::9 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..25)::8 - ['*, Foo'] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + CharacterLiteral;['*, Foo']; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..b0884a958a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt new file mode 100644 index 0000000000..c1d5bcd34e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..41c54a8e5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..21)::21 - [@removeTagHelper "Foo] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + RazorDirective - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..21)::20 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..21)::5 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..21)::4 - ["Foo] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["Foo];RZ1000(17:0,17 [1] ) + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.cspans.txt new file mode 100644 index 0000000000..71bf30f73f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [35] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [35] ) +Markup span at (16:0,16 [5] ) (Accepts:None) - Parent: Directive block at (0:0,0 [35] ) +Code span at (21:0,21 [14] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [35] ) +Markup span at (35:0,35 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.stree.txt new file mode 100644 index 0000000000..e3062d1894 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_SupportsSpaces.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..35)::35 - [@removeTagHelper Foo, Bar ] + MarkupBlock - [0..35)::35 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..35)::35 + RazorDirective - [0..35)::35 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..35)::34 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..35)::19 + MarkupTextLiteral - [16..21)::5 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [21..35)::14 - [Foo, Bar ] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + Comma;[,]; + Whitespace;[ ]; + Identifier;[Bar]; + Whitespace;[ ]; + MarkupTextLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt new file mode 100644 index 0000000000..b919e2b98c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (17:0,17 [5] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt new file mode 100644 index 0000000000..92659f0769 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/RemoveTagHelperDirective_WithQuotes_InvalidLookupText_AddsError.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..22)::22 - [@removeTagHelper "Foo"] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + RazorDirective - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..22)::21 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[removeTagHelper]; + CSharpCodeBlock - [16..22)::6 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..22)::5 - ["Foo"] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["Foo"]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..06a4f306a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [24] ) +Code span at (17:0,17 [7] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt new file mode 100644 index 0000000000..7628ab1cb8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.diag.txt @@ -0,0 +1 @@ +(1,24): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..757c8c81f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_EndQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..24)::24 - [@tagHelperPrefix Foo "] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + RazorDirective - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..24)::23 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[tagHelperPrefix]; + CSharpCodeBlock - [16..24)::8 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..24)::7 - [Foo "] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + Whitespace;[ ]; + StringLiteral;["];RZ1000(23:0,23 [1] ) + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.cspans.txt new file mode 100644 index 0000000000..0dfe38be7c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [19] ) +Code span at (17:0,17 [2] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.stree.txt new file mode 100644 index 0000000000..ee06179c7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_NoValueSucceeds.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..19)::19 - [@tagHelperPrefix ""] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + RazorDirective - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..19)::18 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[tagHelperPrefix]; + CSharpCodeBlock - [16..19)::3 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..19)::2 - [""] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;[""]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_RequiresValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_RequiresValue.cspans.txt new file mode 100644 index 0000000000..a8d324c3dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_RequiresValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [17] ) +Code span at (17:0,17 [0] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_RequiresValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_RequiresValue.stree.txt new file mode 100644 index 0000000000..0e86bb2dc2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_RequiresValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..17)::17 - [@tagHelperPrefix ] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + RazorDirective - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..17)::16 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[tagHelperPrefix]; + CSharpCodeBlock - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Marker;[]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt new file mode 100644 index 0000000000..b0884a958a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [21] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [21] ) +Markup span at (21:0,21 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt new file mode 100644 index 0000000000..c1d5bcd34e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt new file mode 100644 index 0000000000..3e26d675c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_StartQuoteRequiresDoubleQuotesAroundValue.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..21)::21 - [@tagHelperPrefix "Foo] + MarkupBlock - [0..21)::21 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + RazorDirective - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..21)::20 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[tagHelperPrefix]; + CSharpCodeBlock - [16..21)::5 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..21)::4 - ["Foo] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["Foo];RZ1000(17:0,17 [1] ) + MarkupTextLiteral - [21..21)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_Succeeds.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_Succeeds.cspans.txt new file mode 100644 index 0000000000..a3ad9a1394 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_Succeeds.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [20] ) +Code span at (17:0,17 [3] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_Succeeds.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_Succeeds.stree.txt new file mode 100644 index 0000000000..8b875e2851 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_Succeeds.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..20)::20 - [@tagHelperPrefix Foo] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + RazorDirective - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..20)::19 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[tagHelperPrefix]; + CSharpCodeBlock - [16..20)::4 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..20)::3 - [Foo] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + Identifier;[Foo]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.cspans.txt new file mode 100644 index 0000000000..b919e2b98c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [15] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Directive block at (0:0,0 [22] ) +Code span at (17:0,17 [5] ) (Accepts:AnyExceptNewline) - Parent: Directive block at (0:0,0 [22] ) +Markup span at (22:0,22 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.stree.txt new file mode 100644 index 0000000000..1bbaa5ea09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/TagHelperPrefixDirective_WithQuotes_Succeeds.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..22)::22 - [@tagHelperPrefix "Foo"] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + RazorDirective - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [1..22)::21 + RazorMetaCode - [1..16)::15 - Gen - SpanEditHandler;Accepts:None + Identifier;[tagHelperPrefix]; + CSharpCodeBlock - [16..22)::6 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [17..22)::5 - ["Foo"] - Gen - SpanEditHandler;Accepts:AnyExceptNewline + StringLiteral;["Foo"]; + MarkupTextLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.stree.txt new file mode 100644 index 0000000000..519c877aeb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..15)::15 - [] + MarkupBlock - [0..15)::15 + MarkupTagHelperElement - [0..15)::15 - input[StartTagAndEndTag] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [7..15)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.tspans.txt new file mode 100644 index 0000000000..16070edad3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [15] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.stree.txt new file mode 100644 index 0000000000..7e6e3e333d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..9)::9 - [] + MarkupBlock - [0..9)::9 + MarkupTagHelperElement - [0..9)::9 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..9)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.tspans.txt new file mode 100644 index 0000000000..455dab9ef7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [9] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.cspans.txt new file mode 100644 index 0000000000..b60f44ce86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.cspans.txt @@ -0,0 +1 @@ +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.stree.txt new file mode 100644 index 0000000000..57e7823a04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..19)::19 - [] + MarkupBlock - [0..19)::19 + MarkupTagHelperElement - [0..19)::19 - input[StartTagOnly] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..19)::19 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - type - SingleQuotes - Unbound - [ type='text'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..11)::4 - [type] - Gen - SpanEditHandler;Accepts:Any + Text;[type]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + MarkupLiteralAttributeValue - [13..17)::4 - [text] + MarkupTextLiteral - [13..17)::4 - [text] - Gen - SpanEditHandler;Accepts:Any + Text;[text]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.tspans.txt new file mode 100644 index 0000000000..1ad745ab0a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [19] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.stree.txt new file mode 100644 index 0000000000..8bb6ec3a6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..14)::14 - [] + MarkupBlock - [0..14)::14 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTagHelperElement - [7..14)::7 - input[StartTagOnly] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [7..14)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.tspans.txt new file mode 100644 index 0000000000..4668eab0f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper1 - InputTagHelper2 +TagHelper span at (7:0,7 [7] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.cspans.txt new file mode 100644 index 0000000000..a258c3ec2a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.cspans.txt @@ -0,0 +1 @@ +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.stree.txt new file mode 100644 index 0000000000..86a6919a3b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..27)::27 - [] + MarkupBlock - [0..27)::27 + MarkupTagHelperElement - [0..27)::27 - input[StartTagAndEndTag] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..19)::19 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - type - SingleQuotes - Unbound - [ type='text'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..11)::4 - [type] - Gen - SpanEditHandler;Accepts:Any + Text;[type]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + MarkupLiteralAttributeValue - [13..17)::4 - [text] + MarkupTextLiteral - [13..17)::4 - [text] - Gen - SpanEditHandler;Accepts:Any + Text;[text]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [19..27)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.tspans.txt new file mode 100644 index 0000000000..91e8a12872 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [27] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.stree.txt new file mode 100644 index 0000000000..7e6e3e333d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..9)::9 - [] + MarkupBlock - [0..9)::9 + MarkupTagHelperElement - [0..9)::9 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..9)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.tspans.txt new file mode 100644 index 0000000000..455dab9ef7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [9] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.stree.txt new file mode 100644 index 0000000000..7e6e3e333d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..9)::9 - [] + MarkupBlock - [0..9)::9 + MarkupTagHelperElement - [0..9)::9 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..9)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.tspans.txt new file mode 100644 index 0000000000..455dab9ef7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [9] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.cspans.txt new file mode 100644 index 0000000000..e554bcd255 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.cspans.txt @@ -0,0 +1 @@ +Markup span at (7:0,7 [8] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.stree.txt new file mode 100644 index 0000000000..3d9d0fd71c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..15)::15 - [] + MarkupBlock - [0..15)::15 + MarkupElement - [0..15)::15 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupEndTag - [7..15)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.tspans.txt new file mode 100644 index 0000000000..aa95134310 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing.cspans.txt new file mode 100644 index 0000000000..a40388da90 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Transition span at (7:0,7 [1] ) (Accepts:None) - Parent: Expression block at (7:0,7 [8] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (7:0,7 [8] ) +Markup span at (15:0,15 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Expression block at (17:0,17 [5] ) +Code span at (18:0,18 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (17:0,17 [5] ) +Markup span at (22:0,22 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing.stree.txt new file mode 100644 index 0000000000..4767764612 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_SelfClosing.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..25)::25 - [] + MarkupBlock - [0..25)::25 + MarkupElement - [0..25)::25 + MarkupStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [6..23)::17 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [7..15)::8 + CSharpImplicitExpression - [7..15)::8 + CSharpTransition - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [8..15)::7 + CSharpCodeBlock - [8..15)::7 + CSharpExpressionLiteral - [8..15)::7 - [onclick] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[onclick]; + MarkupTextLiteral - [15..17)::2 - [="] - Gen - SpanEditHandler;Accepts:Any + Equals;[=]; + DoubleQuote;["]; + CSharpCodeBlock - [17..22)::5 + CSharpImplicitExpression - [17..22)::5 + CSharpTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [18..22)::4 + CSharpCodeBlock - [18..22)::4 + CSharpExpressionLiteral - [18..22)::4 - [test] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[test]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_Void.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_Void.cspans.txt new file mode 100644 index 0000000000..6bf72d0a28 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_Void.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) +Transition span at (7:0,7 [1] ) (Accepts:None) - Parent: Expression block at (7:0,7 [8] ) +Code span at (8:0,8 [7] ) (Accepts:NonWhitespace) - Parent: Expression block at (7:0,7 [8] ) +Markup span at (15:0,15 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Expression block at (17:0,17 [5] ) +Code span at (18:0,18 [4] ) (Accepts:NonWhitespace) - Parent: Expression block at (17:0,17 [5] ) +Markup span at (22:0,22 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_Void.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_Void.stree.txt new file mode 100644 index 0000000000..053d68870d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/AllowsCompatibleTagStructures_DirectiveAttribute_Void.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupElement - [0..24)::24 + MarkupStartTag - [0..24)::24 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [6..23)::17 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [7..15)::8 + CSharpImplicitExpression - [7..15)::8 + CSharpTransition - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [8..15)::7 + CSharpCodeBlock - [8..15)::7 + CSharpExpressionLiteral - [8..15)::7 - [onclick] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[onclick]; + MarkupTextLiteral - [15..17)::2 - [="] - Gen - SpanEditHandler;Accepts:Any + Equals;[=]; + DoubleQuote;["]; + CSharpCodeBlock - [17..22)::5 + CSharpImplicitExpression - [17..22)::5 + CSharpTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [18..22)::4 + CSharpCodeBlock - [18..22)::4 + CSharpExpressionLiteral - [18..22)::4 - [test] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[test]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.cspans.txt new file mode 100644 index 0000000000..9b14508ec9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.cspans.txt @@ -0,0 +1 @@ +Code span at (18:0,18 [5] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.stree.txt new file mode 100644 index 0000000000..8ce5207ab4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..30)::30 - [
                      ] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - ul[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[ul]; + MarkupMinimizedTagHelperAttribute - [3..9)::6 - bound - Minimized - Unbound - [ bound] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + MarkupTagHelperAttribute - [9..24)::15 - [item] - SingleQuotes - Bound - [ [item]='items'] + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [10..16)::6 - [[item]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[item]; + RightBracket;[]]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [18..23)::5 + CSharpExpressionLiteral - [18..23)::5 - [items] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[items]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [25..30)::5 - [
                      ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.tspans.txt new file mode 100644 index 0000000000..c4ad978332 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [30] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.cspans.txt new file mode 100644 index 0000000000..66cc617a5e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.cspans.txt @@ -0,0 +1 @@ +Code span at (20:0,20 [5] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.stree.txt new file mode 100644 index 0000000000..84a9a37563 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..32)::32 - [
                        ] + MarkupBlock - [0..32)::32 + MarkupTagHelperElement - [0..32)::32 - ul[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..27)::27 - [
                          ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[ul]; + MarkupMinimizedTagHelperAttribute - [3..9)::6 - bound - Minimized - Unbound - [ bound] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + MarkupTagHelperAttribute - [9..26)::17 - [(item)] - SingleQuotes - Bound - [ [(item)]='items'] + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [10..18)::8 - [[(item)]] - Gen - SpanEditHandler;Accepts:Any + LeftBracket;[[]; + Text;[(item)]; + RightBracket;[]]; + Equals;[=]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [20..25)::5 + CSharpExpressionLiteral - [20..25)::5 - [items] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[items]; + MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [27..32)::5 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[ul]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.tspans.txt new file mode 100644 index 0000000000..8dc73d4362 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [32] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.cspans.txt new file mode 100644 index 0000000000..2dfc773ede --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.cspans.txt @@ -0,0 +1,2 @@ +Code span at (23:0,23 [13] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [55] ) +Markup span at (38:0,38 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.stree.txt new file mode 100644 index 0000000000..0acd0c5753 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..55)::55 - [] + MarkupBlock - [0..55)::55 + MarkupTagHelperElement - [0..55)::55 - button[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..38)::38 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[button]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.tspans.txt new file mode 100644 index 0000000000..9d626a71d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [55] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.cspans.txt new file mode 100644 index 0000000000..668451676c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.cspans.txt @@ -0,0 +1,2 @@ +Code span at (24:0,24 [13] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [56] ) +Markup span at (39:0,39 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.stree.txt new file mode 100644 index 0000000000..d2ab596a3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..56)::56 - [] + MarkupBlock - [0..56)::56 + MarkupTagHelperElement - [0..56)::56 - button[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..39)::39 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[button]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.tspans.txt new file mode 100644 index 0000000000..1e7d20eb36 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [56] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.cspans.txt new file mode 100644 index 0000000000..4cfe9f7c9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.cspans.txt @@ -0,0 +1 @@ +Markup span at (28:0,28 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.stree.txt new file mode 100644 index 0000000000..2a17b586c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..46)::46 - [] + MarkupBlock - [0..46)::46 + MarkupTagHelperElement - [0..46)::46 - template[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..35)::35 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[template]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.tspans.txt new file mode 100644 index 0000000000..9666dfd4cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [46] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.stree.txt new file mode 100644 index 0000000000..343ff5e896 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..33)::33 - [
                        ] + MarkupBlock - [0..33)::33 + MarkupTagHelperElement - [0..33)::33 - div[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..27)::27 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupMinimizedTagHelperAttribute - [4..10)::6 - bound - Minimized - Unbound - [ bound] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + MarkupMinimizedTagHelperAttribute - [10..26)::16 - #localminimized - Minimized - Unbound - [ #localminimized] + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [11..26)::15 - [#localminimized] - Gen - SpanEditHandler;Accepts:Any + Text;[#localminimized]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [27..33)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.tspans.txt new file mode 100644 index 0000000000..a6c7ee0196 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [33] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.cspans.txt new file mode 100644 index 0000000000..a75e5a0d69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.cspans.txt @@ -0,0 +1 @@ +Markup span at (19:0,19 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.diag.txt new file mode 100644 index 0000000000..7854af144b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[item]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[item]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a '[' character. +(0,0): Error RZ3003: Invalid tag helper bound property '[(item)]' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '[(item)]' because the name contains a ']' character. +(0,0): Error RZ3003: Invalid tag helper bound property '*something' on tag helper 'CatchAllTagHelper'. Tag helpers cannot bind to HTML attributes with name '*something' because the name contains a '*' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.stree.txt new file mode 100644 index 0000000000..bac65eeedf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..32)::32 - [
                        ] + MarkupBlock - [0..32)::32 + MarkupTagHelperElement - [0..32)::32 - div[StartTagAndEndTag] - CatchAllTagHelper + MarkupTagHelperStartTag - [0..26)::26 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupMinimizedTagHelperAttribute - [4..10)::6 - bound - Minimized - Unbound - [ bound] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + MarkupTagHelperAttribute - [10..25)::15 - #local - SingleQuotes - Bound - [ #local='value'] + MarkupTextLiteral - [10..11)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [11..17)::6 - [#local] - Gen - SpanEditHandler;Accepts:Any + Text;[#local]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [19..24)::5 + MarkupTextLiteral - [19..24)::5 - [value] - Gen - SpanEditHandler;Accepts:Any + Text;[value]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [26..32)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.tspans.txt new file mode 100644 index 0000000000..8dc73d4362 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleSymbolBoundAttributes7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [32] ) - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.stree.txt new file mode 100644 index 0000000000..5a61ddfab0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.stree.txt @@ -0,0 +1,7 @@ +RazorDocument - [0..7)::7 - [] + MarkupBlock - [0..7)::7 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.tspans.txt new file mode 100644 index 0000000000..507d5a1ed9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.cspans.txt new file mode 100644 index 0000000000..b60f44ce86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.cspans.txt @@ -0,0 +1 @@ +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.stree.txt new file mode 100644 index 0000000000..090e52dcca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..19)::19 - [] + MarkupBlock - [0..19)::19 + MarkupTagHelperElement - [0..19)::19 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..19)::19 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - type - SingleQuotes - Unbound - [ type='text'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..11)::4 - [type] - Gen - SpanEditHandler;Accepts:Any + Text;[type]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + MarkupLiteralAttributeValue - [13..17)::4 - [text] + MarkupTextLiteral - [13..17)::4 - [text] - Gen - SpanEditHandler;Accepts:Any + Text;[text]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.tspans.txt new file mode 100644 index 0000000000..0ea7cf09ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [19] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.stree.txt new file mode 100644 index 0000000000..17f6f04e9a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..14)::14 - [] + MarkupBlock - [0..14)::14 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTagHelperElement - [7..14)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [7..14)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.tspans.txt new file mode 100644 index 0000000000..533ebe3e15 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper +TagHelper span at (7:0,7 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.cspans.txt new file mode 100644 index 0000000000..b60f44ce86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.cspans.txt @@ -0,0 +1 @@ +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.stree.txt new file mode 100644 index 0000000000..8bc473614e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..26)::26 - [] + MarkupBlock - [0..26)::26 + MarkupTagHelperElement - [0..19)::19 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..19)::19 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - type - SingleQuotes - Unbound - [ type='text'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..11)::4 - [type] - Gen - SpanEditHandler;Accepts:Any + Text;[type]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + MarkupLiteralAttributeValue - [13..17)::4 - [text] + MarkupTextLiteral - [13..17)::4 - [text] - Gen - SpanEditHandler;Accepts:Any + Text;[text]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperElement - [19..26)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [19..26)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.tspans.txt new file mode 100644 index 0000000000..cf1d9627ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [19] ) - InputTagHelper +TagHelper span at (19:0,19 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.cspans.txt new file mode 100644 index 0000000000..e757d8a3f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (19:0,19 [6] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.stree.txt new file mode 100644 index 0000000000..b1c2556772 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..25)::25 - [
                        ] + MarkupBlock - [0..25)::25 + MarkupElement - [0..25)::25 + MarkupStartTag - [0..5)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperElement - [5..12)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [5..12)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTagHelperElement - [12..19)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [12..19)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupEndTag - [19..25)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.tspans.txt new file mode 100644 index 0000000000..f380f7abd5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CanHandleWithoutEndTagTagStructure5.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (5:0,5 [7] ) - InputTagHelper +TagHelper span at (12:0,12 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.cspans.txt new file mode 100644 index 0000000000..aa429ff6cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.cspans.txt @@ -0,0 +1 @@ +Code span at (13:0,13 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.diag.txt new file mode 100644 index 0000000000..c11ff99be0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.stree.txt new file mode 100644 index 0000000000..6937a24def --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..17)::17 - [] + MarkupBlock - [0..17)::17 + MarkupTagHelperElement - [0..17)::17 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..17)::17 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..14)::9 - bound - SingleQuotes - Bound - [ bound=''] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..13)::0 + CSharpExpressionLiteral - [13..13)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [14..15)::1 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.tspans.txt new file mode 100644 index 0000000000..2835be7bef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [17] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.cspans.txt new file mode 100644 index 0000000000..aa429ff6cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.cspans.txt @@ -0,0 +1 @@ +Code span at (13:0,13 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.diag.txt new file mode 100644 index 0000000000..d57ce479b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2008: Attribute 'BouND' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.stree.txt new file mode 100644 index 0000000000..f788e58531 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..17)::17 - [] + MarkupBlock - [0..17)::17 + MarkupTagHelperElement - [0..17)::17 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..17)::17 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..14)::9 - BouND - SingleQuotes - Bound - [ BouND=''] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [BouND] - Gen - SpanEditHandler;Accepts:Any + Text;[BouND]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..13)::0 + CSharpExpressionLiteral - [13..13)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [14..15)::1 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.tspans.txt new file mode 100644 index 0000000000..2835be7bef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [17] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.cspans.txt new file mode 100644 index 0000000000..92552dfb4e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.cspans.txt @@ -0,0 +1,2 @@ +Code span at (13:0,13 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [29] ) +Code span at (25:0,25 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.diag.txt new file mode 100644 index 0000000000..9739cf1558 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.diag.txt @@ -0,0 +1,2 @@ +(1,7): Error RZ2008: Attribute 'BOUND' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +(1,19): Error RZ2008: Attribute 'bOUnd' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.stree.txt new file mode 100644 index 0000000000..6b645d8c86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..29)::29 - [] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..29)::29 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..14)::9 - BOUND - SingleQuotes - Bound - [ BOUND=''] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [BOUND] - Gen - SpanEditHandler;Accepts:Any + Text;[BOUND]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..13)::0 + CSharpExpressionLiteral - [13..13)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [14..26)::12 - bOUnd - DoubleQuotes - Bound - [ bOUnd=""] + MarkupTextLiteral - [14..18)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..23)::5 - [bOUnd] - Gen - SpanEditHandler;Accepts:Any + Text;[bOUnd]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [25..25)::0 + CSharpExpressionLiteral - [25..25)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [25..26)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [26..27)::1 + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.tspans.txt new file mode 100644 index 0000000000..c8af5cb7b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.cspans.txt new file mode 100644 index 0000000000..228e1bbc94 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.cspans.txt @@ -0,0 +1,2 @@ +Code span at (12:0,12 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [32] ) +Markup span at (19:0,19 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.diag.txt new file mode 100644 index 0000000000..52810ad2c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2008: Attribute 'BOUND' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.stree.txt new file mode 100644 index 0000000000..a88f2f766b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..32)::32 - [] + MarkupBlock - [0..32)::32 + MarkupTagHelperElement - [0..32)::32 - myth[StartTagAndEndTag] - mythTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..12)::7 - BOUND - DoubleQuotes - Bound - [ BOUND=] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [BOUND] - Gen - SpanEditHandler;Accepts:Any + Text;[BOUND]; + Equals;[=]; + MarkupTagHelperAttributeValue - [12..12)::0 + CSharpExpressionLiteral - [12..12)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTagHelperAttribute - [12..24)::12 - nAMe - SingleQuotes - Bound - [ nAMe='john'] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..17)::4 - [nAMe] - Gen - SpanEditHandler;Accepts:Any + Text;[nAMe]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [19..23)::4 + MarkupTextLiteral - [19..23)::4 - [john] - Gen - SpanEditHandler;Accepts:Any + Text;[john]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [25..32)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[myth]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.tspans.txt new file mode 100644 index 0000000000..f6beb36090 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [32] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.cspans.txt new file mode 100644 index 0000000000..7fafd220d5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.cspans.txt @@ -0,0 +1,4 @@ +Code span at (13:0,13 [4] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [9] ) +Code span at (17:0,17 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [5] ) +Code span at (18:0,18 [4] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [5] ) +Code span at (22:0,22 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.stree.txt new file mode 100644 index 0000000000..a481acc898 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..28)::28 - [] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..28)::28 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..25)::20 - bound - SingleQuotes - Bound - [ bound=' @true '] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..24)::11 + MarkupBlock - [13..22)::9 + CSharpExpressionLiteral - [13..17)::4 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + CSharpCodeBlock - [17..22)::5 + CSharpImplicitExpression - [17..22)::5 + CSharpTransition - [17..17)::0 + Transition;[]; + CSharpImplicitExpressionBody - [17..22)::5 + CSharpCodeBlock - [17..22)::5 + CSharpExpressionLiteral - [17..18)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [18..22)::4 - [true] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Keyword;[true]; + CSharpExpressionLiteral - [22..24)::2 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [25..26)::1 + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.tspans.txt new file mode 100644 index 0000000000..303ab8debe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes13.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.cspans.txt new file mode 100644 index 0000000000..f70a554673 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.cspans.txt @@ -0,0 +1,6 @@ +Code span at (13:0,13 [4] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [11] ) +Code span at (17:0,17 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [7] ) +Code span at (18:0,18 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [7] ) +Code span at (19:0,19 [4] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [7] ) +Code span at (23:0,23 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [7] ) +Code span at (24:0,24 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.stree.txt new file mode 100644 index 0000000000..b258c86d31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..30)::30 - [] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..30)::30 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..27)::22 - bound - SingleQuotes - Bound - [ bound=' @(true) '] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..26)::13 + MarkupBlock - [13..24)::11 + CSharpExpressionLiteral - [13..17)::4 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + CSharpCodeBlock - [17..24)::7 + CSharpImplicitExpression - [17..24)::7 + CSharpTransition - [17..17)::0 + Transition;[]; + CSharpImplicitExpressionBody - [17..24)::7 + CSharpCodeBlock - [17..24)::7 + CSharpExpressionLiteral - [17..18)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [18..19)::1 - [(] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + LeftParenthesis;[(]; + CSharpExpressionLiteral - [19..23)::4 - [true] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Keyword;[true]; + CSharpExpressionLiteral - [23..24)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + RightParenthesis;[)]; + CSharpExpressionLiteral - [24..26)::2 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + MarkupTextLiteral - [26..27)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [27..28)::1 + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.tspans.txt new file mode 100644 index 0000000000..5e6577587f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes14.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [30] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.cspans.txt new file mode 100644 index 0000000000..f8351f76e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.cspans.txt @@ -0,0 +1 @@ +Code span at (13:0,13 [8] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.stree.txt new file mode 100644 index 0000000000..062be46ba2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..25)::25 - [] + MarkupBlock - [0..25)::25 + MarkupTagHelperElement - [0..25)::25 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..22)::17 - bound - SingleQuotes - Bound - [ bound=' true'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..21)::8 + CSharpExpressionLiteral - [13..21)::8 - [ true] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + Text;[true]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [22..23)::1 + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.tspans.txt new file mode 100644 index 0000000000..002029ae1e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.cspans.txt new file mode 100644 index 0000000000..d5ea717f81 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.cspans.txt @@ -0,0 +1 @@ +Code span at (13:0,13 [4] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.diag.txt new file mode 100644 index 0000000000..c11ff99be0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.stree.txt new file mode 100644 index 0000000000..e0945db0f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..21)::21 - [] + MarkupBlock - [0..21)::21 + MarkupTagHelperElement - [0..21)::21 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..21)::21 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..18)::13 - bound - SingleQuotes - Bound - [ bound=' '] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + CSharpExpressionLiteral - [13..17)::4 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [18..19)::1 + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.tspans.txt new file mode 100644 index 0000000000..05e209c319 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [21] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.cspans.txt new file mode 100644 index 0000000000..dddc839de0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.cspans.txt @@ -0,0 +1,2 @@ +Code span at (13:0,13 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [27] ) +Code span at (23:0,23 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.diag.txt new file mode 100644 index 0000000000..9a927a8ecb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.diag.txt @@ -0,0 +1,2 @@ +(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +(1,17): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.stree.txt new file mode 100644 index 0000000000..b1a4d9090c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..27)::27 - [] + MarkupBlock - [0..27)::27 + MarkupTagHelperElement - [0..27)::27 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..27)::27 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..14)::9 - bound - SingleQuotes - Bound - [ bound=''] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..13)::0 + CSharpExpressionLiteral - [13..13)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [14..24)::10 - bound - DoubleQuotes - Bound - [ bound=""] + MarkupTextLiteral - [14..16)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [16..21)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [23..23)::0 + CSharpExpressionLiteral - [23..23)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [24..25)::1 + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.tspans.txt new file mode 100644 index 0000000000..dc2eb23533 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [27] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.cspans.txt new file mode 100644 index 0000000000..bd305a47b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.cspans.txt @@ -0,0 +1,2 @@ +Code span at (13:0,13 [1] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [30] ) +Code span at (24:0,24 [2] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.diag.txt new file mode 100644 index 0000000000..f16283e328 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.diag.txt @@ -0,0 +1,2 @@ +(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +(1,18): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.stree.txt new file mode 100644 index 0000000000..4d4340f5e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..30)::30 - [] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..30)::30 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..15)::10 - bound - SingleQuotes - Bound - [ bound=' '] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..14)::1 + CSharpExpressionLiteral - [13..14)::1 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + MarkupTextLiteral - [14..15)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [15..27)::12 - bound - DoubleQuotes - Bound - [ bound=" "] + MarkupTextLiteral - [15..17)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..22)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [24..26)::2 + CSharpExpressionLiteral - [24..26)::2 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [27..28)::1 + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.tspans.txt new file mode 100644 index 0000000000..5e6577587f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [30] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.cspans.txt new file mode 100644 index 0000000000..ee1acf6e62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.cspans.txt @@ -0,0 +1,2 @@ +Code span at (13:0,13 [4] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [29] ) +Code span at (25:0,25 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.diag.txt new file mode 100644 index 0000000000..7993f8fe1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.diag.txt @@ -0,0 +1 @@ +(1,20): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.stree.txt new file mode 100644 index 0000000000..cc21cab405 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..29)::29 - [] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..29)::29 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..18)::13 - bound - SingleQuotes - Bound - [ bound='true'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + CSharpExpressionLiteral - [13..17)::4 - [true] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[true]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [18..25)::7 - bound - DoubleQuotes - Bound - [ bound=] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..24)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTagHelperAttributeValue - [25..25)::0 + CSharpExpressionLiteral - [25..25)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupMiscAttributeContent - [25..27)::2 + MarkupTextLiteral - [25..27)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.tspans.txt new file mode 100644 index 0000000000..c8af5cb7b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.cspans.txt new file mode 100644 index 0000000000..ebd5438288 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.cspans.txt @@ -0,0 +1,2 @@ +Code span at (12:0,12 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [23] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.diag.txt new file mode 100644 index 0000000000..c11ff99be0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.stree.txt new file mode 100644 index 0000000000..52b638b1fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..23)::23 - [] + MarkupBlock - [0..23)::23 + MarkupTagHelperElement - [0..23)::23 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..23)::23 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..12)::7 - bound - DoubleQuotes - Bound - [ bound=] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTagHelperAttributeValue - [12..12)::0 + CSharpExpressionLiteral - [12..12)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTagHelperAttribute - [12..20)::8 - name - SingleQuotes - Bound - [ name=''] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..17)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [19..19)::0 + MarkupTextLiteral - [19..19)::0 - [] + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [20..21)::1 + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.tspans.txt new file mode 100644 index 0000000000..17b38715bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.cspans.txt new file mode 100644 index 0000000000..ecee8c7015 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.cspans.txt @@ -0,0 +1,2 @@ +Code span at (12:0,12 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (19:0,19 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.diag.txt new file mode 100644 index 0000000000..c11ff99be0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.stree.txt new file mode 100644 index 0000000000..c05ed296bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..25)::25 - [] + MarkupBlock - [0..25)::25 + MarkupTagHelperElement - [0..25)::25 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..12)::7 - bound - DoubleQuotes - Bound - [ bound=] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTagHelperAttributeValue - [12..12)::0 + CSharpExpressionLiteral - [12..12)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTagHelperAttribute - [12..22)::10 - name - SingleQuotes - Bound - [ name=' '] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..17)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [19..21)::2 + MarkupTextLiteral - [19..21)::2 - [ ] + Whitespace;[ ]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [22..23)::1 + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.tspans.txt new file mode 100644 index 0000000000..002029ae1e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.cspans.txt new file mode 100644 index 0000000000..9e481866b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.cspans.txt @@ -0,0 +1,4 @@ +Code span at (13:0,13 [4] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [46] ) +Markup span at (25:0,25 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [46] ) +Code span at (37:0,37 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [46] ) +Markup span at (43:0,43 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.diag.txt new file mode 100644 index 0000000000..356a13e234 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.diag.txt @@ -0,0 +1 @@ +(1,32): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.stree.txt new file mode 100644 index 0000000000..a09c2c8a6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..46)::46 - [] + MarkupBlock - [0..46)::46 + MarkupTagHelperElement - [0..46)::46 - myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..46)::46 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[myth]; + MarkupTagHelperAttribute - [5..18)::13 - bound - SingleQuotes - Bound - [ bound='true'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [13..17)::4 + CSharpExpressionLiteral - [13..17)::4 - [true] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[true]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [18..30)::12 - name - SingleQuotes - Bound - [ name='john'] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..23)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [25..29)::4 + MarkupTextLiteral - [25..29)::4 - [john] - Gen - SpanEditHandler;Accepts:Any + Text;[john]; + MarkupTextLiteral - [29..30)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [30..37)::7 - bound - DoubleQuotes - Bound - [ bound=] + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [31..36)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTagHelperAttributeValue - [37..37)::0 + CSharpExpressionLiteral - [37..37)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTagHelperAttribute - [37..43)::6 - name - DoubleQuotes - Bound - [ name=] + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [38..42)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTagHelperAttributeValue - [43..43)::0 + MarkupTextLiteral - [43..43)::0 - [] + MarkupMiscAttributeContent - [43..44)::1 + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.tspans.txt new file mode 100644 index 0000000000..f578bb25fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForEmptyTagHelperBoundAttributes9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [46] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.stree.txt new file mode 100644 index 0000000000..0f370fff09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.stree.txt @@ -0,0 +1,7 @@ +RazorDocument - [0..2)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.tspans.txt new file mode 100644 index 0000000000..d9746775d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [2] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.diag.txt new file mode 100644 index 0000000000..256c57cb9c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ1035: Missing close angle for tag helper 'p'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.stree.txt new file mode 100644 index 0000000000..950d7f704e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..6)::6 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [3..6)::3 - []; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.tspans.txt new file mode 100644 index 0000000000..aae2c81a5e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [6] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.diag.txt new file mode 100644 index 0000000000..581b6ea348 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,5): Error RZ1035: Missing close angle for tag helper 'strong'. +(1,5): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.stree.txt new file mode 100644 index 0000000000..f4aaf2a54f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..10)::10 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..10)::7 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [3..10)::7 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.tspans.txt new file mode 100644 index 0000000000..07be06becb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [10] ) - ptaghelper +TagHelper span at (3:0,3 [7] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.diag.txt new file mode 100644 index 0000000000..e846c7e408 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'strong'. +(1,2): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,10): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.stree.txt new file mode 100644 index 0000000000..ac5ad19b0f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..11)::11 - [] + MarkupBlock - [0..11)::11 + MarkupTagHelperElement - [0..11)::11 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [0..8)::8 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupMiscAttributeContent - [7..8)::1 + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTagHelperElement - [8..11)::3 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [8..11)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.tspans.txt new file mode 100644 index 0000000000..46d677fdef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [11] ) - strongtaghelper +TagHelper span at (8:0,8 [3] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.diag.txt new file mode 100644 index 0000000000..83865622a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'strong'. +(1,11): Error RZ1035: Missing close angle for tag helper 'strong'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.stree.txt new file mode 100644 index 0000000000..cd7a0e4705 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.stree.txt @@ -0,0 +1,15 @@ +RazorDocument - [0..16)::16 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupMiscAttributeContent - [7..8)::1 + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTagHelperEndTag - [8..16)::8 - []; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.tspans.txt new file mode 100644 index 0000000000..fd2821234a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [16] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.cspans.txt new file mode 100644 index 0000000000..17f87ed7c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) +Markup span at (1:0,1 [1] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [1] ) +Markup span at (2:0,2 [9] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [9] ) +Markup span at (11:0,11 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.diag.txt new file mode 100644 index 0000000000..7317861d0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.diag.txt @@ -0,0 +1,2 @@ +(1,5): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,15): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.stree.txt new file mode 100644 index 0000000000..a62747a393 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..16)::16 - [<< <

                        ] + MarkupBlock - [0..16)::16 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupElement - [1..2)::1 + MarkupStartTag - [1..2)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupElement - [2..11)::9 + MarkupEndTag - [2..11)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupElement - [12..13)::1 + MarkupStartTag - [12..13)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [13..16)::3 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [13..16)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.tspans.txt new file mode 100644 index 0000000000..ad070562db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (13:0,13 [3] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.cspans.txt new file mode 100644 index 0000000000..abec4f6747 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) +Markup span at (1:0,1 [1] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [1] ) +Markup span at (10:0,10 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [14] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [1] ) +Markup span at (13:0,13 [2] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [2] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.diag.txt new file mode 100644 index 0000000000..299623f22a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.stree.txt new file mode 100644 index 0000000000..df48745607 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..16)::16 - [<<> <<>>] + MarkupBlock - [0..16)::16 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupElement - [1..2)::1 + MarkupStartTag - [1..2)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [2..16)::14 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [10..12)::2 - [> ] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; + Whitespace;[ ]; + MarkupElement - [12..13)::1 + MarkupStartTag - [12..13)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupElement - [13..16)::3 + MarkupStartTag - [13..15)::2 - [<>] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[>]; + MarkupTextLiteral - [15..16)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.tspans.txt new file mode 100644 index 0000000000..9bcd022232 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [14] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.cspans.txt new file mode 100644 index 0000000000..81f3b86186 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (12:0,12 [4] ) (Accepts:Any) - Parent: Tag block at (12:0,12 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.diag.txt new file mode 100644 index 0000000000..fbfae8923a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.diag.txt @@ -0,0 +1 @@ +(1,15): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.stree.txt new file mode 100644 index 0000000000..99965ff2a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..25)::25 - [

                        ] + MarkupBlock - [0..25)::25 + MarkupElement - [0..25)::25 + MarkupStartTag - [0..4)::4 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[str]; + CloseAngle;[]; + MarkupTagHelperElement - [4..25)::21 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [4..12)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [12..16)::4 + MarkupEndTag - [12..16)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [16..25)::9 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.tspans.txt new file mode 100644 index 0000000000..e87eb3d4c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelper8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (4:0,4 [21] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.cspans.txt new file mode 100644 index 0000000000..480329cced --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [10] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.stree.txt new file mode 100644 index 0000000000..30883a8889 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..10)::10 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..10)::8 - class - SingleQuotes - Unbound - [ class='] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..10)::0 + MarkupTextLiteral - [10..10)::0 - [] + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.tspans.txt new file mode 100644 index 0000000000..07a0d173f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [10] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.cspans.txt new file mode 100644 index 0000000000..952bb29824 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.cspans.txt @@ -0,0 +1 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.diag.txt new file mode 100644 index 0000000000..00e5e03e70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,13): Error RZ1030: TagHelper attributes must be well-formed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.stree.txt new file mode 100644 index 0000000000..d087307908 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..31)::31 - [

                        ] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..31)::31 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=btn] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [btn] + MarkupTextLiteral - [9..12)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupMiscAttributeContent - [12..31)::19 + MarkupTextLiteral - [12..31)::19 - [" bar="foo"] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + Whitespace;[ ]; + Text;[bar]; + Equals;[=]; + DoubleQuote;["]; + Text;[foo]; + DoubleQuote;["]; + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.tspans.txt new file mode 100644 index 0000000000..b3437d8dea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.cspans.txt new file mode 100644 index 0000000000..b04797cd78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [8] ) +Markup span at (13:0,13 [5] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.diag.txt new file mode 100644 index 0000000000..c263af5dea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,25): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.stree.txt new file mode 100644 index 0000000000..41740648ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..31)::31 - [

                        ] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..23)::23 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..19)::17 - class - DoubleQuotes - Unbound - [ class="btn bar="] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..18)::8 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupLiteralAttributeValue - [13..18)::5 - [ bar=] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..18)::4 - [bar=] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMinimizedTagHelperAttribute - [19..23)::4 - foo" - Minimized - Unbound - [foo"] + MarkupTextLiteral - [19..23)::4 - [foo"] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + DoubleQuote;["]; + CloseAngle;[]; + MarkupTagHelperElement - [23..31)::8 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [23..31)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.tspans.txt new file mode 100644 index 0000000000..2eb4f3edd5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes11.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [31] ) - ptaghelper +TagHelper span at (23:0,23 [8] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.cspans.txt new file mode 100644 index 0000000000..b04797cd78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [8] ) +Markup span at (13:0,13 [5] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.stree.txt new file mode 100644 index 0000000000..86673ee967 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..28)::28 - [

                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..24)::24 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..19)::17 - class - DoubleQuotes - Unbound - [ class="btn bar="] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..18)::8 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupLiteralAttributeValue - [13..18)::5 - [ bar=] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..18)::4 - [bar=] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMinimizedTagHelperAttribute - [19..23)::4 - foo" - Minimized - Unbound - [foo"] + MarkupTextLiteral - [19..23)::4 - [foo"] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.tspans.txt new file mode 100644 index 0000000000..1490ae8ef2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.diag.txt new file mode 100644 index 0000000000..3191132e51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1031: The tag helper 'p' must not have C# in the element's attribute declaration area. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.stree.txt new file mode 100644 index 0000000000..b370e9b162 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..33)::33 - [

                        ] + MarkupBlock - [0..33)::33 + MarkupTagHelperElement - [0..33)::33 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..29)::29 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [2..28)::26 + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [3..16)::13 + CSharpImplicitExpression - [3..16)::13 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [4..16)::12 + CSharpCodeBlock - [4..16)::12 + CSharpExpressionLiteral - [4..16)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [16..28)::12 - [ class="btn"] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[class]; + Equals;[=]; + DoubleQuote;["]; + Text;[btn]; + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [29..33)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.tspans.txt new file mode 100644 index 0000000000..d6131fed67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes13.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [33] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.diag.txt new file mode 100644 index 0000000000..3191132e51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1031: The tag helper 'p' must not have C# in the element's attribute declaration area. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.stree.txt new file mode 100644 index 0000000000..b568d50ba3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..27)::27 - [

                        ] + MarkupBlock - [0..27)::27 + MarkupTagHelperElement - [0..27)::27 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..23)::23 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [2..22)::20 + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [3..16)::13 + CSharpImplicitExpression - [3..16)::13 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [4..16)::12 + CSharpCodeBlock - [4..16)::12 + CSharpExpressionLiteral - [4..16)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [16..22)::6 - [="btn"] - Gen - SpanEditHandler;Accepts:Any + Equals;[=]; + DoubleQuote;["]; + Text;[btn]; + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [23..27)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.tspans.txt new file mode 100644 index 0000000000..840d8db41a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes14.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [27] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.cspans.txt new file mode 100644 index 0000000000..e109b92089 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (9:0,9 [13] ) +Code span at (10:0,10 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (9:0,9 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.diag.txt new file mode 100644 index 0000000000..4a81a68e60 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,23): Error RZ1030: TagHelper attributes must be well-formed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.stree.txt new file mode 100644 index 0000000000..74f35b2278 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..28)::28 - [

                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..28)::28 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..22)::20 - class - DoubleQuotes - Unbound - [ class=@DateTime.Now] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..22)::13 + MarkupDynamicAttributeValue - [9..22)::13 - [@DateTime.Now] + GenericBlock - [9..22)::13 + CSharpCodeBlock - [9..22)::13 + CSharpImplicitExpression - [9..22)::13 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [10..22)::12 + CSharpCodeBlock - [10..22)::12 + CSharpExpressionLiteral - [10..22)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupMiscAttributeContent - [22..28)::6 + MarkupTextLiteral - [22..28)::6 - [">

                        ] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.tspans.txt new file mode 100644 index 0000000000..1490ae8ef2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes15.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.cspans.txt new file mode 100644 index 0000000000..30a40eab2d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (10:0,10 [5] ) +Code span at (11:0,11 [4] ) (Accepts:Any) - Parent: Statement block at (10:0,10 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.diag.txt new file mode 100644 index 0000000000..719d1c8841 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,12): Error RZ1006: The do block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.stree.txt new file mode 100644 index 0000000000..4c1d57ee6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..15)::15 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..15)::13 - class - DoubleQuotes - Unbound - [ class="@do {] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..15)::5 + MarkupDynamicAttributeValue - [10..15)::5 - [@do {] + GenericBlock - [10..15)::5 + CSharpCodeBlock - [10..15)::5 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [11..15)::4 - [do {] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.tspans.txt new file mode 100644 index 0000000000..ad9585903c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes16.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [15] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.cspans.txt new file mode 100644 index 0000000000..cef5455740 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (10:0,10 [11] ) +Code span at (11:0,11 [10] ) (Accepts:Any) - Parent: Statement block at (10:0,10 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.diag.txt new file mode 100644 index 0000000000..c9cee88e75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.diag.txt @@ -0,0 +1,4 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,12): Error RZ1006: The do block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,16): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.stree.txt new file mode 100644 index 0000000000..9b5e377ceb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..21)::21 - [

                        ] + MarkupBlock - [0..21)::21 + MarkupTagHelperElement - [0..21)::21 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..21)::21 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..21)::19 - class - DoubleQuotes - Unbound - [ class="@do {">

                        ] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..21)::11 + MarkupDynamicAttributeValue - [10..21)::11 - [@do {">

                        ] + GenericBlock - [10..21)::11 + CSharpCodeBlock - [10..21)::11 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [11..21)::10 - [do {">

                        ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + StringLiteral;[">

                        ];RZ1000(15:0,15 [1] ) + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.tspans.txt new file mode 100644 index 0000000000..452a7da46c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes17.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [21] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.diag.txt new file mode 100644 index 0000000000..6451ce6e4b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.diag.txt @@ -0,0 +1,5 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,4): Error RZ1031: The tag helper 'p' must not have C# in the element's attribute declaration area. +(1,5): Error RZ1006: The do block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,32): Error RZ1026: Encountered end tag "p" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.stree.txt new file mode 100644 index 0000000000..7f6210c500 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..33)::33 - [

                        ] + MarkupBlock - [0..33)::33 + MarkupTagHelperElement - [0..33)::33 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..33)::33 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [2..33)::31 + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [3..33)::30 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [4..29)::25 - [do { someattribute="btn">] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[someattribute]; + Assign;[=]; + StringLiteral;["btn"]; + GreaterThan;[>]; + MarkupBlock - [29..33)::4 + MarkupElement - [29..33)::4 + MarkupEndTag - [29..33)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.tspans.txt new file mode 100644 index 0000000000..d6131fed67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes18.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [33] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.cspans.txt new file mode 100644 index 0000000000..b992258ac2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.cspans.txt @@ -0,0 +1 @@ +Markup span at (9:0,9 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.diag.txt new file mode 100644 index 0000000000..f716761d50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.diag.txt @@ -0,0 +1 @@ +(1,14): Error RZ1030: TagHelper attributes must be well-formed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.stree.txt new file mode 100644 index 0000000000..9c170c6493 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..38)::38 - [

                        ] + MarkupBlock - [0..38)::38 + MarkupTagHelperElement - [0..38)::38 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..34)::34 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..13)::11 - class - DoubleQuotes - Unbound - [ class=some] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..13)::4 + MarkupLiteralAttributeValue - [9..13)::4 - [some] + MarkupTextLiteral - [9..13)::4 - [some] - Gen - SpanEditHandler;Accepts:Any + Text;[some]; + MarkupMiscAttributeContent - [13..33)::20 + MarkupTextLiteral - [13..26)::13 - [=thing attr="] - Gen - SpanEditHandler;Accepts:Any + Equals;[=]; + Text;[thing]; + Whitespace;[ ]; + Text;[attr]; + Equals;[=]; + DoubleQuote;["]; + CSharpCodeBlock - [26..32)::6 + CSharpImplicitExpression - [26..32)::6 + CSharpTransition - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [27..32)::5 + CSharpCodeBlock - [27..32)::5 + CSharpExpressionLiteral - [27..32)::5 - [value] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[value]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [34..38)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.tspans.txt new file mode 100644 index 0000000000..3cc3264682 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes19.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [38] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.cspans.txt new file mode 100644 index 0000000000..14a88d65c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.cspans.txt @@ -0,0 +1 @@ +Markup span at (8:0,8 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.diag.txt new file mode 100644 index 0000000000..8cd66cdd6c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,15): Error RZ1030: TagHelper attributes must be well-formed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.stree.txt new file mode 100644 index 0000000000..8112c96e24 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..24)::24 - [

                        ] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..24)::24 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..24)::24 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - bar - DoubleQuotes - Unbound - [ bar="false"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [7..8)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [8..13)::5 + MarkupLiteralAttributeValue - [8..13)::5 - [false] + MarkupTextLiteral - [8..13)::5 - [false] - Gen - SpanEditHandler;Accepts:Any + Text;[false]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [14..24)::10 + MarkupTextLiteral - [14..24)::10 - [" ] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + Whitespace;[ ]; + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.tspans.txt new file mode 100644 index 0000000000..4292815e00 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [24] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.cspans.txt new file mode 100644 index 0000000000..4934c61fc0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.cspans.txt @@ -0,0 +1,11 @@ +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (9:0,9 [34] ) +Code span at (10:0,10 [10] ) (Accepts:Any) - Parent: Statement block at (9:0,9 [34] ) +Markup span at (20:0,20 [2] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [15] ) +Markup span at (22:0,22 [7] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [12] ) +Transition span at (29:0,29 [1] ) (Accepts:None) - Parent: Expression block at (29:0,29 [4] ) +Code span at (30:0,30 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (29:0,29 [4] ) +Markup span at (33:0,33 [1] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [12] ) +Markup span at (34:0,34 [1] ) (Accepts:None) - Parent: Tag block at (20:0,20 [15] ) +Markup span at (35:0,35 [4] ) (Accepts:Any) - Parent: Markup block at (20:0,20 [23] ) +Markup span at (39:0,39 [4] ) (Accepts:None) - Parent: Tag block at (39:0,39 [4] ) +Code span at (43:0,43 [0] ) (Accepts:Any) - Parent: Statement block at (9:0,9 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt new file mode 100644 index 0000000000..bfae619d1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,21): Error RZ1008: Single-statement control-flow statements in Razor documents statements cannot contain markup. Markup should be enclosed in "{" and "}". diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.stree.txt new file mode 100644 index 0000000000..bd4efb84e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.stree.txt @@ -0,0 +1,67 @@ +RazorDocument - [0..43)::43 - [

                        ] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..43)::43 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..43)::41 - attr - DoubleQuotes - Unbound - [ attr="@if (true)

                        }">

                        ] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..7)::4 - [attr] - Gen - SpanEditHandler;Accepts:Any + Text;[attr]; + Equals;[=]; + MarkupTextLiteral - [8..9)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [9..43)::34 + MarkupDynamicAttributeValue - [9..43)::34 - [@if (true)

                        }">

                        ] + GenericBlock - [9..43)::34 + CSharpCodeBlock - [9..43)::34 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [10..20)::10 - [if (true) ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[if]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Keyword;[true]; + RightParenthesis;[)]; + Whitespace;[ ]; + MarkupBlock - [20..43)::23 + MarkupElement - [20..43)::23 + MarkupStartTag - [20..35)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupAttributeBlock - [22..34)::12 - [ attr='@foo'] + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [23..27)::4 - [attr] - Gen - SpanEditHandler;Accepts:Any + Text;[attr]; + Equals;[=]; + MarkupTextLiteral - [28..29)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [29..33)::4 + MarkupDynamicAttributeValue - [29..33)::4 - [@foo] + GenericBlock - [29..33)::4 + CSharpCodeBlock - [29..33)::4 + CSharpImplicitExpression - [29..33)::4 + CSharpTransition - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [30..33)::3 + CSharpCodeBlock - [30..33)::3 + CSharpExpressionLiteral - [30..33)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [33..34)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [35..39)::4 - [ }">] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[}]; + DoubleQuote;["]; + CloseAngle;[>]; + MarkupEndTag - [39..43)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.tspans.txt new file mode 100644 index 0000000000..2dbca568cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes20.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.cspans.txt new file mode 100644 index 0000000000..5c5c8a05bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (8:0,8 [5] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [15] ) +Markup span at (13:0,13 [10] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [15] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.stree.txt new file mode 100644 index 0000000000..bffeb23151 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..23)::23 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..23)::21 - bar - SingleQuotes - Unbound - [ bar='false ] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [7..8)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [8..23)::15 + MarkupLiteralAttributeValue - [8..13)::5 - [false] + MarkupTextLiteral - [8..13)::5 - [false] - Gen - SpanEditHandler;Accepts:Any + Text;[false]; + MarkupLiteralAttributeValue - [13..23)::10 - [ ] + MarkupTextLiteral - [13..15)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.tspans.txt new file mode 100644 index 0000000000..72fccbbfdc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.cspans.txt new file mode 100644 index 0000000000..9747a806f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (8:0,8 [5] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [14] ) +Markup span at (13:0,13 [9] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.stree.txt new file mode 100644 index 0000000000..97f1a6c37d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..23)::23 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..23)::21 - bar - SingleQuotes - Unbound - [ bar='false - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [7..8)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [8..22)::14 + MarkupLiteralAttributeValue - [8..13)::5 - [false] + MarkupTextLiteral - [8..13)::5 - [false] - Gen - SpanEditHandler;Accepts:Any + Text;[false]; + MarkupLiteralAttributeValue - [13..22)::9 - [ - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..22)::7 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.tspans.txt new file mode 100644 index 0000000000..72fccbbfdc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.cspans.txt new file mode 100644 index 0000000000..8a404a053c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.cspans.txt @@ -0,0 +1 @@ +Markup span at (7:0,7 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.diag.txt new file mode 100644 index 0000000000..00e5e03e70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,13): Error RZ1030: TagHelper attributes must be well-formed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.stree.txt new file mode 100644 index 0000000000..34c09fd634 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..13)::13 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - bar - DoubleQuotes - Unbound - [ bar=false] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTagHelperAttributeValue - [7..12)::5 + MarkupLiteralAttributeValue - [7..12)::5 - [false] + MarkupTextLiteral - [7..12)::5 - [false] - Gen - SpanEditHandler;Accepts:Any + Text;[false]; + MarkupMiscAttributeContent - [12..13)::1 + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.tspans.txt new file mode 100644 index 0000000000..17a2d8cf26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [13] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.cspans.txt new file mode 100644 index 0000000000..948bed3775 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.cspans.txt @@ -0,0 +1 @@ +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.stree.txt new file mode 100644 index 0000000000..7a60f595a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..14)::14 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - bar - DoubleQuotes - Unbound - [ bar="false'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [7..8)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [8..14)::6 + MarkupLiteralAttributeValue - [8..14)::6 - [false'] + MarkupTextLiteral - [8..14)::6 - [false'] - Gen - SpanEditHandler;Accepts:Any + Text;[false]; + SingleQuote;[']; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.tspans.txt new file mode 100644 index 0000000000..d4769a773a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [14] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.cspans.txt new file mode 100644 index 0000000000..ea7a88a5bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (14:0,14 [6] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.stree.txt new file mode 100644 index 0000000000..d5351a5631 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..20)::20 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..20)::18 - bar - DoubleQuotes - Unbound - [ bar="false' >

                        ] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + Equals;[=]; + MarkupTextLiteral - [7..8)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [8..20)::12 + MarkupLiteralAttributeValue - [8..14)::6 - [false'] + MarkupTextLiteral - [8..14)::6 - [false'] - Gen - SpanEditHandler;Accepts:Any + Text;[false]; + SingleQuote;[']; + MarkupLiteralAttributeValue - [14..20)::6 - [ >

                        ] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..20)::5 - [>

                        ] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.tspans.txt new file mode 100644 index 0000000000..66adb496db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [20] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.diag.txt new file mode 100644 index 0000000000..2bc23b0f86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,12): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.stree.txt new file mode 100644 index 0000000000..d76bdc3899 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..18)::18 - [

                        ] + MarkupBlock - [0..18)::18 + MarkupTagHelperElement - [0..18)::18 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..10)::10 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..6)::4 - foo - Minimized - Unbound - [ foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..6)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupMinimizedTagHelperAttribute - [6..10)::4 - bar - Minimized - Unbound - [ bar] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..10)::3 - [bar] - Gen - SpanEditHandler;Accepts:Any + Text;[bar]; + CloseAngle;[]; + MarkupTagHelperElement - [10..18)::8 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [10..18)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.tspans.txt new file mode 100644 index 0000000000..cc7354bc19 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes8.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [18] ) - ptaghelper +TagHelper span at (10:0,10 [8] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.cspans.txt new file mode 100644 index 0000000000..ccaa1b3f13 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.cspans.txt @@ -0,0 +1 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.diag.txt new file mode 100644 index 0000000000..00e5e03e70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,13): Error RZ1030: TagHelper attributes must be well-formed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.stree.txt new file mode 100644 index 0000000000..2e609ba6aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..25)::25 - [

                        ] + MarkupBlock - [0..25)::25 + MarkupTagHelperElement - [0..25)::25 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..25)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=btn] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [btn] + MarkupTextLiteral - [9..12)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupMiscAttributeContent - [12..25)::13 + MarkupTextLiteral - [12..25)::13 - [" bar] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + Whitespace;[ ]; + Text;[bar]; + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.tspans.txt new file mode 100644 index 0000000000..b9ccfbed4b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesErrorForMalformedTagHelpersWithAttributes9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.cspans.txt new file mode 100644 index 0000000000..7c9bbe1aa9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.cspans.txt @@ -0,0 +1 @@ +Code span at (13:0,13 [2] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.stree.txt new file mode 100644 index 0000000000..1afdbe7e75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..19)::19 - [] + MarkupBlock - [0..19)::19 + MarkupTagHelperElement - [0..19)::19 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..19)::19 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..16)::9 - age - DoubleQuotes - Bound - [ age="12"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..15)::2 + CSharpExpressionLiteral - [13..15)::2 - [12] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[12]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.tspans.txt new file mode 100644 index 0000000000..096b786f52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [19] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.cspans.txt new file mode 100644 index 0000000000..93c1eb44f3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.cspans.txt @@ -0,0 +1,5 @@ +Code span at (13:0,13 [2] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [73] ) +Code span at (27:0,27 [12] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [73] ) +Markup span at (47:0,47 [1] ) (Accepts:None) - Parent: Markup block at (47:0,47 [2] ) +Markup span at (48:0,48 [1] ) (Accepts:None) - Parent: Markup block at (47:0,47 [2] ) +Markup span at (49:0,49 [20] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.stree.txt new file mode 100644 index 0000000000..dbc9614a21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..73)::73 - [] + MarkupBlock - [0..73)::73 + MarkupTagHelperElement - [0..73)::73 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..73)::73 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..16)::9 - age - DoubleQuotes - Bound - [ age="12"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..15)::2 + CSharpExpressionLiteral - [13..15)::2 - [12] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[12]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [16..40)::24 - birthday - DoubleQuotes - Bound - [ birthday="DateTime.Now"] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..25)::8 - [birthday] - Gen - SpanEditHandler;Accepts:Any + Text;[birthday]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..39)::12 + CSharpExpressionLiteral - [27..39)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[DateTime.Now]; + MarkupTextLiteral - [39..40)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [40..70)::30 - name - DoubleQuotes - Bound - [ name="@@BoundStringAttribute"] + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [41..45)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [46..47)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [47..69)::22 + MarkupBlock - [47..49)::2 + MarkupTextLiteral - [47..48)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [48..49)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupTextLiteral - [49..69)::20 - [BoundStringAttribute] - Gen - SpanEditHandler;Accepts:Any + Text;[BoundStringAttribute]; + MarkupTextLiteral - [69..70)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [70..71)::1 + MarkupTextLiteral - [70..71)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.tspans.txt new file mode 100644 index 0000000000..66b66f6b27 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [73] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.cspans.txt new file mode 100644 index 0000000000..7d194474a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.cspans.txt @@ -0,0 +1,12 @@ +Code span at (13:0,13 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [2] ) +Code span at (14:0,14 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [2] ) +Code span at (15:0,15 [0] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (15:0,15 [7] ) +Code span at (15:0,15 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (15:0,15 [7] ) +Code span at (16:0,16 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (15:0,15 [7] ) +Code span at (17:0,17 [4] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (15:0,15 [7] ) +Code span at (21:0,21 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (15:0,15 [7] ) +Code span at (34:0,34 [12] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [77] ) +Markup span at (54:0,54 [5] ) (Accepts:Any) - Parent: Markup block at (54:0,54 [19] ) +Markup span at (59:0,59 [1] ) (Accepts:Any) - Parent: Markup block at (59:0,59 [14] ) +Transition span at (60:0,60 [1] ) (Accepts:None) - Parent: Expression block at (60:0,60 [13] ) +Code span at (61:0,61 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (60:0,60 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.stree.txt new file mode 100644 index 0000000000..b4d98fbb97 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.stree.txt @@ -0,0 +1,85 @@ +RazorDocument - [0..77)::77 - [] + MarkupBlock - [0..77)::77 + MarkupTagHelperElement - [0..77)::77 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..77)::77 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..23)::16 - age - DoubleQuotes - Bound - [ age="@@@(11+1)"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..22)::9 + MarkupBlock - [13..15)::2 + CSharpExpressionLiteral - [13..14)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpEphemeralTextLiteral - [14..15)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + MarkupBlock - [15..22)::7 + CSharpExpressionLiteral - [15..15)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Marker;[]; + CSharpCodeBlock - [15..22)::7 + CSharpImplicitExpression - [15..22)::7 + CSharpTransition - [15..15)::0 + Transition;[]; + CSharpImplicitExpressionBody - [15..22)::7 + CSharpCodeBlock - [15..22)::7 + CSharpExpressionLiteral - [15..16)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [16..17)::1 - [(] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + LeftParenthesis;[(]; + CSharpExpressionLiteral - [17..21)::4 - [11+1] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + IntegerLiteral;[11]; + Plus;[+]; + IntegerLiteral;[1]; + CSharpExpressionLiteral - [21..22)::1 - [)] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + RightParenthesis;[)]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [23..47)::24 - birthday - DoubleQuotes - Bound - [ birthday="DateTime.Now"] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..32)::8 - [birthday] - Gen - SpanEditHandler;Accepts:Any + Text;[birthday]; + Equals;[=]; + MarkupTextLiteral - [33..34)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [34..46)::12 + CSharpExpressionLiteral - [34..46)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[DateTime.Now]; + MarkupTextLiteral - [46..47)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [47..74)::27 - name - DoubleQuotes - Bound - [ name="Time: @DateTime.Now"] + MarkupTextLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [48..52)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [53..54)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [54..73)::19 + MarkupTextLiteral - [54..59)::5 - [Time:] - Gen - SpanEditHandler;Accepts:Any + Text;[Time:]; + MarkupBlock - [59..73)::14 + MarkupTextLiteral - [59..60)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [60..73)::13 + CSharpImplicitExpression - [60..73)::13 + CSharpTransition - [60..61)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [61..73)::12 + CSharpCodeBlock - [61..73)::12 + CSharpExpressionLiteral - [61..73)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [73..74)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [74..75)::1 + MarkupTextLiteral - [74..75)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.tspans.txt new file mode 100644 index 0000000000..905f5d687a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [77] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.cspans.txt new file mode 100644 index 0000000000..53bec4dfc2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Statement block at (13:0,13 [22] ) +MetaCode span at (14:0,14 [1] ) (Accepts:None) - Parent: Statement block at (13:0,13 [22] ) +Code span at (15:0,15 [19] ) (Accepts:Any) - Parent: Statement block at (13:0,13 [22] ) +MetaCode span at (34:0,34 [1] ) (Accepts:None) - Parent: Statement block at (13:0,13 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.stree.txt new file mode 100644 index 0000000000..a8c15d092b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..39)::39 - [] + MarkupBlock - [0..39)::39 + MarkupTagHelperElement - [0..39)::39 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..39)::39 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..36)::29 - age - DoubleQuotes - Bound - [ age="@{flag == 0 ? 11 : 12}"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..35)::22 + MarkupBlock - [13..35)::22 + CSharpCodeBlock - [13..35)::22 + CSharpStatement - [13..35)::22 + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [14..35)::21 + RazorMetaCode - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [15..34)::19 + CSharpStatementLiteral - [15..34)::19 - [flag == 0 ? 11 : 12] - Gen - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL + Identifier;[flag]; + Whitespace;[ ]; + Equals;[==]; + Whitespace;[ ]; + IntegerLiteral;[0]; + Whitespace;[ ]; + QuestionMark;[?]; + Whitespace;[ ]; + IntegerLiteral;[11]; + Whitespace;[ ]; + Colon;[:]; + Whitespace;[ ]; + IntegerLiteral;[12]; + RazorMetaCode - [34..35)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [36..37)::1 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.tspans.txt new file mode 100644 index 0000000000..14c5fecb18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [39] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.cspans.txt new file mode 100644 index 0000000000..f743b23285 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.cspans.txt @@ -0,0 +1 @@ +Code span at (18:0,18 [12] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.stree.txt new file mode 100644 index 0000000000..0af2d73896 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..34)::34 - [] + MarkupBlock - [0..34)::34 + MarkupTagHelperElement - [0..34)::34 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..34)::34 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..31)::24 - birthday - DoubleQuotes - Bound - [ birthday="DateTime.Now"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [birthday] - Gen - SpanEditHandler;Accepts:Any + Text;[birthday]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..30)::12 + CSharpExpressionLiteral - [18..30)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[DateTime.Now]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [31..32)::1 + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.tspans.txt new file mode 100644 index 0000000000..f873839265 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [34] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.cspans.txt new file mode 100644 index 0000000000..47295f8488 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (13:0,13 [1] ) (Accepts:None) - Parent: Expression block at (13:0,13 [18] ) +Code span at (14:0,14 [17] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (13:0,13 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.stree.txt new file mode 100644 index 0000000000..517ad1d2d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..35)::35 - [] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..35)::35 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..32)::25 - age - DoubleQuotes - Bound - [ age="@DateTime.Now.Year"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..31)::18 + MarkupBlock - [13..31)::18 + CSharpCodeBlock - [13..31)::18 + CSharpImplicitExpression - [13..31)::18 + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [14..31)::17 + CSharpCodeBlock - [14..31)::17 + CSharpExpressionLiteral - [14..31)::17 - [DateTime.Now.Year] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + Dot;[.]; + Identifier;[Year]; + MarkupTextLiteral - [31..32)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [32..33)::1 + MarkupTextLiteral - [32..33)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.tspans.txt new file mode 100644 index 0000000000..4c67f60b6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.cspans.txt new file mode 100644 index 0000000000..3c2486e3b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.cspans.txt @@ -0,0 +1,3 @@ +Code span at (13:0,13 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [19] ) +Code span at (14:0,14 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (14:0,14 [18] ) +Code span at (15:0,15 [17] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (14:0,14 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.stree.txt new file mode 100644 index 0000000000..5322ea7a7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..36)::36 - [] + MarkupBlock - [0..36)::36 + MarkupTagHelperElement - [0..36)::36 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..36)::36 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..33)::26 - age - DoubleQuotes - Bound - [ age=" @DateTime.Now.Year"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..32)::19 + MarkupBlock - [13..32)::19 + CSharpExpressionLiteral - [13..14)::1 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + CSharpCodeBlock - [14..32)::18 + CSharpImplicitExpression - [14..32)::18 + CSharpTransition - [14..14)::0 + Transition;[]; + CSharpImplicitExpressionBody - [14..32)::18 + CSharpCodeBlock - [14..32)::18 + CSharpExpressionLiteral - [14..15)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [15..32)::17 - [DateTime.Now.Year] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + Dot;[.]; + Identifier;[Year]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [33..34)::1 + MarkupTextLiteral - [33..34)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.tspans.txt new file mode 100644 index 0000000000..232251afb7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [36] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.cspans.txt new file mode 100644 index 0000000000..7dadb4349b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.cspans.txt @@ -0,0 +1 @@ +Markup span at (14:0,14 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.stree.txt new file mode 100644 index 0000000000..cf0a4ec787 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..22)::22 - [] + MarkupBlock - [0..22)::22 + MarkupTagHelperElement - [0..22)::22 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..19)::12 - name - DoubleQuotes - Bound - [ name="John"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..12)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [14..18)::4 + MarkupTextLiteral - [14..18)::4 - [John] - Gen - SpanEditHandler;Accepts:Any + Text;[John]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.tspans.txt new file mode 100644 index 0000000000..936f7cc167 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [22] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.cspans.txt new file mode 100644 index 0000000000..fff411360a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (14:0,14 [5] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [19] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (19:0,19 [14] ) +Transition span at (20:0,20 [1] ) (Accepts:None) - Parent: Expression block at (20:0,20 [13] ) +Code span at (21:0,21 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (20:0,20 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.stree.txt new file mode 100644 index 0000000000..21e1af2a92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..37)::37 - [] + MarkupBlock - [0..37)::37 + MarkupTagHelperElement - [0..37)::37 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..37)::37 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..34)::27 - name - DoubleQuotes - Bound - [ name="Time: @DateTime.Now"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..12)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [14..33)::19 + MarkupTextLiteral - [14..19)::5 - [Time:] - Gen - SpanEditHandler;Accepts:Any + Text;[Time:]; + MarkupBlock - [19..33)::14 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [20..33)::13 + CSharpImplicitExpression - [20..33)::13 + CSharpTransition - [20..21)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [21..33)::12 + CSharpCodeBlock - [21..33)::12 + CSharpExpressionLiteral - [21..33)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [33..34)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [34..35)::1 + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.tspans.txt new file mode 100644 index 0000000000..c61b8f7089 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [37] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.cspans.txt new file mode 100644 index 0000000000..99741cf638 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.cspans.txt @@ -0,0 +1,18 @@ +Code span at (13:0,13 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] ) +Code span at (14:0,14 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] ) +Code span at (16:0,16 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (16:0,16 [7] ) +Code span at (17:0,17 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [6] ) +Code span at (18:0,18 [5] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [6] ) +Code span at (23:0,23 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] ) +Code span at (25:0,25 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (13:0,13 [14] ) +Code span at (39:0,39 [6] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] ) +Code span at (45:0,45 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (45:0,45 [11] ) +Code span at (46:0,46 [10] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (45:0,45 [11] ) +Code span at (56:0,56 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] ) +Code span at (58:0,58 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (58:0,58 [3] ) +Code span at (60:0,60 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (58:0,58 [3] ) +Code span at (61:0,61 [8] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] ) +Code span at (69:0,69 [2] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (39:0,39 [46] ) +Code span at (71:0,71 [1] ) (Accepts:AnyExceptNewline) - Parent: Markup block at (71:0,71 [14] ) +Code span at (72:0,72 [1] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (72:0,72 [13] ) +Code span at (73:0,73 [12] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (72:0,72 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.stree.txt new file mode 100644 index 0000000000..9d01bdafaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.stree.txt @@ -0,0 +1,99 @@ +RazorDocument - [0..88)::88 - [] + MarkupBlock - [0..88)::88 + MarkupTagHelperElement - [0..88)::88 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..88)::88 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..28)::21 - age - DoubleQuotes - Bound - [ age="1 + @value + 2"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..27)::14 + CSharpExpressionLiteral - [13..14)::1 - [1] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[1]; + CSharpExpressionLiteral - [14..16)::2 - [ +] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + Text;[+]; + MarkupBlock - [16..23)::7 + CSharpExpressionLiteral - [16..17)::1 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + CSharpCodeBlock - [17..23)::6 + CSharpImplicitExpression - [17..23)::6 + CSharpTransition - [17..17)::0 + Transition;[]; + CSharpImplicitExpressionBody - [17..23)::6 + CSharpCodeBlock - [17..23)::6 + CSharpExpressionLiteral - [17..18)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [18..23)::5 - [value] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Identifier;[value]; + CSharpExpressionLiteral - [23..25)::2 - [ +] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + Text;[+]; + CSharpExpressionLiteral - [25..27)::2 - [ 2] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + Text;[2]; + MarkupTextLiteral - [27..28)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [28..86)::58 - birthday - SingleQuotes - Bound - [ birthday='(bool)@Bag["val"] ? @@DateTime : @DateTime.Now'] + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [29..37)::8 - [birthday] - Gen - SpanEditHandler;Accepts:Any + Text;[birthday]; + Equals;[=]; + MarkupTextLiteral - [38..39)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [39..85)::46 + CSharpExpressionLiteral - [39..45)::6 - [(bool)] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[(bool)]; + MarkupBlock - [45..56)::11 + CSharpCodeBlock - [45..56)::11 + CSharpImplicitExpression - [45..56)::11 + CSharpTransition - [45..45)::0 + Transition;[]; + CSharpImplicitExpressionBody - [45..56)::11 + CSharpCodeBlock - [45..56)::11 + CSharpExpressionLiteral - [45..46)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [46..56)::10 - [Bag["val"]] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Identifier;[Bag]; + LeftBracket;[[]; + StringLiteral;["val"]; + RightBracket;[]]; + CSharpExpressionLiteral - [56..58)::2 - [ ?] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + QuestionMark;[?]; + MarkupBlock - [58..61)::3 + CSharpExpressionLiteral - [58..60)::2 - [ @] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + Transition;[@]; + CSharpEphemeralTextLiteral - [60..61)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [61..69)::8 - [DateTime] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[DateTime]; + CSharpExpressionLiteral - [69..71)::2 - [ :] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + Text;[:]; + MarkupBlock - [71..85)::14 + CSharpExpressionLiteral - [71..72)::1 - [ ] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Whitespace;[ ]; + CSharpCodeBlock - [72..85)::13 + CSharpImplicitExpression - [72..85)::13 + CSharpTransition - [72..72)::0 + Transition;[]; + CSharpImplicitExpressionBody - [72..85)::13 + CSharpCodeBlock - [72..85)::13 + CSharpExpressionLiteral - [72..73)::1 - [@] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Transition;[@]; + CSharpExpressionLiteral - [73..85)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [85..86)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.tspans.txt new file mode 100644 index 0000000000..9cdbc1f1f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [88] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.cspans.txt new file mode 100644 index 0000000000..14eb11f1cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.cspans.txt @@ -0,0 +1,6 @@ +Code span at (13:0,13 [2] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [70] ) +Code span at (27:0,27 [12] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [70] ) +Markup span at (47:0,47 [5] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [19] ) +Markup span at (52:0,52 [1] ) (Accepts:Any) - Parent: Markup block at (52:0,52 [14] ) +Transition span at (53:0,53 [1] ) (Accepts:None) - Parent: Expression block at (53:0,53 [13] ) +Code span at (54:0,54 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (53:0,53 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.stree.txt new file mode 100644 index 0000000000..9f5cd21e9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.stree.txt @@ -0,0 +1,63 @@ +RazorDocument - [0..70)::70 - [] + MarkupBlock - [0..70)::70 + MarkupTagHelperElement - [0..70)::70 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..70)::70 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..16)::9 - age - DoubleQuotes - Bound - [ age="12"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..15)::2 + CSharpExpressionLiteral - [13..15)::2 - [12] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[12]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [16..40)::24 - birthday - DoubleQuotes - Bound - [ birthday="DateTime.Now"] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..25)::8 - [birthday] - Gen - SpanEditHandler;Accepts:Any + Text;[birthday]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..39)::12 + CSharpExpressionLiteral - [27..39)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[DateTime.Now]; + MarkupTextLiteral - [39..40)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [40..67)::27 - name - DoubleQuotes - Bound - [ name="Time: @DateTime.Now"] + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [41..45)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [46..47)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [47..66)::19 + MarkupTextLiteral - [47..52)::5 - [Time:] - Gen - SpanEditHandler;Accepts:Any + Text;[Time:]; + MarkupBlock - [52..66)::14 + MarkupTextLiteral - [52..53)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [53..66)::13 + CSharpImplicitExpression - [53..66)::13 + CSharpTransition - [53..54)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [54..66)::12 + CSharpCodeBlock - [54..66)::12 + CSharpExpressionLiteral - [54..66)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [66..67)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [67..68)::1 + MarkupTextLiteral - [67..68)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.tspans.txt new file mode 100644 index 0000000000..ccef1ebc65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [70] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.cspans.txt new file mode 100644 index 0000000000..b593b2e5bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.cspans.txt @@ -0,0 +1,8 @@ +Code span at (13:0,13 [2] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [73] ) +Code span at (27:0,27 [12] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [73] ) +Markup span at (47:0,47 [5] ) (Accepts:Any) - Parent: Markup block at (47:0,47 [22] ) +Markup span at (52:0,52 [2] ) (Accepts:None) - Parent: Markup block at (52:0,52 [3] ) +Markup span at (54:0,54 [1] ) (Accepts:None) - Parent: Markup block at (52:0,52 [3] ) +Markup span at (55:0,55 [1] ) (Accepts:Any) - Parent: Markup block at (55:0,55 [14] ) +Transition span at (56:0,56 [1] ) (Accepts:None) - Parent: Expression block at (56:0,56 [13] ) +Code span at (57:0,57 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (56:0,56 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.stree.txt new file mode 100644 index 0000000000..5bbee23170 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.stree.txt @@ -0,0 +1,69 @@ +RazorDocument - [0..73)::73 - [] + MarkupBlock - [0..73)::73 + MarkupTagHelperElement - [0..73)::73 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..73)::73 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..16)::9 - age - DoubleQuotes - Bound - [ age="12"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..15)::2 + CSharpExpressionLiteral - [13..15)::2 - [12] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[12]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [16..40)::24 - birthday - DoubleQuotes - Bound - [ birthday="DateTime.Now"] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..25)::8 - [birthday] - Gen - SpanEditHandler;Accepts:Any + Text;[birthday]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..39)::12 + CSharpExpressionLiteral - [27..39)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[DateTime.Now]; + MarkupTextLiteral - [39..40)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [40..70)::30 - name - DoubleQuotes - Bound - [ name="Time: @@ @DateTime.Now"] + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [41..45)::4 - [name] - Gen - SpanEditHandler;Accepts:Any + Text;[name]; + Equals;[=]; + MarkupTextLiteral - [46..47)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [47..69)::22 + MarkupTextLiteral - [47..52)::5 - [Time:] - Gen - SpanEditHandler;Accepts:Any + Text;[Time:]; + MarkupBlock - [52..55)::3 + MarkupTextLiteral - [52..54)::2 - [ @] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Transition;[@]; + MarkupEphemeralTextLiteral - [54..55)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupBlock - [55..69)::14 + MarkupTextLiteral - [55..56)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [56..69)::13 + CSharpImplicitExpression - [56..69)::13 + CSharpTransition - [56..57)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [57..69)::12 + CSharpCodeBlock - [57..69)::12 + CSharpExpressionLiteral - [57..69)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [69..70)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [70..71)::1 + MarkupTextLiteral - [70..71)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.tspans.txt new file mode 100644 index 0000000000..66b66f6b27 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/CreatesMarkupCodeSpansForNonStringTagHelperAttributes9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [73] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.diag.txt new file mode 100644 index 0000000000..39eecf8c70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.diag.txt @@ -0,0 +1,2 @@ +(1,8): Error RZ2008: Attribute 'boundbool' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. +(1,18): Error RZ2008: Attribute 'boundbooldict-key' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.stree.txt new file mode 100644 index 0000000000..116e8180ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..37)::37 - [] + MarkupBlock - [0..37)::37 + MarkupTagHelperElement - [0..37)::37 - input[SelfClosing] - InputTagHelper + MarkupTagHelperStartTag - [0..37)::37 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..16)::10 - boundbool - Minimized - Bound - [ boundbool] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..16)::9 - [boundbool] - Gen - SpanEditHandler;Accepts:Any + Text;[boundbool]; + MarkupMinimizedTagHelperAttribute - [16..34)::18 - boundbooldict-key - Minimized - Bound - [ boundbooldict-key] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..34)::17 - [boundbooldict-key] - Gen - SpanEditHandler;Accepts:Any + Text;[boundbooldict-key]; + MarkupMiscAttributeContent - [34..35)::1 + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.tspans.txt new file mode 100644 index 0000000000..c28ec2a704 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/FeatureDisabled_AddsErrorForMinimizedBooleanBoundAttributes.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [37] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.cspans.txt new file mode 100644 index 0000000000..0391bc3c6c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Expression block at (24:0,24 [13] ) +Code span at (25:0,25 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (24:0,24 [13] ) +Code span at (41:0,41 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (41:0,41 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (42:0,42 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.stree.txt new file mode 100644 index 0000000000..f1241cf3ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..42)::42 - [@{}] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpStatement - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..42)::41 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..41)::39 + MarkupBlock - [2..41)::39 + MarkupTagHelperElement - [2..41)::39 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..41)::39 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..38)::30 - data-required - SingleQuotes - Unbound - [ data-required='@DateTime.Now'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [24..37)::13 + CSharpCodeBlock - [24..37)::13 + CSharpImplicitExpression - [24..37)::13 + CSharpTransition - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [25..37)::12 + CSharpCodeBlock - [25..37)::12 + CSharpExpressionLiteral - [25..37)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [38..39)::1 + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.tspans.txt new file mode 100644 index 0000000000..8c4810da56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [39] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.cspans.txt new file mode 100644 index 0000000000..b97cd38cd0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (24:0,24 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [31] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.stree.txt new file mode 100644 index 0000000000..c6f66a1cf4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..34)::34 - [@{}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupTagHelperElement - [2..33)::31 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..33)::31 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..30)::22 - data-required - SingleQuotes - Unbound - [ data-required='value'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [24..29)::5 + MarkupTextLiteral - [24..29)::5 - [value] - Gen - SpanEditHandler;Accepts:Any + Text;[value]; + MarkupTextLiteral - [29..30)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [30..31)::1 + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.tspans.txt new file mode 100644 index 0000000000..6104535694 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [31] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.cspans.txt new file mode 100644 index 0000000000..b42754acf3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Markup span at (24:0,24 [7] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [20] ) +Transition span at (31:0,31 [1] ) (Accepts:None) - Parent: Expression block at (31:0,31 [13] ) +Code span at (32:0,32 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (31:0,31 [13] ) +Code span at (48:0,48 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) +MetaCode span at (48:0,48 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Markup span at (49:0,49 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.stree.txt new file mode 100644 index 0000000000..917a150b95 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..49)::49 - [@{}] + MarkupBlock - [0..49)::49 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..49)::49 + CSharpStatement - [0..49)::49 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..49)::48 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..48)::46 + MarkupBlock - [2..48)::46 + MarkupTagHelperElement - [2..48)::46 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..48)::46 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..45)::37 - data-required - SingleQuotes - Unbound - [ data-required='prefix @DateTime.Now'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [24..44)::20 + MarkupTextLiteral - [24..31)::7 - [prefix ] - Gen - SpanEditHandler;Accepts:Any + Text;[prefix]; + Whitespace;[ ]; + CSharpCodeBlock - [31..44)::13 + CSharpImplicitExpression - [31..44)::13 + CSharpTransition - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [32..44)::12 + CSharpCodeBlock - [32..44)::12 + CSharpExpressionLiteral - [32..44)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [44..45)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [45..46)::1 + MarkupTextLiteral - [45..46)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [48..48)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [48..49)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [49..49)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.tspans.txt new file mode 100644 index 0000000000..17bc990785 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [46] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.cspans.txt new file mode 100644 index 0000000000..90cbfa0f75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Expression block at (24:0,24 [13] ) +Code span at (25:0,25 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (24:0,24 [13] ) +Markup span at (37:0,37 [7] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [20] ) +Code span at (48:0,48 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [49] ) +MetaCode span at (48:0,48 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [49] ) +Markup span at (49:0,49 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.stree.txt new file mode 100644 index 0000000000..cbfa94a75a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..49)::49 - [@{}] + MarkupBlock - [0..49)::49 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..49)::49 + CSharpStatement - [0..49)::49 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..49)::48 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..48)::46 + MarkupBlock - [2..48)::46 + MarkupTagHelperElement - [2..48)::46 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..48)::46 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..45)::37 - data-required - SingleQuotes - Unbound - [ data-required='@DateTime.Now suffix'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [24..44)::20 + CSharpCodeBlock - [24..37)::13 + CSharpImplicitExpression - [24..37)::13 + CSharpTransition - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [25..37)::12 + CSharpCodeBlock - [25..37)::12 + CSharpExpressionLiteral - [25..37)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [37..44)::7 - [ suffix] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[suffix]; + MarkupTextLiteral - [44..45)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [45..46)::1 + MarkupTextLiteral - [45..46)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [48..48)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [48..49)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [49..49)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.tspans.txt new file mode 100644 index 0000000000..17bc990785 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [46] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.cspans.txt new file mode 100644 index 0000000000..912f6a9910 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Markup span at (24:0,24 [7] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [27] ) +Transition span at (31:0,31 [1] ) (Accepts:None) - Parent: Expression block at (31:0,31 [13] ) +Code span at (32:0,32 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (31:0,31 [13] ) +Markup span at (44:0,44 [7] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [27] ) +Code span at (55:0,55 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [56] ) +MetaCode span at (55:0,55 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [56] ) +Markup span at (56:0,56 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.stree.txt new file mode 100644 index 0000000000..c511a32c13 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..56)::56 - [@{}] + MarkupBlock - [0..56)::56 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..56)::56 + CSharpStatement - [0..56)::56 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..56)::55 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..55)::53 + MarkupBlock - [2..55)::53 + MarkupTagHelperElement - [2..55)::53 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..55)::53 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..52)::44 - data-required - SingleQuotes - Unbound - [ data-required='prefix @DateTime.Now suffix'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [24..51)::27 + MarkupTextLiteral - [24..31)::7 - [prefix ] - Gen - SpanEditHandler;Accepts:Any + Text;[prefix]; + Whitespace;[ ]; + CSharpCodeBlock - [31..44)::13 + CSharpImplicitExpression - [31..44)::13 + CSharpTransition - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [32..44)::12 + CSharpCodeBlock - [32..44)::12 + CSharpExpressionLiteral - [32..44)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [44..51)::7 - [ suffix] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[suffix]; + MarkupTextLiteral - [51..52)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [52..53)::1 + MarkupTextLiteral - [52..53)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [55..55)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [55..56)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [56..56)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.tspans.txt new file mode 100644 index 0000000000..b3c0a3f1b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [53] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.cspans.txt new file mode 100644 index 0000000000..a02a857505 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +Markup span at (38:0,38 [7] ) (Accepts:Any) - Parent: Markup block at (38:0,38 [27] ) +Transition span at (45:0,45 [1] ) (Accepts:None) - Parent: Expression block at (45:0,45 [13] ) +Code span at (46:0,46 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (45:0,45 [13] ) +Markup span at (58:0,58 [7] ) (Accepts:Any) - Parent: Markup block at (38:0,38 [27] ) +Code span at (84:0,84 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [85] ) +MetaCode span at (84:0,84 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [85] ) +Markup span at (85:0,85 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [85] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.stree.txt new file mode 100644 index 0000000000..3233942ef7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..85)::85 - [@{}] + MarkupBlock - [0..85)::85 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..85)::85 + CSharpStatement - [0..85)::85 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..85)::84 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..84)::82 + MarkupBlock - [2..84)::82 + MarkupTagHelperElement - [2..84)::82 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..84)::82 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..22)::14 - pre-attribute - Minimized - Unbound - [ pre-attribute] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [pre-attribute] - Gen - SpanEditHandler;Accepts:Any + Text;[pre-attribute]; + MarkupTagHelperAttribute - [22..66)::44 - data-required - SingleQuotes - Unbound - [ data-required='prefix @DateTime.Now suffix'] + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [23..36)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [38..65)::27 + MarkupTextLiteral - [38..45)::7 - [prefix ] - Gen - SpanEditHandler;Accepts:Any + Text;[prefix]; + Whitespace;[ ]; + CSharpCodeBlock - [45..58)::13 + CSharpImplicitExpression - [45..58)::13 + CSharpTransition - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [46..58)::12 + CSharpCodeBlock - [46..58)::12 + CSharpExpressionLiteral - [46..58)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [58..65)::7 - [ suffix] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[suffix]; + MarkupTextLiteral - [65..66)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [66..81)::15 - post-attribute - Minimized - Unbound - [ post-attribute] + MarkupTextLiteral - [66..67)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [67..81)::14 - [post-attribute] - Gen - SpanEditHandler;Accepts:Any + Text;[post-attribute]; + MarkupMiscAttributeContent - [81..82)::1 + MarkupTextLiteral - [81..82)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [84..84)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [84..85)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [85..85)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.tspans.txt new file mode 100644 index 0000000000..c5d9978610 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [82] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.cspans.txt new file mode 100644 index 0000000000..636e0fa0e0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [63] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [63] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Expression block at (24:0,24 [13] ) +Code span at (25:0,25 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (24:0,24 [13] ) +Markup span at (37:0,37 [8] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [34] ) +Transition span at (45:0,45 [1] ) (Accepts:None) - Parent: Expression block at (45:0,45 [13] ) +Code span at (46:0,46 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (45:0,45 [13] ) +Code span at (62:0,62 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [63] ) +MetaCode span at (62:0,62 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [63] ) +Markup span at (63:0,63 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [63] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.stree.txt new file mode 100644 index 0000000000..f9bd7098d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.stree.txt @@ -0,0 +1,63 @@ +RazorDocument - [0..63)::63 - [@{}] + MarkupBlock - [0..63)::63 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..63)::63 + CSharpStatement - [0..63)::63 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..63)::62 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..62)::60 + MarkupBlock - [2..62)::60 + MarkupTagHelperElement - [2..62)::60 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [2..62)::60 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..59)::51 - data-required - SingleQuotes - Unbound - [ data-required='@DateTime.Now middle @DateTime.Now'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..22)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [24..58)::34 + CSharpCodeBlock - [24..37)::13 + CSharpImplicitExpression - [24..37)::13 + CSharpTransition - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [25..37)::12 + CSharpCodeBlock - [25..37)::12 + CSharpExpressionLiteral - [25..37)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [37..45)::8 - [ middle ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[middle]; + Whitespace;[ ]; + CSharpCodeBlock - [45..58)::13 + CSharpImplicitExpression - [45..58)::13 + CSharpTransition - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [46..58)::12 + CSharpCodeBlock - [46..58)::12 + CSharpExpressionLiteral - [46..58)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [58..59)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [59..60)::1 + MarkupTextLiteral - [59..60)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [62..62)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [62..63)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [63..63)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.tspans.txt new file mode 100644 index 0000000000..d2ec83b74f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Block7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [60] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.cspans.txt new file mode 100644 index 0000000000..0f363fa410 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (22:0,22 [1] ) (Accepts:None) - Parent: Expression block at (22:0,22 [13] ) +Code span at (23:0,23 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (22:0,22 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.stree.txt new file mode 100644 index 0000000000..005a8559dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..39)::39 - [] + MarkupBlock - [0..39)::39 + MarkupTagHelperElement - [0..39)::39 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..39)::39 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..36)::30 - data-required - SingleQuotes - Unbound - [ data-required='@DateTime.Now'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..35)::13 + CSharpCodeBlock - [22..35)::13 + CSharpImplicitExpression - [22..35)::13 + CSharpTransition - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [23..35)::12 + CSharpCodeBlock - [23..35)::12 + CSharpExpressionLiteral - [23..35)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [36..37)::1 + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.tspans.txt new file mode 100644 index 0000000000..12328928a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [39] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.cspans.txt new file mode 100644 index 0000000000..c7e4c20b33 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.cspans.txt @@ -0,0 +1 @@ +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.stree.txt new file mode 100644 index 0000000000..6add56eab5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..31)::31 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..28)::22 - data-required - SingleQuotes - Unbound - [ data-required='value'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..27)::5 + MarkupTextLiteral - [22..27)::5 - [value] - Gen - SpanEditHandler;Accepts:Any + Text;[value]; + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.tspans.txt new file mode 100644 index 0000000000..230d60af71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.cspans.txt new file mode 100644 index 0000000000..1500c5924f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (22:0,22 [7] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [20] ) +Transition span at (29:0,29 [1] ) (Accepts:None) - Parent: Expression block at (29:0,29 [13] ) +Code span at (30:0,30 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (29:0,29 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.stree.txt new file mode 100644 index 0000000000..c473d31919 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..46)::46 - [] + MarkupBlock - [0..46)::46 + MarkupTagHelperElement - [0..46)::46 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..46)::46 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..43)::37 - data-required - SingleQuotes - Unbound - [ data-required='prefix @DateTime.Now'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..42)::20 + MarkupTextLiteral - [22..29)::7 - [prefix ] - Gen - SpanEditHandler;Accepts:Any + Text;[prefix]; + Whitespace;[ ]; + CSharpCodeBlock - [29..42)::13 + CSharpImplicitExpression - [29..42)::13 + CSharpTransition - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [30..42)::12 + CSharpCodeBlock - [30..42)::12 + CSharpExpressionLiteral - [30..42)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [42..43)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [43..44)::1 + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.tspans.txt new file mode 100644 index 0000000000..81cfc6f2a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [46] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.cspans.txt new file mode 100644 index 0000000000..7a49d77d28 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (22:0,22 [1] ) (Accepts:None) - Parent: Expression block at (22:0,22 [13] ) +Code span at (23:0,23 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (22:0,22 [13] ) +Markup span at (35:0,35 [7] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.stree.txt new file mode 100644 index 0000000000..1933f85f88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..46)::46 - [] + MarkupBlock - [0..46)::46 + MarkupTagHelperElement - [0..46)::46 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..46)::46 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..43)::37 - data-required - SingleQuotes - Unbound - [ data-required='@DateTime.Now suffix'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..42)::20 + CSharpCodeBlock - [22..35)::13 + CSharpImplicitExpression - [22..35)::13 + CSharpTransition - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [23..35)::12 + CSharpCodeBlock - [23..35)::12 + CSharpExpressionLiteral - [23..35)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [35..42)::7 - [ suffix] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[suffix]; + MarkupTextLiteral - [42..43)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [43..44)::1 + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.tspans.txt new file mode 100644 index 0000000000..81cfc6f2a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [46] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.cspans.txt new file mode 100644 index 0000000000..4ffa71d61f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (22:0,22 [7] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [27] ) +Transition span at (29:0,29 [1] ) (Accepts:None) - Parent: Expression block at (29:0,29 [13] ) +Code span at (30:0,30 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (29:0,29 [13] ) +Markup span at (42:0,42 [7] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.stree.txt new file mode 100644 index 0000000000..1e750fbb5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..53)::53 - [] + MarkupBlock - [0..53)::53 + MarkupTagHelperElement - [0..53)::53 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..53)::53 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..50)::44 - data-required - SingleQuotes - Unbound - [ data-required='prefix @DateTime.Now suffix'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..49)::27 + MarkupTextLiteral - [22..29)::7 - [prefix ] - Gen - SpanEditHandler;Accepts:Any + Text;[prefix]; + Whitespace;[ ]; + CSharpCodeBlock - [29..42)::13 + CSharpImplicitExpression - [29..42)::13 + CSharpTransition - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [30..42)::12 + CSharpCodeBlock - [30..42)::12 + CSharpExpressionLiteral - [30..42)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [42..49)::7 - [ suffix] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[suffix]; + MarkupTextLiteral - [49..50)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [50..51)::1 + MarkupTextLiteral - [50..51)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.tspans.txt new file mode 100644 index 0000000000..0a6025f261 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [53] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.cspans.txt new file mode 100644 index 0000000000..72d6434606 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (36:0,36 [7] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [27] ) +Transition span at (43:0,43 [1] ) (Accepts:None) - Parent: Expression block at (43:0,43 [13] ) +Code span at (44:0,44 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (43:0,43 [13] ) +Markup span at (56:0,56 [7] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.stree.txt new file mode 100644 index 0000000000..2389a37fac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..82)::82 - [] + MarkupBlock - [0..82)::82 + MarkupTagHelperElement - [0..82)::82 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..82)::82 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..20)::14 - pre-attribute - Minimized - Unbound - [ pre-attribute] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [pre-attribute] - Gen - SpanEditHandler;Accepts:Any + Text;[pre-attribute]; + MarkupTagHelperAttribute - [20..64)::44 - data-required - SingleQuotes - Unbound - [ data-required='prefix @DateTime.Now suffix'] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..34)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [36..63)::27 + MarkupTextLiteral - [36..43)::7 - [prefix ] - Gen - SpanEditHandler;Accepts:Any + Text;[prefix]; + Whitespace;[ ]; + CSharpCodeBlock - [43..56)::13 + CSharpImplicitExpression - [43..56)::13 + CSharpTransition - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [44..56)::12 + CSharpCodeBlock - [44..56)::12 + CSharpExpressionLiteral - [44..56)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [56..63)::7 - [ suffix] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[suffix]; + MarkupTextLiteral - [63..64)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [64..79)::15 - post-attribute - Minimized - Unbound - [ post-attribute] + MarkupTextLiteral - [64..65)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [65..79)::14 - [post-attribute] - Gen - SpanEditHandler;Accepts:Any + Text;[post-attribute]; + MarkupMiscAttributeContent - [79..80)::1 + MarkupTextLiteral - [79..80)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.tspans.txt new file mode 100644 index 0000000000..368fd6b6d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [82] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.cspans.txt new file mode 100644 index 0000000000..4cf3018f98 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (22:0,22 [1] ) (Accepts:None) - Parent: Expression block at (22:0,22 [13] ) +Code span at (23:0,23 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (22:0,22 [13] ) +Markup span at (35:0,35 [8] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [34] ) +Transition span at (43:0,43 [1] ) (Accepts:None) - Parent: Expression block at (43:0,43 [13] ) +Code span at (44:0,44 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (43:0,43 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.stree.txt new file mode 100644 index 0000000000..f8d3ba9284 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..60)::60 - [] + MarkupBlock - [0..60)::60 + MarkupTagHelperElement - [0..60)::60 - input[SelfClosing] - inputtaghelper + MarkupTagHelperStartTag - [0..60)::60 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..57)::51 - data-required - SingleQuotes - Unbound - [ data-required='@DateTime.Now middle @DateTime.Now'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..20)::13 - [data-required] - Gen - SpanEditHandler;Accepts:Any + Text;[data-required]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..56)::34 + CSharpCodeBlock - [22..35)::13 + CSharpImplicitExpression - [22..35)::13 + CSharpTransition - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [23..35)::12 + CSharpCodeBlock - [23..35)::12 + CSharpExpressionLiteral - [23..35)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [35..43)::8 - [ middle ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[middle]; + Whitespace;[ ]; + CSharpCodeBlock - [43..56)::13 + CSharpImplicitExpression - [43..56)::13 + CSharpTransition - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [44..56)::12 + CSharpCodeBlock - [44..56)::12 + CSharpExpressionLiteral - [44..56)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [56..57)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [57..58)::1 + MarkupTextLiteral - [57..58)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.tspans.txt new file mode 100644 index 0000000000..cd85eb4a9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/GeneratesExpectedOutputForUnboundDataDashAttributes_Document7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [60] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.cspans.txt new file mode 100644 index 0000000000..c768c47175 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.cspans.txt @@ -0,0 +1,5 @@ +MetaCode span at (7:0,7 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [60] ) +Code span at (20:0,20 [7] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [60] ) +MetaCode span at (29:0,29 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [60] ) +MetaCode span at (40:0,40 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [60] ) +Markup span at (48:0,48 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [60] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.stree.txt new file mode 100644 index 0000000000..9118b9908d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..60)::60 - [] + MarkupBlock - [0..60)::60 + MarkupTagHelperElement - [0..60)::60 - input[SelfClosing] - Bind + MarkupTagHelperStartTag - [0..60)::60 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperDirectiveAttribute - [6..28)::22 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [7..8)::1 + Transition;[@]; + MarkupTextLiteral - [8..18)::10 - [bind-value] + Text;[bind-value]; + Equals;[=]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [20..27)::7 + CSharpExpressionLiteral - [20..27)::7 - [Message] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[Message]; + MarkupTextLiteral - [27..28)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperDirectiveAttribute - [28..57)::29 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [29..30)::1 + Transition;[@]; + MarkupTextLiteral - [30..40)::10 - [bind-value] + Text;[bind-value]; + RazorMetaCode - [40..41)::1 + Colon;[:]; + MarkupTextLiteral - [41..46)::5 - [event] + Text;[event]; + Equals;[=]; + MarkupTextLiteral - [47..48)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [48..56)::8 + MarkupTextLiteral - [48..56)::8 - [onchange] - Gen - SpanEditHandler;Accepts:Any + Text;[onchange]; + MarkupTextLiteral - [56..57)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [57..58)::1 + MarkupTextLiteral - [57..58)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.tspans.txt new file mode 100644 index 0000000000..31cb82bc12 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_ComponentDirectiveAttributes.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [60] ) - Bind diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.cspans.txt new file mode 100644 index 0000000000..0d481010a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.cspans.txt @@ -0,0 +1,3 @@ +MetaCode span at (7:0,7 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +MetaCode span at (17:0,17 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +MetaCode span at (26:0,26 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.diag.txt new file mode 100644 index 0000000000..79b4724fca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.diag.txt @@ -0,0 +1,2 @@ +(1,8): Error RZ2008: Attribute '@bind-foo' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Object' cannot be empty or contain only whitespace. +(1,18): Error RZ2008: Attribute '@bind-foo:param' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Object' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.stree.txt new file mode 100644 index 0000000000..ba103eb489 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..35)::35 - [] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - input[SelfClosing] - Bind + MarkupTagHelperStartTag - [0..35)::35 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperDirectiveAttribute - [6..16)::10 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [7..8)::1 + Transition;[@]; + MarkupTextLiteral - [8..16)::8 - [bind-foo] + Text;[bind-foo]; + MarkupMinimizedTagHelperDirectiveAttribute - [16..32)::16 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RazorMetaCode - [17..18)::1 + Transition;[@]; + MarkupTextLiteral - [18..26)::8 - [bind-foo] + Text;[bind-foo]; + RazorMetaCode - [26..27)::1 + Colon;[:]; + MarkupTextLiteral - [27..32)::5 - [param] + Text;[param]; + MarkupMiscAttributeContent - [32..33)::1 + MarkupTextLiteral - [32..33)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.tspans.txt new file mode 100644 index 0000000000..51f2cc1454 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrites_MinimizedComponentDirectiveAttributes.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - Bind diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.cspans.txt new file mode 100644 index 0000000000..b036e36e17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) +Markup span at (1:0,1 [1] ) (Accepts:Any) - Parent: Tag block at (1:0,1 [1] ) +Markup span at (5:0,5 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.stree.txt new file mode 100644 index 0000000000..d7c4029b8d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..11)::11 - [<<

                        >>

                        ] + MarkupBlock - [0..11)::11 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupElement - [1..2)::1 + MarkupStartTag - [1..2)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [2..11)::9 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [2..5)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [5..7)::2 - [>>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [7..11)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.tspans.txt new file mode 100644 index 0000000000..894ab5361e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [9] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.cspans.txt new file mode 100644 index 0000000000..2961977bf2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [17] ) +Transition span at (5:0,5 [1] ) (Accepts:None) - Parent: Expression block at (5:0,5 [13] ) +Code span at (6:0,6 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (5:0,5 [13] ) +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [17] ) +Markup span at (20:0,20 [3] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [3] ) +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Expression block at (23:0,23 [13] ) +Code span at (24:0,24 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (23:0,23 [13] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.stree.txt new file mode 100644 index 0000000000..d7132ba6a3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.stree.txt @@ -0,0 +1,53 @@ +RazorDocument - [0..42)::42 - [

                        < @DateTime.Now >

                        ] + MarkupBlock - [0..42)::42 + MarkupTagHelperElement - [0..42)::42 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..23)::20 + MarkupStartTag - [3..20)::17 - [< @DateTime.Now >] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMiscAttributeContent - [4..19)::15 + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CSharpCodeBlock - [5..18)::13 + CSharpImplicitExpression - [5..18)::13 + CSharpTransition - [5..6)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [6..18)::12 + CSharpCodeBlock - [6..18)::12 + CSharpExpressionLiteral - [6..18)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupEndTag - [20..23)::3 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + MarkupMiscAttributeContent - [22..23)::1 + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + CSharpCodeBlock - [23..36)::13 + CSharpImplicitExpression - [23..36)::13 + CSharpTransition - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [24..36)::12 + CSharpCodeBlock - [24..36)::12 + CSharpExpressionLiteral - [24..36)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [36..38)::2 - [ >] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [38..42)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.tspans.txt new file mode 100644 index 0000000000..ba17544451 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [42] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.cspans.txt new file mode 100644 index 0000000000..0e6957363a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.stree.txt new file mode 100644 index 0000000000..6287be03cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..6)::6 - [<

                        ] + MarkupBlock - [0..6)::6 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [1..6)::5 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [1..6)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [3..4)::1 + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.tspans.txt new file mode 100644 index 0000000000..84e47f2a85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (1:0,1 [5] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml3.cspans.txt new file mode 100644 index 0000000000..a81209229a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [6] ) +Markup span at (1:0,1 [2] ) (Accepts:Any) - Parent: Markup block at (1:0,1 [2] ) +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml3.stree.txt new file mode 100644 index 0000000000..3ad4a9bcc6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml3.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..6)::6 - [< p />] + MarkupBlock - [0..6)::6 + MarkupElement - [0..6)::6 + MarkupStartTag - [0..6)::6 - [< p />] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMinimizedAttributeBlock - [1..3)::2 - [ p] + MarkupTextLiteral - [1..2)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [2..3)::1 - [p] - Gen - SpanEditHandler;Accepts:Any + Text;[p]; + MarkupMiscAttributeContent - [3..4)::1 + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.cspans.txt new file mode 100644 index 0000000000..4f69cb3f10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.stree.txt new file mode 100644 index 0000000000..ed83e316d0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..12)::12 - [] + MarkupBlock - [0..12)::12 + MarkupElement - [0..7)::7 + MarkupStartTag - [0..7)::7 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTagHelperElement - [7..12)::5 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [7..12)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [9..10)::1 + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.tspans.txt new file mode 100644 index 0000000000..42777cb027 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (7:0,7 [5] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.cspans.txt new file mode 100644 index 0000000000..c6be2f1925 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) +Markup span at (1:0,1 [8] ) (Accepts:Any) - Parent: Markup block at (1:0,1 [12] ) +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Markup block at (1:0,1 [12] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (1:0,1 [12] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.stree.txt new file mode 100644 index 0000000000..857397eb39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..19)::19 - [< class="foo"

                        ] + MarkupBlock - [0..19)::19 + MarkupElement - [0..14)::14 + MarkupStartTag - [0..14)::14 - [< class="foo" ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupAttributeBlock - [1..13)::12 - [ class="foo"] + MarkupTextLiteral - [1..2)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [2..7)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [8..9)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [13..14)::1 + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTagHelperElement - [14..19)::5 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [14..19)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.tspans.txt new file mode 100644 index 0000000000..ad370b61a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (14:0,14 [5] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.cspans.txt new file mode 100644 index 0000000000..680a4f547c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [2] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [1] ) +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [9] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.stree.txt new file mode 100644 index 0000000000..3203e9a1e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..13)::13 - [/>

                        >] + MarkupBlock - [0..13)::13 + MarkupElement - [0..2)::2 + MarkupEndTag - [0..2)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupElement - [2..3)::1 + MarkupStartTag - [2..3)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [3..12)::9 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [3..6)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [6..8)::2 - [/>] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [8..12)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [12..13)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.tspans.txt new file mode 100644 index 0000000000..4efdfadfb9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (3:0,3 [9] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.cspans.txt new file mode 100644 index 0000000000..026682c72d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [2] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [1] ) +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [17] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [8] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.stree.txt new file mode 100644 index 0000000000..e7a7bd8bef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..21)::21 - [/>

                        >] + MarkupBlock - [0..21)::21 + MarkupElement - [0..2)::2 + MarkupEndTag - [0..2)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupElement - [2..3)::1 + MarkupStartTag - [2..3)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [3..20)::17 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [3..6)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [6..8)::2 - [/>] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupElement - [8..16)::8 + MarkupStartTag - [8..16)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [16..20)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [20..21)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.tspans.txt new file mode 100644 index 0000000000..f66bf28d95 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (3:0,3 [17] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.cspans.txt new file mode 100644 index 0000000000..31aa41b4cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [2] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [1] ) +Transition span at (6:0,6 [1] ) (Accepts:None) - Parent: Expression block at (6:0,6 [13] ) +Code span at (7:0,7 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (6:0,6 [13] ) +Markup span at (19:0,19 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [30] ) +Markup span at (21:0,21 [8] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [8] ) +Markup span at (33:0,33 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.stree.txt new file mode 100644 index 0000000000..d15f747b50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..34)::34 - [@DateTime.Now/>

                        >] + MarkupBlock - [0..34)::34 + MarkupElement - [0..2)::2 + MarkupEndTag - [0..2)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupElement - [2..3)::1 + MarkupStartTag - [2..3)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [3..33)::30 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [3..6)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [6..19)::13 + CSharpImplicitExpression - [6..19)::13 + CSharpTransition - [6..7)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [7..19)::12 + CSharpCodeBlock - [7..19)::12 + CSharpExpressionLiteral - [7..19)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [19..21)::2 - [/>] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupElement - [21..29)::8 + MarkupStartTag - [21..29)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [29..33)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [33..34)::1 - [>] - Gen - SpanEditHandler;Accepts:Any + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.tspans.txt new file mode 100644 index 0000000000..9953ea6327 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (3:0,3 [30] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.cspans.txt new file mode 100644 index 0000000000..38e6112313 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) +Markup span at (5:0,5 [4] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [4] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [13] ) +Code span at (13:0,13 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [13] ) +Markup span at (25:0,25 [4] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [32] ) +Markup span at (29:0,29 [8] ) (Accepts:Any) - Parent: Tag block at (29:0,29 [8] ) +Markup span at (41:0,41 [11] ) (Accepts:Any) - Parent: Tag block at (41:0,41 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.stree.txt new file mode 100644 index 0000000000..d7790cca1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.stree.txt @@ -0,0 +1,59 @@ +RazorDocument - [0..52)::52 - [

                        @DateTime.Now / >

                        ] + MarkupBlock - [0..52)::52 + MarkupElement - [0..4)::4 + MarkupEndTag - [0..4)::4 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + MarkupMiscAttributeContent - [2..4)::2 + MarkupTextLiteral - [2..4)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTextLiteral - [4..5)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupElement - [5..52)::47 + MarkupStartTag - [5..9)::4 - [< >] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + MarkupMiscAttributeContent - [6..8)::2 + MarkupTextLiteral - [6..8)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTagHelperElement - [9..41)::32 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [9..12)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [12..25)::13 + CSharpImplicitExpression - [12..25)::13 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..25)::12 + CSharpCodeBlock - [13..25)::12 + CSharpExpressionLiteral - [13..25)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [25..29)::4 - [ / >] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + Whitespace;[ ]; + CloseAngle;[>]; + MarkupElement - [29..37)::8 + MarkupStartTag - [29..37)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [37..41)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [41..52)::11 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + MarkupMiscAttributeContent - [43..51)::8 + MarkupTextLiteral - [43..51)::8 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.tspans.txt new file mode 100644 index 0000000000..4d43ab5dde --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_AllowsInvalidHtml9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (9:0,9 [32] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.cspans.txt new file mode 100644 index 0000000000..e3af2600c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [64] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (41:0,41 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [64] ) +Markup span at (64:0,64 [9] ) (Accepts:Any) - Parent: Tag block at (64:0,64 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.diag.txt new file mode 100644 index 0000000000..2578ab72e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.diag.txt @@ -0,0 +1,2 @@ +(1,54): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,67): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.stree.txt new file mode 100644 index 0000000000..3bd2c13667 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.stree.txt @@ -0,0 +1,62 @@ +RazorDocument - [0..73)::73 - [

                        ] + MarkupBlock - [0..73)::73 + MarkupTagHelperElement - [0..64)::64 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..52)::52 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTagHelperAttribute - [12..34)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..20)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [21..34)::13 + MarkupDynamicAttributeValue - [21..34)::13 - [@DateTime.Now] + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperAttribute - [34..51)::17 - style - DoubleQuotes - Unbound - [ style=color:red;] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..40)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTagHelperAttributeValue - [41..51)::10 + MarkupLiteralAttributeValue - [41..51)::10 - [color:red;] + MarkupTextLiteral - [41..51)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + CloseAngle;[>]; + MarkupTagHelperElement - [52..60)::8 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [52..60)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [60..64)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [64..73)::9 + MarkupEndTag - [64..73)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.tspans.txt new file mode 100644 index 0000000000..13065315b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper1.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [64] ) - ptaghelper +TagHelper span at (52:0,52 [8] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.cspans.txt new file mode 100644 index 0000000000..f4e5ce935c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [31] ) +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [22] ) +Markup span at (36:0,36 [6] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.diag.txt new file mode 100644 index 0000000000..b1d7d8700f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.stree.txt new file mode 100644 index 0000000000..b14f935845 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..42)::42 - [

                        Hello World

                        ] + MarkupBlock - [0..42)::42 + MarkupElement - [0..42)::42 + MarkupStartTag - [0..5)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperElement - [5..36)::31 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [5..8)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [8..14)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + MarkupTagHelperElement - [14..36)::22 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [14..22)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [22..27)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [27..36)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [36..42)::6 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.tspans.txt new file mode 100644 index 0000000000..36dd08e818 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (5:0,5 [31] ) - ptaghelper +TagHelper span at (14:0,14 [22] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.cspans.txt new file mode 100644 index 0000000000..a003b54d78 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (8:0,8 [6] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [22] ) +Markup span at (22:0,22 [5] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [13] ) +Markup span at (27:0,27 [6] ) (Accepts:Any) - Parent: Tag block at (27:0,27 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.diag.txt new file mode 100644 index 0000000000..f0fb702841 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.diag.txt @@ -0,0 +1,2 @@ +(1,7): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,16): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.stree.txt new file mode 100644 index 0000000000..d81b716ffb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..33)::33 - [

                        Hello World

                        ] + MarkupBlock - [0..33)::33 + MarkupElement - [0..33)::33 + MarkupStartTag - [0..5)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperElement - [5..27)::22 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [5..8)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [8..14)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + MarkupTagHelperElement - [14..27)::13 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [14..22)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [22..27)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupEndTag - [27..33)::6 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.tspans.txt new file mode 100644 index 0000000000..9fc6edf71a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (5:0,5 [22] ) - ptaghelper +TagHelper span at (14:0,14 [13] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.cspans.txt new file mode 100644 index 0000000000..201fd033d5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [52] ) +Markup span at (15:0,15 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [52] ) +Markup span at (31:0,31 [10] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [31] ) +Markup span at (43:0,43 [5] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.diag.txt new file mode 100644 index 0000000000..d177eb6df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.stree.txt new file mode 100644 index 0000000000..1b2046e56b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..52)::52 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..52)::52 + MarkupTagHelperElement - [0..52)::52 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [15..21)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + MarkupTagHelperElement - [21..52)::31 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [21..43)::22 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [23..42)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..29)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [31..41)::10 + MarkupLiteralAttributeValue - [31..41)::10 - [color:red;] + MarkupTextLiteral - [31..41)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [41..42)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [43..48)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [48..52)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.tspans.txt new file mode 100644 index 0000000000..9cc0f52b9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_CreatesErrorForIncompleteTagHelper4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [52] ) - ptaghelper +TagHelper span at (21:0,21 [31] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.cspans.txt new file mode 100644 index 0000000000..646bf548d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) +Transition span at (32:0,32 [1] ) (Accepts:None) - Parent: Expression block at (32:0,32 [13] ) +Code span at (33:0,33 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (32:0,32 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.stree.txt new file mode 100644 index 0000000000..219e227fc1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..51)::51 - [

                        ] + MarkupBlock - [0..51)::51 + MarkupTagHelperElement - [0..51)::51 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..47)::47 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..23)::13 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [24..46)::22 - style - SingleQuotes - Unbound - [ style='@DateTime.Now'] + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [25..30)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [31..32)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [32..45)::13 + MarkupDynamicAttributeValue - [32..45)::13 - [@DateTime.Now] + GenericBlock - [32..45)::13 + CSharpCodeBlock - [32..45)::13 + CSharpImplicitExpression - [32..45)::13 + CSharpTransition - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [33..45)::12 + CSharpCodeBlock - [33..45)::12 + CSharpExpressionLiteral - [33..45)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [45..46)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [47..51)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.tspans.txt new file mode 100644 index 0000000000..23e57e8f34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [51] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.cspans.txt new file mode 100644 index 0000000000..d595d25c40 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.cspans.txt @@ -0,0 +1,12 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (10:0,10 [64] ) +Code span at (11:0,11 [20] ) (Accepts:Any) - Parent: Statement block at (10:0,10 [64] ) +Transition span at (31:0,31 [6] ) (Accepts:None) - Parent: Tag block at (31:0,31 [6] ) +Markup span at (37:0,37 [3] ) (Accepts:Any) - Parent: Markup block at (31:0,31 [16] ) +Transition span at (40:0,40 [7] ) (Accepts:None) - Parent: Tag block at (40:0,40 [7] ) +Code span at (47:0,47 [27] ) (Accepts:None) - Parent: Statement block at (10:0,10 [64] ) +Transition span at (83:0,83 [1] ) (Accepts:None) - Parent: Statement block at (83:0,83 [64] ) +Code span at (84:0,84 [20] ) (Accepts:Any) - Parent: Statement block at (83:0,83 [64] ) +Transition span at (104:0,104 [6] ) (Accepts:None) - Parent: Tag block at (104:0,104 [6] ) +Markup span at (110:0,110 [3] ) (Accepts:Any) - Parent: Markup block at (104:0,104 [16] ) +Transition span at (113:0,113 [7] ) (Accepts:None) - Parent: Tag block at (113:0,113 [7] ) +Code span at (120:0,120 [27] ) (Accepts:None) - Parent: Statement block at (83:0,83 [64] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.stree.txt new file mode 100644 index 0000000000..f64298d554 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.stree.txt @@ -0,0 +1,132 @@ +RazorDocument - [0..153)::153 - [

                        ] + MarkupBlock - [0..153)::153 + MarkupTagHelperElement - [0..153)::153 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..149)::149 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..75)::73 - class - DoubleQuotes - Unbound - [ class="@do { var foo = bar; Foo foo++; } while (foo);"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..74)::64 + MarkupDynamicAttributeValue - [10..74)::64 - [@do { var foo = bar; Foo foo++; } while (foo);] + GenericBlock - [10..74)::64 + CSharpCodeBlock - [10..74)::64 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [11..31)::20 - [do { var foo = bar; ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + MarkupBlock - [31..47)::16 + MarkupElement - [31..47)::16 + MarkupStartTag - [31..37)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [37..40)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [40..47)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [47..74)::27 - [ foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [74..75)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [75..148)::73 - style - SingleQuotes - Unbound - [ style='@do { var foo = bar; Foo foo++; } while (foo);'] + MarkupTextLiteral - [75..76)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [76..81)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [82..83)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [83..147)::64 + MarkupDynamicAttributeValue - [83..147)::64 - [@do { var foo = bar; Foo foo++; } while (foo);] + GenericBlock - [83..147)::64 + CSharpCodeBlock - [83..147)::64 + CSharpTransition - [83..84)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [84..104)::20 - [do { var foo = bar; ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + MarkupBlock - [104..120)::16 + MarkupElement - [104..120)::16 + MarkupStartTag - [104..110)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [110..113)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [113..120)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [120..147)::27 - [ foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [147..148)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [149..153)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.tspans.txt new file mode 100644 index 0000000000..112587be7d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [153] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.cspans.txt new file mode 100644 index 0000000000..b49460175d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) +Transition span at (32:0,32 [1] ) (Accepts:None) - Parent: Expression block at (32:0,32 [13] ) +Code span at (33:0,33 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (32:0,32 [13] ) +Markup span at (47:0,47 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [62] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.stree.txt new file mode 100644 index 0000000000..3920141b9e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.stree.txt @@ -0,0 +1,62 @@ +RazorDocument - [0..62)::62 - [

                        Hello World

                        ] + MarkupBlock - [0..62)::62 + MarkupTagHelperElement - [0..62)::62 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..47)::47 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..23)::13 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [24..46)::22 - style - SingleQuotes - Unbound - [ style='@DateTime.Now'] + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [25..30)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [31..32)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [32..45)::13 + MarkupDynamicAttributeValue - [32..45)::13 - [@DateTime.Now] + GenericBlock - [32..45)::13 + CSharpCodeBlock - [32..45)::13 + CSharpImplicitExpression - [32..45)::13 + CSharpTransition - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [33..45)::12 + CSharpCodeBlock - [33..45)::12 + CSharpExpressionLiteral - [33..45)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [45..46)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [47..58)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [58..62)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.tspans.txt new file mode 100644 index 0000000000..d720c816de --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [62] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.cspans.txt new file mode 100644 index 0000000000..dc6757f2fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.cspans.txt @@ -0,0 +1,13 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (10:0,10 [64] ) +Code span at (11:0,11 [20] ) (Accepts:Any) - Parent: Statement block at (10:0,10 [64] ) +Transition span at (31:0,31 [6] ) (Accepts:None) - Parent: Tag block at (31:0,31 [6] ) +Markup span at (37:0,37 [3] ) (Accepts:Any) - Parent: Markup block at (31:0,31 [16] ) +Transition span at (40:0,40 [7] ) (Accepts:None) - Parent: Tag block at (40:0,40 [7] ) +Code span at (47:0,47 [27] ) (Accepts:None) - Parent: Statement block at (10:0,10 [64] ) +Transition span at (83:0,83 [1] ) (Accepts:None) - Parent: Statement block at (83:0,83 [64] ) +Code span at (84:0,84 [20] ) (Accepts:Any) - Parent: Statement block at (83:0,83 [64] ) +Transition span at (104:0,104 [6] ) (Accepts:None) - Parent: Tag block at (104:0,104 [6] ) +Markup span at (110:0,110 [3] ) (Accepts:Any) - Parent: Markup block at (104:0,104 [16] ) +Transition span at (113:0,113 [7] ) (Accepts:None) - Parent: Tag block at (113:0,113 [7] ) +Code span at (120:0,120 [27] ) (Accepts:None) - Parent: Statement block at (83:0,83 [64] ) +Markup span at (149:0,149 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [164] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.stree.txt new file mode 100644 index 0000000000..50fdae1085 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.stree.txt @@ -0,0 +1,136 @@ +RazorDocument - [0..164)::164 - [

                        Hello World

                        ] + MarkupBlock - [0..164)::164 + MarkupTagHelperElement - [0..164)::164 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..149)::149 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..75)::73 - class - DoubleQuotes - Unbound - [ class="@do { var foo = bar; Foo foo++; } while (foo);"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..74)::64 + MarkupDynamicAttributeValue - [10..74)::64 - [@do { var foo = bar; Foo foo++; } while (foo);] + GenericBlock - [10..74)::64 + CSharpCodeBlock - [10..74)::64 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [11..31)::20 - [do { var foo = bar; ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + MarkupBlock - [31..47)::16 + MarkupElement - [31..47)::16 + MarkupStartTag - [31..37)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [37..40)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [40..47)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [47..74)::27 - [ foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [74..75)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [75..148)::73 - style - SingleQuotes - Unbound - [ style='@do { var foo = bar; Foo foo++; } while (foo);'] + MarkupTextLiteral - [75..76)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [76..81)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [82..83)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [83..147)::64 + MarkupDynamicAttributeValue - [83..147)::64 - [@do { var foo = bar; Foo foo++; } while (foo);] + GenericBlock - [83..147)::64 + CSharpCodeBlock - [83..147)::64 + CSharpTransition - [83..84)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [84..104)::20 - [do { var foo = bar; ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + MarkupBlock - [104..120)::16 + MarkupElement - [104..120)::16 + MarkupStartTag - [104..110)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [110..113)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [113..120)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [120..147)::27 - [ foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [147..148)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [149..160)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [160..164)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.tspans.txt new file mode 100644 index 0000000000..396ba4cb79 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [164] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.cspans.txt new file mode 100644 index 0000000000..8737eaeaf8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) +Markup span at (25:0,25 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [34] ) +Markup span at (34:0,34 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [69] ) +Transition span at (45:0,45 [1] ) (Accepts:None) - Parent: Expression block at (45:0,45 [13] ) +Code span at (46:0,46 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (45:0,45 [13] ) +Markup span at (60:0,60 [5] ) (Accepts:Any) - Parent: Tag block at (35:0,35 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.stree.txt new file mode 100644 index 0000000000..5199be1c54 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.stree.txt @@ -0,0 +1,74 @@ +RazorDocument - [0..69)::69 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..69)::69 + MarkupTagHelperElement - [0..34)::34 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..25)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..23)::13 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [25..30)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [30..34)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [35..69)::34 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [35..60)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [37..59)::22 - style - SingleQuotes - Unbound - [ style='@DateTime.Now'] + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [38..43)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [44..45)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [45..58)::13 + MarkupDynamicAttributeValue - [45..58)::13 - [@DateTime.Now] + GenericBlock - [45..58)::13 + CSharpCodeBlock - [45..58)::13 + CSharpImplicitExpression - [45..58)::13 + CSharpTransition - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [46..58)::12 + CSharpCodeBlock - [46..58)::12 + CSharpExpressionLiteral - [46..58)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [58..59)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [60..65)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [65..69)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.tspans.txt new file mode 100644 index 0000000000..0c0ec10e16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks5.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [34] ) - ptaghelper +TagHelper span at (35:0,35 [34] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.cspans.txt new file mode 100644 index 0000000000..a07650681c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.cspans.txt @@ -0,0 +1,15 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (10:0,10 [64] ) +Code span at (11:0,11 [20] ) (Accepts:Any) - Parent: Statement block at (10:0,10 [64] ) +Transition span at (31:0,31 [6] ) (Accepts:None) - Parent: Tag block at (31:0,31 [6] ) +Markup span at (37:0,37 [3] ) (Accepts:Any) - Parent: Markup block at (31:0,31 [16] ) +Transition span at (40:0,40 [7] ) (Accepts:None) - Parent: Tag block at (40:0,40 [7] ) +Code span at (47:0,47 [27] ) (Accepts:None) - Parent: Statement block at (10:0,10 [64] ) +Markup span at (76:0,76 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [85] ) +Markup span at (85:0,85 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [171] ) +Transition span at (96:0,96 [1] ) (Accepts:None) - Parent: Statement block at (96:0,96 [64] ) +Code span at (97:0,97 [20] ) (Accepts:Any) - Parent: Statement block at (96:0,96 [64] ) +Transition span at (117:0,117 [6] ) (Accepts:None) - Parent: Tag block at (117:0,117 [6] ) +Markup span at (123:0,123 [3] ) (Accepts:Any) - Parent: Markup block at (117:0,117 [16] ) +Transition span at (126:0,126 [7] ) (Accepts:None) - Parent: Tag block at (126:0,126 [7] ) +Code span at (133:0,133 [27] ) (Accepts:None) - Parent: Statement block at (96:0,96 [64] ) +Markup span at (162:0,162 [5] ) (Accepts:Any) - Parent: Tag block at (86:0,86 [85] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.stree.txt new file mode 100644 index 0000000000..6109fde080 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.stree.txt @@ -0,0 +1,148 @@ +RazorDocument - [0..171)::171 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..171)::171 + MarkupTagHelperElement - [0..85)::85 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..76)::76 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..75)::73 - class - DoubleQuotes - Unbound - [ class="@do { var foo = bar; Foo foo++; } while (foo);"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..74)::64 + MarkupDynamicAttributeValue - [10..74)::64 - [@do { var foo = bar; Foo foo++; } while (foo);] + GenericBlock - [10..74)::64 + CSharpCodeBlock - [10..74)::64 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [11..31)::20 - [do { var foo = bar; ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + MarkupBlock - [31..47)::16 + MarkupElement - [31..47)::16 + MarkupStartTag - [31..37)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [37..40)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [40..47)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [47..74)::27 - [ foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [74..75)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [76..81)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [81..85)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [85..86)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [86..171)::85 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [86..162)::76 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [88..161)::73 - style - SingleQuotes - Unbound - [ style='@do { var foo = bar; Foo foo++; } while (foo);'] + MarkupTextLiteral - [88..89)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [89..94)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [95..96)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [96..160)::64 + MarkupDynamicAttributeValue - [96..160)::64 - [@do { var foo = bar; Foo foo++; } while (foo);] + GenericBlock - [96..160)::64 + CSharpCodeBlock - [96..160)::64 + CSharpTransition - [96..97)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [97..117)::20 - [do { var foo = bar; ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + Whitespace;[ ]; + MarkupBlock - [117..133)::16 + MarkupElement - [117..133)::16 + MarkupStartTag - [117..123)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [123..126)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [126..133)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [133..160)::27 - [ foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [160..161)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [162..167)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [167..171)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.tspans.txt new file mode 100644 index 0000000000..f8dba79588 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks6.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [85] ) - ptaghelper +TagHelper span at (86:0,86 [85] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.cspans.txt new file mode 100644 index 0000000000..c60ad109b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.cspans.txt @@ -0,0 +1,13 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) +Transition span at (32:0,32 [1] ) (Accepts:None) - Parent: Expression block at (32:0,32 [13] ) +Code span at (33:0,33 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (32:0,32 [13] ) +Markup span at (47:0,47 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [122] ) +Markup span at (59:0,59 [7] ) (Accepts:Any) - Parent: Tag block at (59:0,59 [30] ) +Markup span at (66:0,66 [8] ) (Accepts:Any) - Parent: Markup block at (66:0,66 [22] ) +Transition span at (74:0,74 [1] ) (Accepts:None) - Parent: Expression block at (74:0,74 [13] ) +Code span at (75:0,75 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (74:0,74 [13] ) +Markup span at (87:0,87 [1] ) (Accepts:Any) - Parent: Markup block at (66:0,66 [22] ) +Markup span at (88:0,88 [1] ) (Accepts:Any) - Parent: Tag block at (59:0,59 [30] ) +Markup span at (89:0,89 [20] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [122] ) +Markup span at (109:0,109 [9] ) (Accepts:Any) - Parent: Tag block at (109:0,109 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.stree.txt new file mode 100644 index 0000000000..2fb28c3926 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.stree.txt @@ -0,0 +1,104 @@ +RazorDocument - [0..122)::122 - [

                        Hello World inside of strong tag

                        ] + MarkupBlock - [0..122)::122 + MarkupTagHelperElement - [0..122)::122 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..47)::47 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..23)::13 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [24..46)::22 - style - SingleQuotes - Unbound - [ style='@DateTime.Now'] + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [25..30)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [31..32)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [32..45)::13 + MarkupDynamicAttributeValue - [32..45)::13 - [@DateTime.Now] + GenericBlock - [32..45)::13 + CSharpCodeBlock - [32..45)::13 + CSharpImplicitExpression - [32..45)::13 + CSharpTransition - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [33..45)::12 + CSharpCodeBlock - [33..45)::12 + CSharpExpressionLiteral - [33..45)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [45..46)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTextLiteral - [47..59)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + MarkupElement - [59..118)::59 + MarkupStartTag - [59..89)::30 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupAttributeBlock - [66..88)::22 - [ class="@DateTime.Now"] + MarkupTextLiteral - [66..67)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [67..72)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [73..74)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [74..87)::13 + MarkupDynamicAttributeValue - [74..87)::13 - [@DateTime.Now] + GenericBlock - [74..87)::13 + CSharpCodeBlock - [74..87)::13 + CSharpImplicitExpression - [74..87)::13 + CSharpTransition - [74..75)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [75..87)::12 + CSharpCodeBlock - [75..87)::12 + CSharpExpressionLiteral - [75..87)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [87..88)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [89..109)::20 - [inside of strong tag] - Gen - SpanEditHandler;Accepts:Any + Text;[inside]; + Whitespace;[ ]; + Text;[of]; + Whitespace;[ ]; + Text;[strong]; + Whitespace;[ ]; + Text;[tag]; + MarkupEndTag - [109..118)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [118..122)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.tspans.txt new file mode 100644 index 0000000000..e881d9b302 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [122] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.cspans.txt new file mode 100644 index 0000000000..1a81781533 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Expression block at (3:0,3 [13] ) +Code span at (4:0,4 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (3:0,3 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.stree.txt new file mode 100644 index 0000000000..eb398bbcec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..20)::20 - [

                        @DateTime.Now

                        ] + MarkupBlock - [0..20)::20 + MarkupTagHelperElement - [0..20)::20 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [3..16)::13 + CSharpImplicitExpression - [3..16)::13 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [4..16)::12 + CSharpCodeBlock - [4..16)::12 + CSharpExpressionLiteral - [4..16)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperEndTag - [16..20)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.tspans.txt new file mode 100644 index 0000000000..66adb496db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [20] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.cspans.txt new file mode 100644 index 0000000000..1f24e0d42a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.cspans.txt @@ -0,0 +1,6 @@ +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Statement block at (3:0,3 [58] ) +Code span at (4:0,4 [19] ) (Accepts:Any) - Parent: Statement block at (3:0,3 [58] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (23:0,23 [12] ) +Markup span at (27:0,27 [3] ) (Accepts:Any) - Parent: Tag block at (24:0,24 [10] ) +Markup span at (34:0,34 [1] ) (Accepts:None) - Parent: Markup block at (23:0,23 [12] ) +Code span at (35:0,35 [26] ) (Accepts:None) - Parent: Statement block at (3:0,3 [58] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.stree.txt new file mode 100644 index 0000000000..0fa891e8bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..65)::65 - [

                        @do { var foo = bar;

                        Foo

                        foo++; } while (foo);

                        ] + MarkupBlock - [0..65)::65 + MarkupTagHelperElement - [0..65)::65 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [3..61)::58 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [4..23)::19 - [do { var foo = bar;] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + MarkupBlock - [23..35)::12 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [24..34)::10 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [24..27)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [27..30)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTagHelperEndTag - [30..34)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [35..61)::26 - [foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTagHelperEndTag - [61..65)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.tspans.txt new file mode 100644 index 0000000000..7799cf6bf0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [65] ) - ptaghelper +TagHelper span at (24:0,24 [10] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.cspans.txt new file mode 100644 index 0000000000..09807c89f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (3:0,3 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [32] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [13] ) +Code span at (16:0,16 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (15:0,15 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.stree.txt new file mode 100644 index 0000000000..cdb14643e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..32)::32 - [

                        Hello World @DateTime.Now

                        ] + MarkupBlock - [0..32)::32 + MarkupTagHelperElement - [0..32)::32 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..15)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + CSharpCodeBlock - [15..28)::13 + CSharpImplicitExpression - [15..28)::13 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [16..28)::12 + CSharpCodeBlock - [16..28)::12 + CSharpExpressionLiteral - [16..28)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperEndTag - [28..32)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.tspans.txt new file mode 100644 index 0000000000..5cb039743d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [32] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.cspans.txt new file mode 100644 index 0000000000..2ad93795ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (3:0,3 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Statement block at (15:0,15 [58] ) +Code span at (16:0,16 [19] ) (Accepts:Any) - Parent: Statement block at (15:0,15 [58] ) +Markup span at (35:0,35 [1] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [12] ) +Markup span at (39:0,39 [3] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [10] ) +Markup span at (46:0,46 [1] ) (Accepts:None) - Parent: Markup block at (35:0,35 [12] ) +Code span at (47:0,47 [26] ) (Accepts:None) - Parent: Statement block at (15:0,15 [58] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.stree.txt new file mode 100644 index 0000000000..9bb210bc79 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..77)::77 - [

                        Hello World @do { var foo = bar;

                        Foo

                        foo++; } while (foo);

                        ] + MarkupBlock - [0..77)::77 + MarkupTagHelperElement - [0..77)::77 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..15)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + CSharpCodeBlock - [15..73)::58 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [16..35)::19 - [do { var foo = bar;] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + MarkupBlock - [35..47)::12 + MarkupTextLiteral - [35..36)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [36..46)::10 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [36..39)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [39..42)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTagHelperEndTag - [42..46)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [46..47)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [47..73)::26 - [foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTagHelperEndTag - [73..77)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.tspans.txt new file mode 100644 index 0000000000..24d79866fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [77] ) - ptaghelper +TagHelper span at (36:0,36 [10] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.cspans.txt new file mode 100644 index 0000000000..1f1417e4fd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Expression block at (3:0,3 [13] ) +Code span at (4:0,4 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (3:0,3 [13] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Expression block at (24:0,24 [13] ) +Code span at (25:0,25 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (24:0,24 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.stree.txt new file mode 100644 index 0000000000..4939b76203 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..41)::41 - [

                        @DateTime.Now

                        @DateTime.Now

                        ] + MarkupBlock - [0..41)::41 + MarkupTagHelperElement - [0..20)::20 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [3..16)::13 + CSharpImplicitExpression - [3..16)::13 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [4..16)::12 + CSharpCodeBlock - [4..16)::12 + CSharpExpressionLiteral - [4..16)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperEndTag - [16..20)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [21..41)::20 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [21..24)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [24..37)::13 + CSharpImplicitExpression - [24..37)::13 + CSharpTransition - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [25..37)::12 + CSharpCodeBlock - [25..37)::12 + CSharpExpressionLiteral - [25..37)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperEndTag - [37..41)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.tspans.txt new file mode 100644 index 0000000000..5c19dd2b8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks5.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [20] ) - ptaghelper +TagHelper span at (21:0,21 [20] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.cspans.txt new file mode 100644 index 0000000000..e79b4cf049 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.cspans.txt @@ -0,0 +1,13 @@ +Transition span at (3:0,3 [1] ) (Accepts:None) - Parent: Statement block at (3:0,3 [58] ) +Code span at (4:0,4 [19] ) (Accepts:Any) - Parent: Statement block at (3:0,3 [58] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (23:0,23 [12] ) +Markup span at (27:0,27 [3] ) (Accepts:Any) - Parent: Tag block at (24:0,24 [10] ) +Markup span at (34:0,34 [1] ) (Accepts:None) - Parent: Markup block at (23:0,23 [12] ) +Code span at (35:0,35 [26] ) (Accepts:None) - Parent: Statement block at (3:0,3 [58] ) +Markup span at (65:0,65 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [131] ) +Transition span at (69:0,69 [1] ) (Accepts:None) - Parent: Statement block at (69:0,69 [58] ) +Code span at (70:0,70 [19] ) (Accepts:Any) - Parent: Statement block at (69:0,69 [58] ) +Markup span at (89:0,89 [1] ) (Accepts:Any) - Parent: Markup block at (89:0,89 [12] ) +Markup span at (93:0,93 [3] ) (Accepts:Any) - Parent: Tag block at (90:0,90 [10] ) +Markup span at (100:0,100 [1] ) (Accepts:None) - Parent: Markup block at (89:0,89 [12] ) +Code span at (101:0,101 [26] ) (Accepts:None) - Parent: Statement block at (69:0,69 [58] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.stree.txt new file mode 100644 index 0000000000..599b101b45 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.stree.txt @@ -0,0 +1,122 @@ +RazorDocument - [0..131)::131 - [

                        @do { var foo = bar;

                        Foo

                        foo++; } while (foo);

                        @do { var foo = bar;

                        Foo

                        foo++; } while (foo);

                        ] + MarkupBlock - [0..131)::131 + MarkupTagHelperElement - [0..65)::65 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [3..61)::58 + CSharpTransition - [3..4)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [4..23)::19 - [do { var foo = bar;] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + MarkupBlock - [23..35)::12 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [24..34)::10 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [24..27)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [27..30)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTagHelperEndTag - [30..34)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [35..61)::26 - [foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTagHelperEndTag - [61..65)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [65..66)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [66..131)::65 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [66..69)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + CSharpCodeBlock - [69..127)::58 + CSharpTransition - [69..70)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [70..89)::19 - [do { var foo = bar;] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + MarkupBlock - [89..101)::12 + MarkupTextLiteral - [89..90)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [90..100)::10 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [90..93)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [93..96)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTagHelperEndTag - [96..100)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [100..101)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [101..127)::26 - [foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTagHelperEndTag - [127..131)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.tspans.txt new file mode 100644 index 0000000000..eef88691cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks6.tspans.txt @@ -0,0 +1,4 @@ +TagHelper span at (0:0,0 [65] ) - ptaghelper +TagHelper span at (24:0,24 [10] ) - ptaghelper +TagHelper span at (66:0,66 [65] ) - ptaghelper +TagHelper span at (90:0,90 [10] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.cspans.txt new file mode 100644 index 0000000000..289b98f67f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Expression block at (9:0,9 [13] ) +Code span at (10:0,10 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (9:0,9 [13] ) +Markup span at (22:0,22 [8] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [8] ) +Markup span at (30:0,30 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) +Transition span at (40:0,40 [1] ) (Accepts:None) - Parent: Expression block at (40:0,40 [13] ) +Code span at (41:0,41 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (40:0,40 [13] ) +Markup span at (53:0,53 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) +Markup span at (64:0,64 [9] ) (Accepts:Any) - Parent: Tag block at (64:0,64 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.stree.txt new file mode 100644 index 0000000000..5aa23f352a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..77)::77 - [

                        Hello @DateTime.Nowinside of @DateTime.Now strong tag

                        ] + MarkupBlock - [0..77)::77 + MarkupTagHelperElement - [0..77)::77 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..9)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + CSharpCodeBlock - [9..22)::13 + CSharpImplicitExpression - [9..22)::13 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [10..22)::12 + CSharpCodeBlock - [10..22)::12 + CSharpExpressionLiteral - [10..22)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupElement - [22..73)::51 + MarkupStartTag - [22..30)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [30..40)::10 - [inside of ] - Gen - SpanEditHandler;Accepts:Any + Text;[inside]; + Whitespace;[ ]; + Text;[of]; + Whitespace;[ ]; + CSharpCodeBlock - [40..53)::13 + CSharpImplicitExpression - [40..53)::13 + CSharpTransition - [40..41)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [41..53)::12 + CSharpCodeBlock - [41..53)::12 + CSharpExpressionLiteral - [41..53)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [53..64)::11 - [ strong tag] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[strong]; + Whitespace;[ ]; + Text;[tag]; + MarkupEndTag - [64..73)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [73..77)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.tspans.txt new file mode 100644 index 0000000000..fdd25b54f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [77] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.cspans.txt new file mode 100644 index 0000000000..d03e66d5c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [167] ) +Transition span at (9:0,9 [1] ) (Accepts:None) - Parent: Statement block at (9:0,9 [58] ) +Code span at (10:0,10 [19] ) (Accepts:Any) - Parent: Statement block at (9:0,9 [58] ) +Markup span at (29:0,29 [1] ) (Accepts:Any) - Parent: Markup block at (29:0,29 [12] ) +Markup span at (33:0,33 [3] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [10] ) +Markup span at (40:0,40 [1] ) (Accepts:None) - Parent: Markup block at (29:0,29 [12] ) +Code span at (41:0,41 [26] ) (Accepts:None) - Parent: Statement block at (9:0,9 [58] ) +Markup span at (67:0,67 [8] ) (Accepts:Any) - Parent: Tag block at (67:0,67 [8] ) +Markup span at (75:0,75 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [167] ) +Transition span at (85:0,85 [1] ) (Accepts:None) - Parent: Statement block at (85:0,85 [58] ) +Code span at (86:0,86 [19] ) (Accepts:Any) - Parent: Statement block at (85:0,85 [58] ) +Markup span at (105:0,105 [1] ) (Accepts:Any) - Parent: Markup block at (105:0,105 [12] ) +Markup span at (109:0,109 [3] ) (Accepts:Any) - Parent: Tag block at (106:0,106 [10] ) +Markup span at (116:0,116 [1] ) (Accepts:None) - Parent: Markup block at (105:0,105 [12] ) +Code span at (117:0,117 [26] ) (Accepts:None) - Parent: Statement block at (85:0,85 [58] ) +Markup span at (143:0,143 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [167] ) +Markup span at (154:0,154 [9] ) (Accepts:Any) - Parent: Tag block at (154:0,154 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.stree.txt new file mode 100644 index 0000000000..a471bacbf0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.stree.txt @@ -0,0 +1,133 @@ +RazorDocument - [0..167)::167 - [

                        Hello @do { var foo = bar;

                        Foo

                        foo++; } while (foo);inside of @do { var foo = bar;

                        Foo

                        foo++; } while (foo); strong tag

                        ] + MarkupBlock - [0..167)::167 + MarkupTagHelperElement - [0..167)::167 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..9)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + CSharpCodeBlock - [9..67)::58 + CSharpTransition - [9..10)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [10..29)::19 - [do { var foo = bar;] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + MarkupBlock - [29..41)::12 + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [30..40)::10 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [30..33)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [33..36)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTagHelperEndTag - [36..40)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [41..67)::26 - [foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupElement - [67..163)::96 + MarkupStartTag - [67..75)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [75..85)::10 - [inside of ] - Gen - SpanEditHandler;Accepts:Any + Text;[inside]; + Whitespace;[ ]; + Text;[of]; + Whitespace;[ ]; + CSharpCodeBlock - [85..143)::58 + CSharpTransition - [85..86)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementLiteral - [86..105)::19 - [do { var foo = bar;] - Gen - SpanEditHandler;Accepts:Any + Keyword;[do]; + Whitespace;[ ]; + LeftBrace;[{]; + Whitespace;[ ]; + Identifier;[var]; + Whitespace;[ ]; + Identifier;[foo]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + Identifier;[bar]; + Semicolon;[;]; + MarkupBlock - [105..117)::12 + MarkupTextLiteral - [105..106)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [106..116)::10 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [106..109)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [109..112)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupTagHelperEndTag - [112..116)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [116..117)::1 - [ ] - Gen - SpanEditHandler;Accepts:None + Whitespace;[ ]; + CSharpStatementLiteral - [117..143)::26 - [foo++; } while (foo);] - Gen - SpanEditHandler;Accepts:None + Identifier;[foo]; + Increment;[++]; + Semicolon;[;]; + Whitespace;[ ]; + RightBrace;[}]; + Whitespace;[ ]; + Keyword;[while]; + Whitespace;[ ]; + LeftParenthesis;[(]; + Identifier;[foo]; + LessThan;[<]; + Identifier;[bar]; + GreaterThan;[>]; + RightParenthesis;[)]; + Semicolon;[;]; + MarkupTextLiteral - [143..154)::11 - [ strong tag] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[strong]; + Whitespace;[ ]; + Text;[tag]; + MarkupEndTag - [154..163)::9 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [163..167)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.tspans.txt new file mode 100644 index 0000000000..f972911c7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesComplexTagHelperTagBlocks8.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [167] ) - ptaghelper +TagHelper span at (30:0,30 [10] ) - ptaghelper +TagHelper span at (106:0,106 [10] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.cspans.txt new file mode 100644 index 0000000000..ddb3c37d48 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [66] ) +Markup span at (35:0,35 [8] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (43:0,43 [2] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (45:0,45 [5] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (50:0,50 [3] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (53:0,53 [3] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.stree.txt new file mode 100644 index 0000000000..0b1d263b98 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..66)::66 - [

                        ] + MarkupBlock - [0..66)::66 + MarkupTagHelperElement - [0..66)::66 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..62)::62 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class=" foo"] + MarkupTextLiteral - [2..8)::6 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..13)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [15..23)::8 + MarkupLiteralAttributeValue - [15..23)::8 - [ foo] + MarkupTextLiteral - [15..20)::5 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..23)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [24..57)::33 - style - DoubleQuotes - Unbound - [ style=" color : red ; "] + MarkupTextLiteral - [24..28)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..33)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [34..35)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [35..56)::21 + MarkupLiteralAttributeValue - [35..43)::8 - [ color] + MarkupTextLiteral - [35..38)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [38..43)::5 - [color] - Gen - SpanEditHandler;Accepts:Any + Text;[color]; + MarkupLiteralAttributeValue - [43..45)::2 - [ :] + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [44..45)::1 - [:] - Gen - SpanEditHandler;Accepts:Any + Text;[:]; + MarkupLiteralAttributeValue - [45..50)::5 - [ red] + MarkupTextLiteral - [45..47)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [47..50)::3 - [red] - Gen - SpanEditHandler;Accepts:Any + Text;[red]; + MarkupLiteralAttributeValue - [50..53)::3 - [ ;] + MarkupTextLiteral - [50..52)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [52..53)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; + MarkupLiteralAttributeValue - [53..56)::3 - [ ] + MarkupTextLiteral - [53..56)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [56..57)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [57..61)::4 + MarkupTextLiteral - [57..61)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [62..66)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.tspans.txt new file mode 100644 index 0000000000..ef54ffee1b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [66] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.cspans.txt new file mode 100644 index 0000000000..9a63e4f2b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) +Markup span at (35:0,35 [8] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (43:0,43 [2] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (45:0,45 [5] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (50:0,50 [3] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (53:0,53 [3] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [21] ) +Markup span at (62:0,62 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.stree.txt new file mode 100644 index 0000000000..002409e66b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.stree.txt @@ -0,0 +1,69 @@ +RazorDocument - [0..77)::77 - [

                        Hello World

                        ] + MarkupBlock - [0..77)::77 + MarkupTagHelperElement - [0..77)::77 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..62)::62 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class=" foo"] + MarkupTextLiteral - [2..8)::6 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..13)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [15..23)::8 + MarkupLiteralAttributeValue - [15..23)::8 - [ foo] + MarkupTextLiteral - [15..20)::5 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..23)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [24..57)::33 - style - DoubleQuotes - Unbound - [ style=" color : red ; "] + MarkupTextLiteral - [24..28)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..33)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [34..35)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [35..56)::21 + MarkupLiteralAttributeValue - [35..43)::8 - [ color] + MarkupTextLiteral - [35..38)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [38..43)::5 - [color] - Gen - SpanEditHandler;Accepts:Any + Text;[color]; + MarkupLiteralAttributeValue - [43..45)::2 - [ :] + MarkupTextLiteral - [43..44)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [44..45)::1 - [:] - Gen - SpanEditHandler;Accepts:Any + Text;[:]; + MarkupLiteralAttributeValue - [45..50)::5 - [ red] + MarkupTextLiteral - [45..47)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [47..50)::3 - [red] - Gen - SpanEditHandler;Accepts:Any + Text;[red]; + MarkupLiteralAttributeValue - [50..53)::3 - [ ;] + MarkupTextLiteral - [50..52)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [52..53)::1 - [;] - Gen - SpanEditHandler;Accepts:Any + Text;[;]; + MarkupLiteralAttributeValue - [53..56)::3 - [ ] + MarkupTextLiteral - [53..56)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [56..57)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [57..61)::4 + MarkupTextLiteral - [57..61)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [62..73)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [73..77)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.tspans.txt new file mode 100644 index 0000000000..fdd25b54f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [77] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.cspans.txt new file mode 100644 index 0000000000..ac0c044abb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (14:0,14 [6] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [8] ) +Markup span at (20:0,20 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [8] ) +Markup span at (25:0,25 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [34] ) +Markup span at (34:0,34 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [73] ) +Markup span at (48:0,48 [12] ) (Accepts:Any) - Parent: Markup block at (48:0,48 [13] ) +Markup span at (60:0,60 [1] ) (Accepts:Any) - Parent: Markup block at (48:0,48 [13] ) +Markup span at (64:0,64 [5] ) (Accepts:Any) - Parent: Tag block at (35:0,35 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.stree.txt new file mode 100644 index 0000000000..82112b38b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.stree.txt @@ -0,0 +1,72 @@ +RazorDocument - [0..73)::73 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..73)::73 + MarkupTagHelperElement - [0..34)::34 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..25)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..23)::21 - class - DoubleQuotes - Unbound - [ class=" foo "] + MarkupTextLiteral - [2..7)::5 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [14..22)::8 + MarkupLiteralAttributeValue - [14..20)::6 - [ foo] + MarkupTextLiteral - [14..17)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..20)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupLiteralAttributeValue - [20..22)::2 - [ ] + MarkupTextLiteral - [20..22)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [23..24)::1 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [25..30)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [30..34)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [35..73)::38 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [35..64)::29 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [37..62)::25 - style - DoubleQuotes - Unbound - [ style=" color:red; "] + MarkupTextLiteral - [37..41)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [41..46)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [47..48)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [48..61)::13 + MarkupLiteralAttributeValue - [48..60)::12 - [ color:red;] + MarkupTextLiteral - [48..50)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [50..60)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupLiteralAttributeValue - [60..61)::1 - [ ] + MarkupTextLiteral - [60..61)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [61..62)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [62..63)::1 + MarkupTextLiteral - [62..63)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [64..69)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [69..73)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.tspans.txt new file mode 100644 index 0000000000..ac76be0a56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesOddlySpacedTagHelperTagBlocks3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [34] ) - ptaghelper +TagHelper span at (35:0,35 [38] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.stree.txt new file mode 100644 index 0000000000..3c6c5782ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..7)::7 - [

                        ] + MarkupBlock - [0..7)::7 + MarkupTagHelperElement - [0..7)::7 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [3..7)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.tspans.txt new file mode 100644 index 0000000000..8c084941d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.cspans.txt new file mode 100644 index 0000000000..f82aba421e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.stree.txt new file mode 100644 index 0000000000..1cad064338 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..18)::18 - [

                        Hello World

                        ] + MarkupBlock - [0..18)::18 + MarkupTagHelperElement - [0..18)::18 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..14)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [14..18)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.tspans.txt new file mode 100644 index 0000000000..952b7c9df9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [18] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.cspans.txt new file mode 100644 index 0000000000..bae5d9e829 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (3:0,3 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [12] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (16:0,16 [5] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.stree.txt new file mode 100644 index 0000000000..a1430c006e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..25)::25 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..25)::25 + MarkupTagHelperElement - [0..12)::12 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..8)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [8..12)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [13..25)::12 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [13..16)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [16..21)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [21..25)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.tspans.txt new file mode 100644 index 0000000000..9c65b6e8ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [12] ) - ptaghelper +TagHelper span at (13:0,13 [12] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.cspans.txt new file mode 100644 index 0000000000..6d458bf721 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (3:0,3 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [56] ) +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (23:0,23 [20] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [56] ) +Markup span at (43:0,43 [9] ) (Accepts:Any) - Parent: Tag block at (43:0,43 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.stree.txt new file mode 100644 index 0000000000..c49a39a260 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..56)::56 - [

                        Hello World inside of strong tag

                        ] + MarkupBlock - [0..56)::56 + MarkupTagHelperElement - [0..56)::56 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..15)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + MarkupElement - [15..52)::37 + MarkupStartTag - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [23..43)::20 - [inside of strong tag] - Gen - SpanEditHandler;Accepts:Any + Text;[inside]; + Whitespace;[ ]; + Text;[of]; + Whitespace;[ ]; + Text;[strong]; + Whitespace;[ ]; + Text;[tag]; + MarkupEndTag - [43..52)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [52..56)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.tspans.txt new file mode 100644 index 0000000000..43d407d913 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [56] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.cspans.txt new file mode 100644 index 0000000000..d972e4a4f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.cspans.txt @@ -0,0 +1 @@ +Markup span at (8:0,8 [14] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.stree.txt new file mode 100644 index 0000000000..f5a2d95995 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [0..8)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.tspans.txt new file mode 100644 index 0000000000..8c61f52583 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - scripttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.cspans.txt new file mode 100644 index 0000000000..20e0cf45b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.cspans.txt @@ -0,0 +1 @@ +Markup span at (8:0,8 [23] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.stree.txt new file mode 100644 index 0000000000..e51cba2264 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..40)::40 - [] + MarkupBlock - [0..40)::40 + MarkupTagHelperElement - [0..40)::40 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [0..8)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.tspans.txt new file mode 100644 index 0000000000..ac63486204 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [40] ) - scripttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.cspans.txt new file mode 100644 index 0000000000..8cebd4fdd9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (8:0,8 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [29] ) +Markup span at (29:0,29 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [53] ) +Markup span at (38:0,38 [5] ) (Accepts:Any) - Parent: Tag block at (33:0,33 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.stree.txt new file mode 100644 index 0000000000..2f3212ad0a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..53)::53 - [

                        World

                        ] + MarkupBlock - [0..53)::53 + MarkupTagHelperElement - [0..29)::29 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [0..8)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [30..53)::23 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [30..33)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [33..49)::16 - div[StartTagAndEndTag] - divtaghelper + MarkupTagHelperStartTag - [33..38)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [38..43)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [43..49)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [49..53)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.tspans.txt new file mode 100644 index 0000000000..a253e4c493 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers3.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [29] ) - scripttaghelper +TagHelper span at (30:0,30 [23] ) - ptaghelper +TagHelper span at (33:0,33 [16] ) - divtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.cspans.txt new file mode 100644 index 0000000000..a94da0fb8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (8:0,8 [22] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [39] ) +Markup span at (39:0,39 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [75] ) +Markup span at (48:0,48 [18] ) (Accepts:Any) - Parent: Tag block at (40:0,40 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.stree.txt new file mode 100644 index 0000000000..ad304014f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..75)::75 - [ ] + MarkupBlock - [0..75)::75 + MarkupTagHelperElement - [0..39)::39 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [0..8)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTextLiteral - [39..40)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [40..75)::35 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [40..48)::8 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.tspans.txt new file mode 100644 index 0000000000..e884343e22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [39] ) - scripttaghelper +TagHelper span at (40:0,40 [35] ) - scripttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers5.cspans.txt new file mode 100644 index 0000000000..76b38b02c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers5.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [41] ) +Markup span at (27:0,27 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers5.stree.txt new file mode 100644 index 0000000000..8a9c34d8bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers5.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..41)::41 - [ World

                        ] + MarkupBlock - [0..67)::67 + MarkupTagHelperElement - [0..67)::67 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..9)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + MarkupTagHelperElement - [9..57)::48 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [9..48)::39 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTextLiteral - [57..63)::6 - [ World] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [63..67)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers6.tspans.txt new file mode 100644 index 0000000000..928d196eb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers6.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [67] ) - ptaghelper +TagHelper span at (9:0,9 [48] ) - scripttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.cspans.txt new file mode 100644 index 0000000000..572d8641d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) +Markup span at (24:0,24 [1] ) (Accepts:None) - Parent: Markup block at (24:0,24 [2] ) +Markup span at (25:0,25 [1] ) (Accepts:None) - Parent: Markup block at (24:0,24 [2] ) +Markup span at (26:0,26 [11] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [13] ) +Markup span at (46:0,46 [10] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [58] ) +Markup span at (67:0,67 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [77] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.stree.txt new file mode 100644 index 0000000000..e6e4a4c0ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..77)::77 - [

                        Hello World

                        ] + MarkupBlock - [0..77)::77 + MarkupTagHelperElement - [0..77)::77 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..9)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + MarkupTagHelperElement - [9..67)::58 - script[StartTagAndEndTag] - scripttaghelper + MarkupTagHelperStartTag - [9..58)::49 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTextLiteral - [67..73)::6 - [ World] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [73..77)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.tspans.txt new file mode 100644 index 0000000000..fcf8bee101 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesScriptTagHelpers7.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [77] ) - ptaghelper +TagHelper span at (9:0,9 [58] ) - scripttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.cspans.txt new file mode 100644 index 0000000000..e4af93f808 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [36] ) +Markup span at (22:0,22 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [36] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.stree.txt new file mode 100644 index 0000000000..8c00dcb65d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..36)::36 - [

                        ] + MarkupBlock - [0..36)::36 + MarkupTagHelperElement - [0..36)::36 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [0..36)::36 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [14..33)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..20)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [22..32)::10 + MarkupLiteralAttributeValue - [22..32)::10 - [color:red;] + MarkupTextLiteral - [22..32)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [33..34)::1 + MarkupTextLiteral - [33..34)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.tspans.txt new file mode 100644 index 0000000000..c32a52d977 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [36] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.cspans.txt new file mode 100644 index 0000000000..3b11382a00 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [55] ) +Markup span at (19:0,19 [3] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [36] ) +Markup span at (31:0,31 [10] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [36] ) +Markup span at (45:0,45 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [55] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.stree.txt new file mode 100644 index 0000000000..ed266cc908 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..55)::55 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..55)::55 + MarkupTagHelperElement - [0..55)::55 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..9)::6 - [Hello ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + MarkupTagHelperElement - [9..45)::36 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [9..45)::36 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [11..23)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [11..12)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [12..17)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [19..22)::3 + MarkupLiteralAttributeValue - [19..22)::3 - [foo] + MarkupTextLiteral - [19..22)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [22..23)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [23..42)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..29)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [31..41)::10 + MarkupLiteralAttributeValue - [31..41)::10 - [color:red;] + MarkupTextLiteral - [31..41)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [41..42)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [42..43)::1 + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [45..51)::6 - [ World] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [51..55)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.tspans.txt new file mode 100644 index 0000000000..6dc6c9b953 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [55] ) - ptaghelper +TagHelper span at (9:0,9 [36] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.cspans.txt new file mode 100644 index 0000000000..a55ddcf08a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [17] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) +Markup span at (33:0,33 [10] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [24] ) +Markup span at (47:0,47 [5] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [52] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.stree.txt new file mode 100644 index 0000000000..af795e12c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..52)::52 - [Hello

                        World] + MarkupBlock - [0..52)::52 + MarkupTextLiteral - [0..5)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperElement - [5..22)::17 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [5..22)::17 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [7..19)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..13)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [15..18)::3 + MarkupLiteralAttributeValue - [15..18)::3 - [foo] + MarkupTextLiteral - [15..18)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [23..47)::24 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [23..47)::24 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [25..44)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..31)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [33..43)::10 + MarkupLiteralAttributeValue - [33..43)::10 - [color:red;] + MarkupTextLiteral - [33..43)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [43..44)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [44..45)::1 + MarkupTextLiteral - [44..45)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [47..52)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.tspans.txt new file mode 100644 index 0000000000..9cf7822faf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (5:0,5 [17] ) - ptaghelper +TagHelper span at (23:0,23 [24] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.cspans.txt new file mode 100644 index 0000000000..ecfdc446c7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [38] ) +Markup span at (22:0,22 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.stree.txt new file mode 100644 index 0000000000..29e97ff837 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..38)::38 - [

                        ] + MarkupBlock - [0..38)::38 + MarkupTagHelperElement - [0..38)::38 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..34)::34 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [14..33)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..20)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [22..32)::10 + MarkupLiteralAttributeValue - [22..32)::10 - [color:red;] + MarkupTextLiteral - [22..32)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [34..38)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.tspans.txt new file mode 100644 index 0000000000..3cc3264682 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [38] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.cspans.txt new file mode 100644 index 0000000000..9f93b41526 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [49] ) +Markup span at (22:0,22 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [49] ) +Markup span at (34:0,34 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.stree.txt new file mode 100644 index 0000000000..9a4a238ea7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..49)::49 - [

                        Hello World

                        ] + MarkupBlock - [0..49)::49 + MarkupTagHelperElement - [0..49)::49 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..34)::34 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [14..33)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..20)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [22..32)::10 + MarkupLiteralAttributeValue - [22..32)::10 - [color:red;] + MarkupTextLiteral - [22..32)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [34..45)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [45..49)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.tspans.txt new file mode 100644 index 0000000000..f12231fbd7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [49] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.cspans.txt new file mode 100644 index 0000000000..9663987bab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) +Markup span at (15:0,15 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [56] ) +Markup span at (35:0,35 [10] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [31] ) +Markup span at (47:0,47 [5] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.stree.txt new file mode 100644 index 0000000000..ddb55a3923 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.stree.txt @@ -0,0 +1,56 @@ +RazorDocument - [0..56)::56 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..56)::56 + MarkupTagHelperElement - [0..24)::24 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [15..20)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [20..24)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [25..56)::31 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [25..47)::22 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [27..46)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..33)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [34..35)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [35..45)::10 + MarkupLiteralAttributeValue - [35..45)::10 - [color:red;] + MarkupTextLiteral - [35..45)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [45..46)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [47..52)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [52..56)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.tspans.txt new file mode 100644 index 0000000000..75b14aa3c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [24] ) - ptaghelper +TagHelper span at (25:0,25 [31] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.cspans.txt new file mode 100644 index 0000000000..944a88693b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [99] ) +Markup span at (22:0,22 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [99] ) +Markup span at (34:0,34 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [99] ) +Markup span at (46:0,46 [7] ) (Accepts:Any) - Parent: Tag block at (46:0,46 [20] ) +Markup span at (53:0,53 [8] ) (Accepts:Any) - Parent: Markup block at (53:0,53 [12] ) +Markup span at (61:0,61 [3] ) (Accepts:Any) - Parent: Markup block at (53:0,53 [12] ) +Markup span at (64:0,64 [1] ) (Accepts:Any) - Parent: Markup block at (53:0,53 [12] ) +Markup span at (65:0,65 [1] ) (Accepts:Any) - Parent: Tag block at (46:0,46 [20] ) +Markup span at (66:0,66 [20] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [99] ) +Markup span at (86:0,86 [9] ) (Accepts:Any) - Parent: Tag block at (86:0,86 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.stree.txt new file mode 100644 index 0000000000..591365bb3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.stree.txt @@ -0,0 +1,77 @@ +RazorDocument - [0..99)::99 - [

                        Hello World inside of strong tag

                        ] + MarkupBlock - [0..99)::99 + MarkupTagHelperElement - [0..99)::99 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..34)::34 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="foo"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [14..33)::19 - style - DoubleQuotes - Unbound - [ style="color:red;"] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..20)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [22..32)::10 + MarkupLiteralAttributeValue - [22..32)::10 - [color:red;] + MarkupTextLiteral - [22..32)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [34..46)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + MarkupElement - [46..95)::49 + MarkupStartTag - [46..66)::20 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupAttributeBlock - [53..65)::12 - [ class="foo"] + MarkupTextLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [54..59)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [60..61)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [61..64)::3 + MarkupLiteralAttributeValue - [61..64)::3 - [foo] + MarkupTextLiteral - [61..64)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [64..65)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [66..86)::20 - [inside of strong tag] - Gen - SpanEditHandler;Accepts:Any + Text;[inside]; + Whitespace;[ ]; + Text;[of]; + Whitespace;[ ]; + Text;[strong]; + Whitespace;[ ]; + Text;[tag]; + MarkupEndTag - [86..95)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [95..99)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.tspans.txt new file mode 100644 index 0000000000..06bcd7e03e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [99] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.cspans.txt new file mode 100644 index 0000000000..f08a9b491a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [56] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (41:0,41 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [56] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.stree.txt new file mode 100644 index 0000000000..2ce0880bef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..56)::56 - [

                        ] + MarkupBlock - [0..56)::56 + MarkupTagHelperElement - [0..56)::56 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..52)::52 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTagHelperAttribute - [12..34)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..20)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [21..34)::13 + MarkupDynamicAttributeValue - [21..34)::13 - [@DateTime.Now] + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperAttribute - [34..51)::17 - style - DoubleQuotes - Unbound - [ style=color:red;] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..40)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTagHelperAttributeValue - [41..51)::10 + MarkupLiteralAttributeValue - [41..51)::10 - [color:red;] + MarkupTextLiteral - [41..51)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [52..56)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.tspans.txt new file mode 100644 index 0000000000..43d407d913 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [56] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.cspans.txt new file mode 100644 index 0000000000..a52e2d29cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [67] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (41:0,41 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [67] ) +Markup span at (52:0,52 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [67] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.stree.txt new file mode 100644 index 0000000000..e60c28b9dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.stree.txt @@ -0,0 +1,55 @@ +RazorDocument - [0..67)::67 - [

                        Hello World

                        ] + MarkupBlock - [0..67)::67 + MarkupTagHelperElement - [0..67)::67 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..52)::52 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTagHelperAttribute - [12..34)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..20)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [21..34)::13 + MarkupDynamicAttributeValue - [21..34)::13 - [@DateTime.Now] + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperAttribute - [34..51)::17 - style - DoubleQuotes - Unbound - [ style=color:red;] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..40)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTagHelperAttributeValue - [41..51)::10 + MarkupLiteralAttributeValue - [41..51)::10 - [color:red;] + MarkupTextLiteral - [41..51)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + CloseAngle;[>]; + MarkupTextLiteral - [52..63)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [63..67)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.tspans.txt new file mode 100644 index 0000000000..fc4df1931c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [67] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.cspans.txt new file mode 100644 index 0000000000..9b90d7819d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [69] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (41:0,41 [5] ) (Accepts:Any) - Parent: Markup block at (41:0,41 [12] ) +Markup span at (46:0,46 [1] ) (Accepts:None) - Parent: Markup block at (46:0,46 [2] ) +Markup span at (47:0,47 [1] ) (Accepts:None) - Parent: Markup block at (46:0,46 [2] ) +Markup span at (48:0,48 [5] ) (Accepts:Any) - Parent: Markup block at (41:0,41 [12] ) +Markup span at (54:0,54 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [69] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.stree.txt new file mode 100644 index 0000000000..613e9fd565 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.stree.txt @@ -0,0 +1,63 @@ +RazorDocument - [0..69)::69 - [

                        Hello World

                        ] + MarkupBlock - [0..69)::69 + MarkupTagHelperElement - [0..69)::69 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..54)::54 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTagHelperAttribute - [12..34)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..20)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [21..34)::13 + MarkupDynamicAttributeValue - [21..34)::13 - [@DateTime.Now] + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperAttribute - [34..53)::19 - style - DoubleQuotes - Unbound - [ style=color@@:red;] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..40)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTagHelperAttributeValue - [41..53)::12 + MarkupLiteralAttributeValue - [41..46)::5 - [color] + MarkupTextLiteral - [41..46)::5 - [color] - Gen - SpanEditHandler;Accepts:Any + Text;[color]; + MarkupBlock - [46..48)::2 + MarkupTextLiteral - [46..47)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [47..48)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [48..53)::5 - [:red;] + MarkupTextLiteral - [48..53)::5 - [:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[:red;]; + CloseAngle;[>]; + MarkupTextLiteral - [54..65)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [65..69)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.tspans.txt new file mode 100644 index 0000000000..ff9e419de7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [69] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.cspans.txt new file mode 100644 index 0000000000..ed2cf9ddf2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [44] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (35:0,35 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [44] ) +Markup span at (44:0,44 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [96] ) +Markup span at (54:0,54 [10] ) (Accepts:Any) - Parent: Tag block at (45:0,45 [51] ) +Transition span at (73:0,73 [1] ) (Accepts:None) - Parent: Expression block at (73:0,73 [13] ) +Code span at (74:0,74 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (73:0,73 [13] ) +Markup span at (87:0,87 [5] ) (Accepts:Any) - Parent: Tag block at (45:0,45 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.stree.txt new file mode 100644 index 0000000000..146dc1b816 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.stree.txt @@ -0,0 +1,86 @@ +RazorDocument - [0..96)::96 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..96)::96 + MarkupTagHelperElement - [0..44)::44 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..35)::35 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTagHelperAttribute - [12..34)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..20)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [21..34)::13 + MarkupDynamicAttributeValue - [21..34)::13 - [@DateTime.Now] + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + CloseAngle;[>]; + MarkupTextLiteral - [35..40)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [40..44)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [44..45)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [45..96)::51 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [45..87)::42 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [47..64)::17 - style - DoubleQuotes - Unbound - [ style=color:red;] + MarkupTextLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [48..53)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTagHelperAttributeValue - [54..64)::10 + MarkupLiteralAttributeValue - [54..64)::10 - [color:red;] + MarkupTextLiteral - [54..64)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + MarkupTagHelperAttribute - [64..86)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [64..65)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [65..72)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [73..86)::13 + MarkupDynamicAttributeValue - [73..86)::13 - [@DateTime.Now] + GenericBlock - [73..86)::13 + CSharpCodeBlock - [73..86)::13 + CSharpImplicitExpression - [73..86)::13 + CSharpTransition - [73..74)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [74..86)::12 + CSharpCodeBlock - [74..86)::12 + CSharpExpressionLiteral - [74..86)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + CloseAngle;[>]; + MarkupTextLiteral - [87..92)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [92..96)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.tspans.txt new file mode 100644 index 0000000000..bddced97ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [44] ) - ptaghelper +TagHelper span at (45:0,45 [51] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.cspans.txt new file mode 100644 index 0000000000..2b1a126add --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (9:0,9 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [117] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (41:0,41 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [117] ) +Markup span at (52:0,52 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [117] ) +Markup span at (64:0,64 [7] ) (Accepts:Any) - Parent: Tag block at (64:0,64 [20] ) +Markup span at (71:0,71 [8] ) (Accepts:Any) - Parent: Markup block at (71:0,71 [12] ) +Markup span at (79:0,79 [3] ) (Accepts:Any) - Parent: Markup block at (71:0,71 [12] ) +Markup span at (82:0,82 [1] ) (Accepts:Any) - Parent: Markup block at (71:0,71 [12] ) +Markup span at (83:0,83 [1] ) (Accepts:Any) - Parent: Tag block at (64:0,64 [20] ) +Markup span at (84:0,84 [20] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [117] ) +Markup span at (104:0,104 [9] ) (Accepts:Any) - Parent: Tag block at (104:0,104 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.stree.txt new file mode 100644 index 0000000000..a84353c61f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.stree.txt @@ -0,0 +1,88 @@ +RazorDocument - [0..117)::117 - [

                        Hello World inside of strong tag

                        ] + MarkupBlock - [0..117)::117 + MarkupTagHelperElement - [0..117)::117 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..52)::52 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class - DoubleQuotes - Unbound - [ class=foo] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..12)::3 + MarkupLiteralAttributeValue - [9..12)::3 - [foo] + MarkupTextLiteral - [9..12)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTagHelperAttribute - [12..34)::22 - dynamic - DoubleQuotes - Unbound - [ dynamic=@DateTime.Now] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..20)::7 - [dynamic] - Gen - SpanEditHandler;Accepts:Any + Text;[dynamic]; + Equals;[=]; + MarkupTagHelperAttributeValue - [21..34)::13 + MarkupDynamicAttributeValue - [21..34)::13 - [@DateTime.Now] + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTagHelperAttribute - [34..51)::17 - style - DoubleQuotes - Unbound - [ style=color:red;] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..40)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTagHelperAttributeValue - [41..51)::10 + MarkupLiteralAttributeValue - [41..51)::10 - [color:red;] + MarkupTextLiteral - [41..51)::10 - [color:red;] - Gen - SpanEditHandler;Accepts:Any + Text;[color:red;]; + CloseAngle;[>]; + MarkupTextLiteral - [52..64)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + MarkupElement - [64..113)::49 + MarkupStartTag - [64..84)::20 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupAttributeBlock - [71..83)::12 - [ class="foo"] + MarkupTextLiteral - [71..72)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [72..77)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [78..79)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [79..82)::3 + MarkupLiteralAttributeValue - [79..82)::3 - [foo] + MarkupTextLiteral - [79..82)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [82..83)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [84..104)::20 - [inside of strong tag] - Gen - SpanEditHandler;Accepts:Any + Text;[inside]; + Whitespace;[ ]; + Text;[of]; + Whitespace;[ ]; + Text;[strong]; + Whitespace;[ ]; + Text;[tag]; + MarkupEndTag - [104..113)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [113..117)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.tspans.txt new file mode 100644 index 0000000000..dc61572b3f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [117] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.cspans.txt new file mode 100644 index 0000000000..92e6c778c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.stree.txt new file mode 100644 index 0000000000..812b156152 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..16)::16 - [

                        ] + MarkupBlock - [0..16)::16 + MarkupTagHelperElement - [0..16)::16 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..12)::12 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..11)::9 - class - DoubleQuotes - Unbound - [ class=""] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..10)::0 + MarkupTextLiteral - [10..10)::0 - [] + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [12..16)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.tspans.txt new file mode 100644 index 0000000000..52dba16922 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [16] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.cspans.txt new file mode 100644 index 0000000000..92e6c778c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.stree.txt new file mode 100644 index 0000000000..1ffbad01be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..16)::16 - [

                        ] + MarkupBlock - [0..16)::16 + MarkupTagHelperElement - [0..16)::16 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..12)::12 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..11)::9 - class - SingleQuotes - Unbound - [ class=''] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..10)::0 + MarkupTextLiteral - [10..10)::0 - [] + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [12..16)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.tspans.txt new file mode 100644 index 0000000000..52dba16922 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [16] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.cspans.txt new file mode 100644 index 0000000000..065cf74b88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.cspans.txt @@ -0,0 +1 @@ +Markup span at (9:0,9 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.stree.txt new file mode 100644 index 0000000000..bf92b6fffc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..14)::14 - [

                        ] + MarkupBlock - [0..14)::14 + MarkupTagHelperElement - [0..14)::14 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..10)::10 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..9)::7 - class - DoubleQuotes - Unbound - [ class=] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTagHelperAttributeValue - [9..9)::0 + MarkupTextLiteral - [9..9)::0 - [] + CloseAngle;[>]; + MarkupTagHelperEndTag - [10..14)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.tspans.txt new file mode 100644 index 0000000000..d4769a773a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [14] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.cspans.txt new file mode 100644 index 0000000000..eeee563c5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.stree.txt new file mode 100644 index 0000000000..6986ffec04 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..33)::33 - [

                        ] + MarkupBlock - [0..33)::33 + MarkupTagHelperElement - [0..33)::33 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [0..33)::33 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class1 - SingleQuotes - Unbound - [ class1=''] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..9)::6 - [class1] - Gen - SpanEditHandler;Accepts:Any + Text;[class1]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [11..11)::0 + MarkupTextLiteral - [11..11)::0 - [] + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [12..20)::8 - class2 - DoubleQuotes - Unbound - [ class2=] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..19)::6 - [class2] - Gen - SpanEditHandler;Accepts:Any + Text;[class2]; + Equals;[=]; + MarkupTagHelperAttributeValue - [20..20)::0 + MarkupTextLiteral - [20..20)::0 - [] + MarkupTagHelperAttribute - [20..30)::10 - class3 - DoubleQuotes - Unbound - [ class3=""] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..27)::6 - [class3] - Gen - SpanEditHandler;Accepts:Any + Text;[class3]; + Equals;[=]; + MarkupTextLiteral - [28..29)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [29..29)::0 + MarkupTextLiteral - [29..29)::0 - [] + MarkupTextLiteral - [29..30)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [30..31)::1 + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.tspans.txt new file mode 100644 index 0000000000..d6131fed67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [33] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.cspans.txt new file mode 100644 index 0000000000..7b54ebc00d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.stree.txt new file mode 100644 index 0000000000..eb17396a39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..31)::31 - [

                        ] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - p[SelfClosing] - ptaghelper + MarkupTagHelperStartTag - [0..31)::31 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..12)::10 - class1 - SingleQuotes - Unbound - [ class1=''] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..9)::6 - [class1] - Gen - SpanEditHandler;Accepts:Any + Text;[class1]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [11..11)::0 + MarkupTextLiteral - [11..11)::0 - [] + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttribute - [12..21)::9 - class2 - DoubleQuotes - Unbound - [class2=""] + MarkupTextLiteral - [12..18)::6 - [class2] - Gen - SpanEditHandler;Accepts:Any + Text;[class2]; + Equals;[=]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [20..20)::0 + MarkupTextLiteral - [20..20)::0 - [] + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [21..28)::7 - class3 - DoubleQuotes - Unbound - [class3=] + MarkupTextLiteral - [21..27)::6 - [class3] - Gen - SpanEditHandler;Accepts:Any + Text;[class3]; + Equals;[=]; + MarkupTagHelperAttributeValue - [28..28)::0 + MarkupTextLiteral - [28..28)::0 - [] + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.tspans.txt new file mode 100644 index 0000000000..b3437d8dea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsEmptyAttributeTagHelpers5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.cspans.txt new file mode 100644 index 0000000000..2681dbe5c7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Code span at (28:0,28 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.stree.txt new file mode 100644 index 0000000000..0bfd3f50eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..29)::29 - [@{}] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpStatement - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..29)::28 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..28)::26 + MarkupBlock - [2..28)::26 + MarkupTagHelperElement - [2..28)::26 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..28)::26 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..25)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..25)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMiscAttributeContent - [25..26)::1 + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.tspans.txt new file mode 100644 index 0000000000..2af3e60e20 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [26] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.cspans.txt new file mode 100644 index 0000000000..20f962b4cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Code span at (27:0,27 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.diag.txt new file mode 100644 index 0000000000..1fba524ca7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'int-prefix-value' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.stree.txt new file mode 100644 index 0000000000..73a3bdc16a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..28)::28 - [@{}] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + CSharpStatement - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..28)::27 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..27)::25 + MarkupBlock - [2..27)::25 + MarkupTagHelperElement - [2..27)::25 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..27)::25 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..25)::17 - int-prefix-value - Minimized - Bound - [ int-prefix-value] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..25)::16 - [int-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-value]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [27..28)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.tspans.txt new file mode 100644 index 0000000000..0744554d85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [25] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.cspans.txt new file mode 100644 index 0000000000..a9bbc9d9b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.diag.txt new file mode 100644 index 0000000000..f50988eac1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'string-prefix-value' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.stree.txt new file mode 100644 index 0000000000..47c931a035 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupTagHelperElement - [2..31)::29 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..31)::29 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..28)::20 - string-prefix-value - Minimized - Bound - [ string-prefix-value] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..28)::19 - [string-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-value]; + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.tspans.txt new file mode 100644 index 0000000000..2806d5b970 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [29] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.cspans.txt new file mode 100644 index 0000000000..37fd3df813 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Code span at (27:0,27 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (2:0,2 [29] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.diag.txt new file mode 100644 index 0000000000..1fba524ca7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'int-prefix-value' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.stree.txt new file mode 100644 index 0000000000..3635da96eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupTagHelperElement - [2..31)::29 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..31)::29 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..28)::20 - int-prefix-value - SingleQuotes - Bound - [ int-prefix-value=''] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..25)::16 - [int-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [27..27)::0 + CSharpExpressionLiteral - [27..27)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.tspans.txt new file mode 100644 index 0000000000..2806d5b970 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [29] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.cspans.txt new file mode 100644 index 0000000000..dfa5d6b255 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [31] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.stree.txt new file mode 100644 index 0000000000..8695b4af8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..34)::34 - [@{}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupTagHelperElement - [2..33)::31 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..33)::31 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..31)::23 - string-prefix-value - SingleQuotes - Bound - [ string-prefix-value=''] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..28)::19 - [string-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [29..30)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [30..30)::0 + MarkupTextLiteral - [30..30)::0 - [] + MarkupTextLiteral - [30..31)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.tspans.txt new file mode 100644 index 0000000000..8182ed93b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block13.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [31] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.cspans.txt new file mode 100644 index 0000000000..3a6e32aaf1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Code span at (27:0,27 [1] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (2:0,2 [29] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.stree.txt new file mode 100644 index 0000000000..e9db26a2d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..32)::32 - [@{}] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupTagHelperElement - [2..31)::29 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..31)::29 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..29)::21 - int-prefix-value - SingleQuotes - Bound - [ int-prefix-value='3'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..25)::16 - [int-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [27..28)::1 + CSharpExpressionLiteral - [27..28)::1 - [3] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[3]; + MarkupTextLiteral - [28..29)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.tspans.txt new file mode 100644 index 0000000000..2806d5b970 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block14.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [29] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.cspans.txt new file mode 100644 index 0000000000..1b14171eab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (30:0,30 [4] ) (Accepts:Any) - Parent: Markup block at (30:0,30 [11] ) +Markup span at (34:0,34 [7] ) (Accepts:Any) - Parent: Markup block at (30:0,30 [11] ) +Code span at (45:0,45 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (46:0,46 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.stree.txt new file mode 100644 index 0000000000..4a4dac9f5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..46)::46 - [@{}] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpStatement - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..46)::45 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + MarkupBlock - [2..45)::43 + MarkupTagHelperElement - [2..45)::43 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..45)::43 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..42)::34 - string-prefix-value - SingleQuotes - Bound - [ string-prefix-value='some string'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..28)::19 - [string-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [29..30)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [30..41)::11 + MarkupTextLiteral - [30..34)::4 - [some] - Gen - SpanEditHandler;Accepts:Any + Text;[some]; + MarkupTextLiteral - [34..41)::7 - [ string] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[string]; + MarkupTextLiteral - [41..42)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [42..43)::1 + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.tspans.txt new file mode 100644 index 0000000000..02d9781340 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block15.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [43] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.cspans.txt new file mode 100644 index 0000000000..cf35066b4c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Code span at (50:0,50 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [51] ) +MetaCode span at (50:0,50 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [51] ) +Markup span at (51:0,51 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.diag.txt new file mode 100644 index 0000000000..34a097ddbd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.diag.txt @@ -0,0 +1 @@ +(1,27): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.stree.txt new file mode 100644 index 0000000000..9f865a9054 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..51)::51 - [@{}] + MarkupBlock - [0..51)::51 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..51)::51 + CSharpStatement - [0..51)::51 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..51)::50 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..50)::48 + MarkupBlock - [2..50)::48 + MarkupTagHelperElement - [2..50)::48 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..50)::48 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..25)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..25)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMinimizedTagHelperAttribute - [25..47)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..47)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [47..48)::1 + MarkupTextLiteral - [47..48)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [50..50)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [50..51)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [51..51)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.tspans.txt new file mode 100644 index 0000000000..720abefec9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block16.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [48] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.cspans.txt new file mode 100644 index 0000000000..8d6822ee97 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Code span at (32:0,32 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [33] ) +MetaCode span at (32:0,32 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [33] ) +Markup span at (33:0,33 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.diag.txt new file mode 100644 index 0000000000..1f297c49c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.diag.txt @@ -0,0 +1,2 @@ +(1,6): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,16): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.stree.txt new file mode 100644 index 0000000000..1befcaa705 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..33)::33 - [@{

                        }] + MarkupBlock - [0..33)::33 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..33)::33 + CSharpStatement - [0..33)::33 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..33)::32 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..32)::30 + MarkupBlock - [2..32)::30 + MarkupTagHelperElement - [2..32)::30 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..28)::26 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..14)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..14)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupMinimizedTagHelperAttribute - [14..27)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..27)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [28..32)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [32..33)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.tspans.txt new file mode 100644 index 0000000000..1c716c5737 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block17.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [30] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.cspans.txt new file mode 100644 index 0000000000..27127e839a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [70] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [70] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [70] ) +Code span at (69:0,69 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [70] ) +MetaCode span at (69:0,69 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [70] ) +Markup span at (70:0,70 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [70] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.diag.txt new file mode 100644 index 0000000000..85acb7466e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.diag.txt @@ -0,0 +1,2 @@ +(1,10): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,46): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.stree.txt new file mode 100644 index 0000000000..25b3448e77 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..70)::70 - [@{}] + MarkupBlock - [0..70)::70 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..70)::70 + CSharpStatement - [0..70)::70 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..70)::69 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..69)::67 + MarkupBlock - [2..69)::67 + MarkupTagHelperElement - [2..69)::67 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [2..69)::67 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..27)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..27)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMinimizedTagHelperAttribute - [27..44)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..44)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMinimizedTagHelperAttribute - [44..66)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [44..45)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [45..66)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [66..67)::1 + MarkupTextLiteral - [66..67)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [69..69)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [69..70)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [70..70)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.tspans.txt new file mode 100644 index 0000000000..d52f0760b6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block18.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [67] ) - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.cspans.txt new file mode 100644 index 0000000000..3c04339e4d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Code span at (45:0,45 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (46:0,46 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.diag.txt new file mode 100644 index 0000000000..40bd70e718 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.diag.txt @@ -0,0 +1,3 @@ +(1,6): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,16): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,29): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.stree.txt new file mode 100644 index 0000000000..e8733ace63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..46)::46 - [@{

                        }] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpStatement - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..46)::45 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + MarkupBlock - [2..45)::43 + MarkupTagHelperElement - [2..45)::43 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..41)::39 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..14)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..14)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupMinimizedTagHelperAttribute - [14..27)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..27)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + MarkupMinimizedTagHelperAttribute - [27..40)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..40)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [41..45)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.tspans.txt new file mode 100644 index 0000000000..a82989a6ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block19.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [43] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.cspans.txt new file mode 100644 index 0000000000..db6a9525a0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Code span at (22:0,22 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (23:0,23 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.diag.txt new file mode 100644 index 0000000000..7aaa747435 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.stree.txt new file mode 100644 index 0000000000..e68706d9ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..23)::23 - [@{

                        }] + MarkupBlock - [0..23)::23 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupTagHelperElement - [2..22)::20 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..18)::16 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..17)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..17)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [18..22)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [22..22)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [22..23)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.tspans.txt new file mode 100644 index 0000000000..d9c1c8ba6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [20] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.cspans.txt new file mode 100644 index 0000000000..eeed5a0f9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (33:0,33 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [38] ) +Code span at (40:0,40 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (41:0,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.stree.txt new file mode 100644 index 0000000000..0346338d31 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..41)::41 - [@{}] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + CSharpStatement - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..41)::40 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..40)::38 + MarkupBlock - [2..40)::38 + MarkupTagHelperElement - [2..40)::38 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..40)::38 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..25)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..25)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupTagHelperAttribute - [25..37)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..31)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [32..33)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [33..36)::3 + MarkupLiteralAttributeValue - [33..36)::3 - [btn] + MarkupTextLiteral - [33..36)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [36..37)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [37..38)::1 + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [40..41)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.tspans.txt new file mode 100644 index 0000000000..d3b1fd3647 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block20.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [38] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.cspans.txt new file mode 100644 index 0000000000..59bf8f8330 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Markup span at (25:0,25 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [32] ) +Code span at (34:0,34 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [35] ) +MetaCode span at (34:0,34 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Markup span at (35:0,35 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.diag.txt new file mode 100644 index 0000000000..7aaa747435 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.stree.txt new file mode 100644 index 0000000000..5b700f8c43 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..35)::35 - [@{

                        }] + MarkupBlock - [0..35)::35 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..35)::35 + CSharpStatement - [0..35)::35 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..35)::34 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..34)::32 + MarkupBlock - [2..34)::32 + MarkupTagHelperElement - [2..34)::32 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..30)::28 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..17)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..17)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + MarkupTagHelperAttribute - [17..29)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..23)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [25..28)::3 + MarkupLiteralAttributeValue - [25..28)::3 - [btn] + MarkupTextLiteral - [25..28)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [28..29)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [30..34)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [34..35)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.tspans.txt new file mode 100644 index 0000000000..89ddbae3e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block21.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [32] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.cspans.txt new file mode 100644 index 0000000000..5543e2871d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [38] ) +Code span at (40:0,40 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (41:0,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.stree.txt new file mode 100644 index 0000000000..7efcc5f43d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..41)::41 - [@{}] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + CSharpStatement - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..41)::40 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..40)::38 + MarkupBlock - [2..40)::38 + MarkupTagHelperElement - [2..40)::38 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..40)::38 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..20)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [20..37)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..37)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMiscAttributeContent - [37..38)::1 + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [40..41)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.tspans.txt new file mode 100644 index 0000000000..d3b1fd3647 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block22.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [38] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.cspans.txt new file mode 100644 index 0000000000..2a00c88428 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [32] ) +Code span at (34:0,34 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [35] ) +MetaCode span at (34:0,34 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [35] ) +Markup span at (35:0,35 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.diag.txt new file mode 100644 index 0000000000..2e64b8d326 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.stree.txt new file mode 100644 index 0000000000..2a6b8a96b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..35)::35 - [@{

                        }] + MarkupBlock - [0..35)::35 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..35)::35 + CSharpStatement - [0..35)::35 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..35)::34 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..34)::32 + MarkupBlock - [2..34)::32 + MarkupTagHelperElement - [2..34)::32 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..30)::28 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [4..16)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [btn] + MarkupTextLiteral - [12..15)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [16..29)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..29)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [30..34)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [34..35)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [35..35)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.tspans.txt new file mode 100644 index 0000000000..89ddbae3e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block23.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [32] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.cspans.txt new file mode 100644 index 0000000000..376263f7c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (38:0,38 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [43] ) +Code span at (45:0,45 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (46:0,46 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.diag.txt new file mode 100644 index 0000000000..17ba3c5206 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.stree.txt new file mode 100644 index 0000000000..df1c7887d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..46)::46 - [@{}] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpStatement - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..46)::45 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + MarkupBlock - [2..45)::43 + MarkupTagHelperElement - [2..45)::43 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..45)::43 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..30)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..30)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupTagHelperAttribute - [30..42)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [31..36)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [38..41)::3 + MarkupLiteralAttributeValue - [38..41)::3 - [btn] + MarkupTextLiteral - [38..41)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [41..42)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [42..43)::1 + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.tspans.txt new file mode 100644 index 0000000000..1521fa98cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block24.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [43] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.cspans.txt new file mode 100644 index 0000000000..1d5021398f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [43] ) +Code span at (45:0,45 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (46:0,46 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.diag.txt new file mode 100644 index 0000000000..4d52547683 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.diag.txt @@ -0,0 +1 @@ +(1,22): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.stree.txt new file mode 100644 index 0000000000..353f33a5d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..46)::46 - [@{}] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpStatement - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..46)::45 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + MarkupBlock - [2..45)::43 + MarkupTagHelperElement - [2..45)::43 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..45)::43 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..20)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [20..42)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..42)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [42..43)::1 + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.tspans.txt new file mode 100644 index 0000000000..1521fa98cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block25.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [43] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.cspans.txt new file mode 100644 index 0000000000..c5c968408f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (35:0,35 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [40] ) +Code span at (42:0,42 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [43] ) +MetaCode span at (42:0,42 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (43:0,43 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.diag.txt new file mode 100644 index 0000000000..e49be8f23f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.stree.txt new file mode 100644 index 0000000000..ed760371aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..43)::43 - [@{}] + MarkupBlock - [0..43)::43 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..43)::43 + CSharpStatement - [0..43)::43 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..43)::42 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..42)::40 + MarkupBlock - [2..42)::40 + MarkupTagHelperElement - [2..42)::40 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [2..42)::40 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..27)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..27)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupTagHelperAttribute - [27..39)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..33)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [34..35)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [35..38)::3 + MarkupLiteralAttributeValue - [35..38)::3 - [btn] + MarkupTextLiteral - [35..38)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [38..39)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [39..40)::1 + MarkupTextLiteral - [39..40)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [42..43)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.tspans.txt new file mode 100644 index 0000000000..e397c293b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block26.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [40] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.cspans.txt new file mode 100644 index 0000000000..c99bc193a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (22:0,22 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [29] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.diag.txt new file mode 100644 index 0000000000..d801de11d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.stree.txt new file mode 100644 index 0000000000..374822bdae --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..32)::32 - [@{

                        }] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupTagHelperElement - [2..31)::29 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..27)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..14)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..14)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupTagHelperAttribute - [14..26)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..20)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [21..22)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [22..25)::3 + MarkupLiteralAttributeValue - [22..25)::3 - [btn] + MarkupTextLiteral - [22..25)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [27..31)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.tspans.txt new file mode 100644 index 0000000000..59132499f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block27.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [29] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.cspans.txt new file mode 100644 index 0000000000..44774dadad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [40] ) +Code span at (42:0,42 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [43] ) +MetaCode span at (42:0,42 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [43] ) +Markup span at (43:0,43 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.diag.txt new file mode 100644 index 0000000000..44cbbd120a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.diag.txt @@ -0,0 +1 @@ +(1,22): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.stree.txt new file mode 100644 index 0000000000..e5f59f4fa6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..43)::43 - [@{}] + MarkupBlock - [0..43)::43 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..43)::43 + CSharpStatement - [0..43)::43 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..43)::42 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..42)::40 + MarkupBlock - [2..42)::40 + MarkupTagHelperElement - [2..42)::40 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [2..42)::40 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..20)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [20..39)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..39)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMiscAttributeContent - [39..40)::1 + MarkupTextLiteral - [39..40)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [42..43)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.tspans.txt new file mode 100644 index 0000000000..e397c293b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block28.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [40] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.cspans.txt new file mode 100644 index 0000000000..1bfedce83b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [29] ) +Code span at (31:0,31 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [32] ) +MetaCode span at (31:0,31 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [32] ) +Markup span at (32:0,32 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.diag.txt new file mode 100644 index 0000000000..b0d4ba275b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.stree.txt new file mode 100644 index 0000000000..b040d3d84b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..32)::32 - [@{

                        }] + MarkupBlock - [0..32)::32 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..32)::32 + CSharpStatement - [0..32)::32 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..32)::31 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..31)::29 + MarkupBlock - [2..31)::29 + MarkupTagHelperElement - [2..31)::29 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..27)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [4..16)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [btn] + MarkupTextLiteral - [12..15)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [16..26)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..26)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [27..31)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [31..32)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [32..32)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.tspans.txt new file mode 100644 index 0000000000..59132499f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block29.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [29] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.cspans.txt new file mode 100644 index 0000000000..1b7db58ccc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.diag.txt new file mode 100644 index 0000000000..17ba3c5206 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.stree.txt new file mode 100644 index 0000000000..f86315c309 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..34)::34 - [@{}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupTagHelperElement - [2..33)::31 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [2..33)::31 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..30)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..30)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [30..31)::1 + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.tspans.txt new file mode 100644 index 0000000000..15e0c638a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [31] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.cspans.txt new file mode 100644 index 0000000000..e24fb99361 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Transition span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (16:0,16 [13] ) +Code span at (17:0,17 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (16:0,16 [13] ) +Markup span at (29:0,29 [2] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [17] ) +Markup span at (31:0,31 [2] ) (Accepts:Any) - Parent: Markup block at (16:0,16 [17] ) +Code span at (56:0,56 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [57] ) +MetaCode span at (56:0,56 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [57] ) +Markup span at (57:0,57 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [57] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.diag.txt new file mode 100644 index 0000000000..f13ebc1193 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.diag.txt @@ -0,0 +1 @@ +(1,36): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.stree.txt new file mode 100644 index 0000000000..0737c3c3d5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..57)::57 - [@{}] + MarkupBlock - [0..57)::57 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..57)::57 + CSharpStatement - [0..57)::57 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..57)::56 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..56)::54 + MarkupBlock - [2..56)::54 + MarkupTagHelperElement - [2..56)::54 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [2..56)::54 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [8..34)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [16..33)::17 + MarkupDynamicAttributeValue - [16..29)::13 - [@DateTime.Now] + GenericBlock - [16..29)::13 + CSharpCodeBlock - [16..29)::13 + CSharpImplicitExpression - [16..29)::13 + CSharpTransition - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [17..29)::12 + CSharpCodeBlock - [17..29)::12 + CSharpExpressionLiteral - [17..29)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [29..31)::2 - [ +] + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [30..31)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [31..33)::2 - [ 1] + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [32..33)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [33..34)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [34..53)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..53)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMiscAttributeContent - [53..54)::1 + MarkupTextLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [56..56)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [56..57)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [57..57)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.tspans.txt new file mode 100644 index 0000000000..48c553ef88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block30.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [54] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.cspans.txt new file mode 100644 index 0000000000..50cbc5077c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [13] ) +Code span at (13:0,13 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [13] ) +Markup span at (25:0,25 [2] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [17] ) +Markup span at (27:0,27 [2] ) (Accepts:Any) - Parent: Markup block at (12:0,12 [17] ) +Code span at (45:0,45 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [46] ) +MetaCode span at (45:0,45 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [46] ) +Markup span at (46:0,46 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.diag.txt new file mode 100644 index 0000000000..df44096ccc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.diag.txt @@ -0,0 +1 @@ +(1,32): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.stree.txt new file mode 100644 index 0000000000..1b52e27608 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.stree.txt @@ -0,0 +1,67 @@ +RazorDocument - [0..46)::46 - [@{

                        }] + MarkupBlock - [0..46)::46 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..46)::46 + CSharpStatement - [0..46)::46 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..46)::45 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..45)::43 + MarkupBlock - [2..45)::43 + MarkupTagHelperElement - [2..45)::43 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..41)::39 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [4..30)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [12..29)::17 + MarkupDynamicAttributeValue - [12..25)::13 - [@DateTime.Now] + GenericBlock - [12..25)::13 + CSharpCodeBlock - [12..25)::13 + CSharpImplicitExpression - [12..25)::13 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..25)::12 + CSharpCodeBlock - [13..25)::12 + CSharpExpressionLiteral - [13..25)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [25..27)::2 - [ +] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..27)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [27..29)::2 - [ 1] + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..29)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [29..30)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [30..40)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [31..40)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [41..45)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [45..46)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.tspans.txt new file mode 100644 index 0000000000..a82989a6ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block31.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [43] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.cspans.txt new file mode 100644 index 0000000000..24ce3652a1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [129] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [129] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [129] ) +Transition span at (38:0,38 [1] ) (Accepts:None) - Parent: Expression block at (38:0,38 [13] ) +Code span at (39:0,39 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (38:0,38 [13] ) +Markup span at (51:0,51 [2] ) (Accepts:Any) - Parent: Markup block at (38:0,38 [17] ) +Markup span at (53:0,53 [2] ) (Accepts:Any) - Parent: Markup block at (38:0,38 [17] ) +Transition span at (88:0,88 [1] ) (Accepts:None) - Parent: Expression block at (88:0,88 [13] ) +Code span at (89:0,89 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (88:0,88 [13] ) +Markup span at (101:0,101 [2] ) (Accepts:Any) - Parent: Markup block at (88:0,88 [17] ) +Markup span at (103:0,103 [2] ) (Accepts:Any) - Parent: Markup block at (88:0,88 [17] ) +Code span at (128:0,128 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [129] ) +MetaCode span at (128:0,128 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [129] ) +Markup span at (129:0,129 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [129] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.diag.txt new file mode 100644 index 0000000000..f7ecf89f20 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.diag.txt @@ -0,0 +1,2 @@ +(1,13): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,60): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.stree.txt new file mode 100644 index 0000000000..b189fe0934 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.stree.txt @@ -0,0 +1,109 @@ +RazorDocument - [0..129)::129 - [@{}] + MarkupBlock - [0..129)::129 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..129)::129 + CSharpStatement - [0..129)::129 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..129)::128 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..128)::126 + MarkupBlock - [2..128)::126 + MarkupTagHelperElement - [2..128)::126 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [2..128)::126 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..30)::22 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [8..12)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [12..30)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupTagHelperAttribute - [30..56)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [31..36)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [37..38)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [38..55)::17 + MarkupDynamicAttributeValue - [38..51)::13 - [@DateTime.Now] + GenericBlock - [38..51)::13 + CSharpCodeBlock - [38..51)::13 + CSharpImplicitExpression - [38..51)::13 + CSharpTransition - [38..39)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [39..51)::12 + CSharpCodeBlock - [39..51)::12 + CSharpExpressionLiteral - [39..51)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [51..53)::2 - [ +] + MarkupTextLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [52..53)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [53..55)::2 - [ 1] + MarkupTextLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [54..55)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [55..56)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [56..80)::24 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [56..59)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [59..80)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupTagHelperAttribute - [80..106)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [80..81)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [81..86)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [87..88)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [88..105)::17 + MarkupDynamicAttributeValue - [88..101)::13 - [@DateTime.Now] + GenericBlock - [88..101)::13 + CSharpCodeBlock - [88..101)::13 + CSharpImplicitExpression - [88..101)::13 + CSharpTransition - [88..89)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [89..101)::12 + CSharpCodeBlock - [89..101)::12 + CSharpExpressionLiteral - [89..101)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [101..103)::2 - [ +] + MarkupTextLiteral - [101..102)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [102..103)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [103..105)::2 - [ 1] + MarkupTextLiteral - [103..104)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [104..105)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [105..106)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [106..124)::18 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [106..108)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [108..124)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMiscAttributeContent - [124..126)::2 + MarkupTextLiteral - [124..126)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [128..128)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [128..129)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [129..129)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.tspans.txt new file mode 100644 index 0000000000..166c08fd21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block32.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [126] ) - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.cspans.txt new file mode 100644 index 0000000000..a67845db19 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [104] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [104] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [104] ) +Transition span at (25:0,25 [1] ) (Accepts:None) - Parent: Expression block at (25:0,25 [13] ) +Code span at (26:0,26 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (25:0,25 [13] ) +Markup span at (38:0,38 [2] ) (Accepts:Any) - Parent: Markup block at (25:0,25 [17] ) +Markup span at (40:0,40 [2] ) (Accepts:Any) - Parent: Markup block at (25:0,25 [17] ) +Transition span at (66:0,66 [1] ) (Accepts:None) - Parent: Expression block at (66:0,66 [13] ) +Code span at (67:0,67 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (66:0,66 [13] ) +Markup span at (79:0,79 [2] ) (Accepts:Any) - Parent: Markup block at (66:0,66 [17] ) +Markup span at (81:0,81 [2] ) (Accepts:Any) - Parent: Markup block at (66:0,66 [17] ) +Code span at (103:0,103 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [104] ) +MetaCode span at (103:0,103 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [104] ) +Markup span at (104:0,104 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [104] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.diag.txt new file mode 100644 index 0000000000..02bcf3e7fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.diag.txt @@ -0,0 +1,3 @@ +(1,9): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,47): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,87): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.stree.txt new file mode 100644 index 0000000000..5045858817 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.stree.txt @@ -0,0 +1,110 @@ +RazorDocument - [0..104)::104 - [@{

                        }] + MarkupBlock - [0..104)::104 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..104)::104 + CSharpStatement - [0..104)::104 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..104)::103 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..103)::101 + MarkupBlock - [2..103)::101 + MarkupTagHelperElement - [2..103)::101 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..99)::97 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..17)::13 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [4..8)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..17)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupTagHelperAttribute - [17..43)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..23)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [25..42)::17 + MarkupDynamicAttributeValue - [25..38)::13 - [@DateTime.Now] + GenericBlock - [25..38)::13 + CSharpCodeBlock - [25..38)::13 + CSharpImplicitExpression - [25..38)::13 + CSharpTransition - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [26..38)::12 + CSharpCodeBlock - [26..38)::12 + CSharpExpressionLiteral - [26..38)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [38..40)::2 - [ +] + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [39..40)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [40..42)::2 - [ 1] + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [41..42)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [42..43)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [43..58)::15 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [43..46)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [46..58)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + MarkupTagHelperAttribute - [58..84)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [58..59)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [59..64)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [65..66)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [66..83)::17 + MarkupDynamicAttributeValue - [66..79)::13 - [@DateTime.Now] + GenericBlock - [66..79)::13 + CSharpCodeBlock - [66..79)::13 + CSharpImplicitExpression - [66..79)::13 + CSharpTransition - [66..67)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [67..79)::12 + CSharpCodeBlock - [67..79)::12 + CSharpExpressionLiteral - [67..79)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [79..81)::2 - [ +] + MarkupTextLiteral - [79..80)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [80..81)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [81..83)::2 - [ 1] + MarkupTextLiteral - [81..82)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [82..83)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [83..84)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [84..98)::14 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [84..86)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [86..98)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [99..103)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [103..103)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [103..104)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [104..104)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.tspans.txt new file mode 100644 index 0000000000..9fcda621d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block33.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [101] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.cspans.txt new file mode 100644 index 0000000000..98013e5de4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Code span at (30:0,30 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (31:0,31 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.diag.txt new file mode 100644 index 0000000000..e49be8f23f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.stree.txt new file mode 100644 index 0000000000..aec5a2ef4a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..31)::31 - [@{}] + MarkupBlock - [0..31)::31 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + CSharpStatement - [0..31)::31 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..31)::30 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + MarkupBlock - [2..30)::28 + MarkupTagHelperElement - [2..30)::28 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [2..30)::28 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..27)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..27)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMiscAttributeContent - [27..28)::1 + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.tspans.txt new file mode 100644 index 0000000000..84da2d9138 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [28] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.cspans.txt new file mode 100644 index 0000000000..2397a13ae4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Code span at (19:0,19 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (19:0,19 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (20:0,20 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.diag.txt new file mode 100644 index 0000000000..d801de11d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.diag.txt @@ -0,0 +1 @@ +(1,6): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.stree.txt new file mode 100644 index 0000000000..f61bc90a08 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..20)::20 - [@{

                        }] + MarkupBlock - [0..20)::20 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupTagHelperElement - [2..19)::17 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [2..15)::13 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [4..14)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..14)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [15..19)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [19..20)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [20..20)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.tspans.txt new file mode 100644 index 0000000000..b8f49f313a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [17] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.cspans.txt new file mode 100644 index 0000000000..24e649f2da --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (25:0,25 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (26:0,26 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.diag.txt new file mode 100644 index 0000000000..4ea65e9705 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'int-dictionary' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Collections.Generic.IDictionary' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.stree.txt new file mode 100644 index 0000000000..cffd8ef998 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..26)::26 - [@{}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..25)::23 + MarkupBlock - [2..25)::23 + MarkupTagHelperElement - [2..25)::23 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..25)::23 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..23)::15 - int-dictionary - Minimized - Bound - [ int-dictionary] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..23)::14 - [int-dictionary] - Gen - SpanEditHandler;Accepts:Any + Text;[int-dictionary]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.tspans.txt new file mode 100644 index 0000000000..15dbcaa307 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [23] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.cspans.txt new file mode 100644 index 0000000000..3b00b2167f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Code span at (29:0,29 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.diag.txt new file mode 100644 index 0000000000..c4f2e7af6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ2008: Attribute 'string-dictionary' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Collections.Generic.IDictionary' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.stree.txt new file mode 100644 index 0000000000..de57398940 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..30)::30 - [@{}] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpStatement - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..30)::29 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..29)::27 + MarkupBlock - [2..29)::27 + MarkupTagHelperElement - [2..29)::27 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..29)::27 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..26)::18 - string-dictionary - Minimized - Bound - [ string-dictionary] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..26)::17 - [string-dictionary] - Gen - SpanEditHandler;Accepts:Any + Text;[string-dictionary]; + MarkupMiscAttributeContent - [26..27)::1 + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.tspans.txt new file mode 100644 index 0000000000..e5276ea81f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [27] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.cspans.txt new file mode 100644 index 0000000000..b4b9c0325e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Code span at (23:0,23 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.diag.txt new file mode 100644 index 0000000000..132178a225 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.diag.txt @@ -0,0 +1,2 @@ +(1,10): Error RZ2008: Attribute 'int-prefix-' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,10): Error RZ1029: The tag helper attribute 'int-prefix-' in element 'input' is missing a key. The syntax is ''. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.stree.txt new file mode 100644 index 0000000000..54f08693c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..24)::24 - [@{}] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + MarkupBlock - [2..23)::21 + MarkupTagHelperElement - [2..23)::21 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..23)::21 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..20)::12 - int-prefix- - Minimized - Bound - [ int-prefix-] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..20)::11 - [int-prefix-] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-]; + MarkupMiscAttributeContent - [20..21)::1 + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.tspans.txt new file mode 100644 index 0000000000..a323d89c7a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [21] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.cspans.txt new file mode 100644 index 0000000000..24e649f2da --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Code span at (25:0,25 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [26] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [26] ) +Markup span at (26:0,26 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.diag.txt new file mode 100644 index 0000000000..b9efc3a749 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.diag.txt @@ -0,0 +1,2 @@ +(1,10): Error RZ2008: Attribute 'string-prefix-' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,10): Error RZ1029: The tag helper attribute 'string-prefix-' in element 'input' is missing a key. The syntax is ''. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.stree.txt new file mode 100644 index 0000000000..54a9bbcb1c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..26)::26 - [@{}] + MarkupBlock - [0..26)::26 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..26)::26 + CSharpStatement - [0..26)::26 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..26)::25 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..25)::23 + MarkupBlock - [2..25)::23 + MarkupTagHelperElement - [2..25)::23 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [2..25)::23 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [8..23)::15 - string-prefix- - Minimized - Bound - [ string-prefix-] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..23)::14 - [string-prefix-] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-]; + ForwardSlash;[/]; + CloseAngle;[>]; + CSharpStatementLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [25..26)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.tspans.txt new file mode 100644 index 0000000000..15dbcaa307 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Block9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [23] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.stree.txt new file mode 100644 index 0000000000..47f7be7833 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..26)::26 - [] + MarkupBlock - [0..26)::26 + MarkupTagHelperElement - [0..26)::26 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..26)::26 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..23)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMiscAttributeContent - [23..24)::1 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.tspans.txt new file mode 100644 index 0000000000..c70b63a3a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [26] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.diag.txt new file mode 100644 index 0000000000..f9aca6bc06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'int-prefix-value' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.stree.txt new file mode 100644 index 0000000000..b4a299b04e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..25)::25 - [] + MarkupBlock - [0..25)::25 + MarkupTagHelperElement - [0..25)::25 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..23)::17 - int-prefix-value - Minimized - Bound - [ int-prefix-value] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [int-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-value]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.tspans.txt new file mode 100644 index 0000000000..1cdf61374d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.diag.txt new file mode 100644 index 0000000000..34c821c786 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'string-prefix-value' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.stree.txt new file mode 100644 index 0000000000..7e2884d597 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..29)::29 - [] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..29)::29 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..26)::20 - string-prefix-value - Minimized - Bound - [ string-prefix-value] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..26)::19 - [string-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-value]; + MarkupMiscAttributeContent - [26..27)::1 + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.tspans.txt new file mode 100644 index 0000000000..0cecc8878e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.cspans.txt new file mode 100644 index 0000000000..fd32ae8345 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.cspans.txt @@ -0,0 +1 @@ +Code span at (25:0,25 [0] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.diag.txt new file mode 100644 index 0000000000..f9aca6bc06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'int-prefix-value' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.stree.txt new file mode 100644 index 0000000000..2fdaa0868a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..29)::29 - [] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..29)::29 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..26)::20 - int-prefix-value - SingleQuotes - Bound - [ int-prefix-value=''] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [int-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [25..25)::0 + CSharpExpressionLiteral - [25..25)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [26..27)::1 + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.tspans.txt new file mode 100644 index 0000000000..0cecc8878e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.cspans.txt new file mode 100644 index 0000000000..8bfb200837 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.cspans.txt @@ -0,0 +1 @@ +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.stree.txt new file mode 100644 index 0000000000..08bf6be38e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..31)::31 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..29)::23 - string-prefix-value - SingleQuotes - Bound - [ string-prefix-value=''] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..26)::19 - [string-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [28..28)::0 + MarkupTextLiteral - [28..28)::0 - [] + MarkupTextLiteral - [28..29)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.tspans.txt new file mode 100644 index 0000000000..fb3dd52d1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document13.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.cspans.txt new file mode 100644 index 0000000000..ef4d8f2892 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.cspans.txt @@ -0,0 +1 @@ +Code span at (25:0,25 [1] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.stree.txt new file mode 100644 index 0000000000..11c35e9738 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..29)::29 - [] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..29)::29 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..27)::21 - int-prefix-value - SingleQuotes - Bound - [ int-prefix-value='3'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [int-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [25..26)::1 + CSharpExpressionLiteral - [25..26)::1 - [3] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[3]; + MarkupTextLiteral - [26..27)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.tspans.txt new file mode 100644 index 0000000000..0cecc8878e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document14.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.cspans.txt new file mode 100644 index 0000000000..59085ec1f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (28:0,28 [4] ) (Accepts:Any) - Parent: Markup block at (28:0,28 [11] ) +Markup span at (32:0,32 [7] ) (Accepts:Any) - Parent: Markup block at (28:0,28 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.stree.txt new file mode 100644 index 0000000000..f3b42e62e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..43)::43 - [] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..43)::43 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..40)::34 - string-prefix-value - SingleQuotes - Bound - [ string-prefix-value='some string'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..26)::19 - [string-prefix-value] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-value]; + Equals;[=]; + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [28..39)::11 + MarkupTextLiteral - [28..32)::4 - [some] - Gen - SpanEditHandler;Accepts:Any + Text;[some]; + MarkupTextLiteral - [32..39)::7 - [ string] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[string]; + MarkupTextLiteral - [39..40)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [40..41)::1 + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.tspans.txt new file mode 100644 index 0000000000..cdcaa72be2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document15.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.diag.txt new file mode 100644 index 0000000000..f16231c79a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.diag.txt @@ -0,0 +1 @@ +(1,25): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.stree.txt new file mode 100644 index 0000000000..2eb0da7317 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..48)::48 - [] + MarkupBlock - [0..48)::48 + MarkupTagHelperElement - [0..48)::48 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..48)::48 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..23)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMinimizedTagHelperAttribute - [23..45)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..45)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [45..46)::1 + MarkupTextLiteral - [45..46)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.tspans.txt new file mode 100644 index 0000000000..d2f983f82e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document16.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [48] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.diag.txt new file mode 100644 index 0000000000..a34289902a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.diag.txt @@ -0,0 +1,2 @@ +(1,4): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,14): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.stree.txt new file mode 100644 index 0000000000..7e4b51696b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..30)::30 - [

                        ] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..26)::26 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..12)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..12)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupMinimizedTagHelperAttribute - [12..25)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..25)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [26..30)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.tspans.txt new file mode 100644 index 0000000000..2e5914e934 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document17.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [30] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.diag.txt new file mode 100644 index 0000000000..b62a808863 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.diag.txt @@ -0,0 +1,2 @@ +(1,8): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,44): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.stree.txt new file mode 100644 index 0000000000..f0769355d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..67)::67 - [] + MarkupBlock - [0..67)::67 + MarkupTagHelperElement - [0..67)::67 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [0..67)::67 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..25)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..25)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMinimizedTagHelperAttribute - [25..42)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..42)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMinimizedTagHelperAttribute - [42..64)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [43..64)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [64..65)::1 + MarkupTextLiteral - [64..65)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.tspans.txt new file mode 100644 index 0000000000..bd906590f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document18.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [67] ) - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.diag.txt new file mode 100644 index 0000000000..2d5adeffaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.diag.txt @@ -0,0 +1,3 @@ +(1,4): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,14): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,27): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.stree.txt new file mode 100644 index 0000000000..3e7583e45f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..43)::43 - [

                        ] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..39)::39 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..12)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..12)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupMinimizedTagHelperAttribute - [12..25)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..25)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + MarkupMinimizedTagHelperAttribute - [25..38)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..38)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [39..43)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.tspans.txt new file mode 100644 index 0000000000..9b75c4b72a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document19.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.diag.txt new file mode 100644 index 0000000000..73d0ec9b72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.stree.txt new file mode 100644 index 0000000000..145201b308 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..20)::20 - [

                        ] + MarkupBlock - [0..20)::20 + MarkupTagHelperElement - [0..20)::20 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..16)::16 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..15)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..15)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [16..20)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.tspans.txt new file mode 100644 index 0000000000..c5f5d51854 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [20] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.cspans.txt new file mode 100644 index 0000000000..f887502903 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.cspans.txt @@ -0,0 +1 @@ +Markup span at (31:0,31 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.stree.txt new file mode 100644 index 0000000000..a0f4d372dd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..38)::38 - [] + MarkupBlock - [0..38)::38 + MarkupTagHelperElement - [0..38)::38 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..38)::38 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..23)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupTagHelperAttribute - [23..35)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..29)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [30..31)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [31..34)::3 + MarkupLiteralAttributeValue - [31..34)::3 - [btn] + MarkupTextLiteral - [31..34)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [34..35)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [35..36)::1 + MarkupTextLiteral - [35..36)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.tspans.txt new file mode 100644 index 0000000000..3530a0ad39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document20.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [38] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.cspans.txt new file mode 100644 index 0000000000..f3168ff72f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.cspans.txt @@ -0,0 +1 @@ +Markup span at (23:0,23 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.diag.txt new file mode 100644 index 0000000000..73d0ec9b72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.stree.txt new file mode 100644 index 0000000000..8d6eb3895f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..32)::32 - [

                        ] + MarkupBlock - [0..32)::32 + MarkupTagHelperElement - [0..32)::32 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..28)::28 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..15)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..15)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + MarkupTagHelperAttribute - [15..27)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [16..21)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [23..26)::3 + MarkupLiteralAttributeValue - [23..26)::3 - [btn] + MarkupTextLiteral - [23..26)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [26..27)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [28..32)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.tspans.txt new file mode 100644 index 0000000000..96056a17cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document21.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [32] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.cspans.txt new file mode 100644 index 0000000000..da12d8c524 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.cspans.txt @@ -0,0 +1 @@ +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [38] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.stree.txt new file mode 100644 index 0000000000..bd392ebaca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..38)::38 - [] + MarkupBlock - [0..38)::38 + MarkupTagHelperElement - [0..38)::38 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..38)::38 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [14..17)::3 + MarkupLiteralAttributeValue - [14..17)::3 - [btn] + MarkupTextLiteral - [14..17)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [18..35)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..35)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMiscAttributeContent - [35..36)::1 + MarkupTextLiteral - [35..36)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.tspans.txt new file mode 100644 index 0000000000..3530a0ad39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document22.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [38] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.cspans.txt new file mode 100644 index 0000000000..aaba30723e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [32] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.diag.txt new file mode 100644 index 0000000000..1379c04890 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.stree.txt new file mode 100644 index 0000000000..a5d56b5d4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..32)::32 - [

                        ] + MarkupBlock - [0..32)::32 + MarkupTagHelperElement - [0..32)::32 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..28)::28 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..27)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..27)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [28..32)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.tspans.txt new file mode 100644 index 0000000000..96056a17cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document23.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [32] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.cspans.txt new file mode 100644 index 0000000000..617d58dd6c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.cspans.txt @@ -0,0 +1 @@ +Markup span at (36:0,36 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.diag.txt new file mode 100644 index 0000000000..fa5bd9298e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.stree.txt new file mode 100644 index 0000000000..fac0ca1d88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..43)::43 - [] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..43)::43 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..28)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..28)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupTagHelperAttribute - [28..40)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [29..34)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [36..39)::3 + MarkupLiteralAttributeValue - [36..39)::3 - [btn] + MarkupTextLiteral - [36..39)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [39..40)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [40..41)::1 + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.tspans.txt new file mode 100644 index 0000000000..4b2bde1a22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document24.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.cspans.txt new file mode 100644 index 0000000000..5d5e86a3ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.cspans.txt @@ -0,0 +1 @@ +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [43] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.diag.txt new file mode 100644 index 0000000000..107ae7e349 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.diag.txt @@ -0,0 +1 @@ +(1,20): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.stree.txt new file mode 100644 index 0000000000..44e24eec99 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..43)::43 - [] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..43)::43 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [14..17)::3 + MarkupLiteralAttributeValue - [14..17)::3 - [btn] + MarkupTextLiteral - [14..17)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [18..40)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..40)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [40..41)::1 + MarkupTextLiteral - [40..41)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.tspans.txt new file mode 100644 index 0000000000..4b2bde1a22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document25.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.cspans.txt new file mode 100644 index 0000000000..a407f3ff42 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.cspans.txt @@ -0,0 +1 @@ +Markup span at (33:0,33 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.diag.txt new file mode 100644 index 0000000000..7c6942351c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.stree.txt new file mode 100644 index 0000000000..d95095a2ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..40)::40 - [] + MarkupBlock - [0..40)::40 + MarkupTagHelperElement - [0..40)::40 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [0..40)::40 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..25)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..25)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupTagHelperAttribute - [25..37)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..31)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [32..33)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [33..36)::3 + MarkupLiteralAttributeValue - [33..36)::3 - [btn] + MarkupTextLiteral - [33..36)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [36..37)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMiscAttributeContent - [37..38)::1 + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.tspans.txt new file mode 100644 index 0000000000..e303f87929 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document26.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [40] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.cspans.txt new file mode 100644 index 0000000000..b760071418 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.cspans.txt @@ -0,0 +1 @@ +Markup span at (20:0,20 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.diag.txt new file mode 100644 index 0000000000..522de8be51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.stree.txt new file mode 100644 index 0000000000..c06d878da2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..29)::29 - [

                        ] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..12)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..12)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupTagHelperAttribute - [12..24)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..18)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [19..20)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [20..23)::3 + MarkupLiteralAttributeValue - [20..23)::3 - [btn] + MarkupTextLiteral - [20..23)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupTagHelperEndTag - [25..29)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.tspans.txt new file mode 100644 index 0000000000..4a617a9985 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document27.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.cspans.txt new file mode 100644 index 0000000000..bbfaeade34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.cspans.txt @@ -0,0 +1 @@ +Markup span at (14:0,14 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.diag.txt new file mode 100644 index 0000000000..b147ff3b8e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.diag.txt @@ -0,0 +1 @@ +(1,20): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.stree.txt new file mode 100644 index 0000000000..469b6d91f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..40)::40 - [] + MarkupBlock - [0..40)::40 + MarkupTagHelperElement - [0..40)::40 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [0..40)::40 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..18)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [14..17)::3 + MarkupLiteralAttributeValue - [14..17)::3 - [btn] + MarkupTextLiteral - [14..17)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [17..18)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [18..37)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..37)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMiscAttributeContent - [37..38)::1 + MarkupTextLiteral - [37..38)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.tspans.txt new file mode 100644 index 0000000000..e303f87929 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document28.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [40] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.cspans.txt new file mode 100644 index 0000000000..9886c6c9e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.diag.txt new file mode 100644 index 0000000000..070a2efcbf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.stree.txt new file mode 100644 index 0000000000..f745ff8f16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..29)::29 - [

                        ] + MarkupBlock - [0..29)::29 + MarkupTagHelperElement - [0..29)::29 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - SingleQuotes - Unbound - [ class='btn'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..24)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..24)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [25..29)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.tspans.txt new file mode 100644 index 0000000000..4a617a9985 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document29.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [29] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.diag.txt new file mode 100644 index 0000000000..fa5bd9298e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.stree.txt new file mode 100644 index 0000000000..8e3178ad8e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - input[SelfClosing] - InputTagHelper1 - InputTagHelper3 + MarkupTagHelperStartTag - [0..31)::31 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..28)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..28)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.tspans.txt new file mode 100644 index 0000000000..69e54d8aad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.cspans.txt new file mode 100644 index 0000000000..b7f3cfaf69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (14:0,14 [1] ) (Accepts:None) - Parent: Expression block at (14:0,14 [13] ) +Code span at (15:0,15 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (14:0,14 [13] ) +Markup span at (27:0,27 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [17] ) +Markup span at (29:0,29 [2] ) (Accepts:Any) - Parent: Markup block at (14:0,14 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.diag.txt new file mode 100644 index 0000000000..35bf3d2029 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.diag.txt @@ -0,0 +1 @@ +(1,34): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.stree.txt new file mode 100644 index 0000000000..53741e1a93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..54)::54 - [] + MarkupBlock - [0..54)::54 + MarkupTagHelperElement - [0..54)::54 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [0..54)::54 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupTagHelperAttribute - [6..32)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..12)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [14..31)::17 + MarkupDynamicAttributeValue - [14..27)::13 - [@DateTime.Now] + GenericBlock - [14..27)::13 + CSharpCodeBlock - [14..27)::13 + CSharpImplicitExpression - [14..27)::13 + CSharpTransition - [14..15)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [15..27)::12 + CSharpCodeBlock - [15..27)::12 + CSharpExpressionLiteral - [15..27)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [27..29)::2 - [ +] + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [28..29)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [29..31)::2 - [ 1] + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [30..31)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [31..32)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [32..51)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [32..33)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [33..51)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMiscAttributeContent - [51..52)::1 + MarkupTextLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.tspans.txt new file mode 100644 index 0000000000..3416d837b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document30.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [54] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.cspans.txt new file mode 100644 index 0000000000..5279ba8415 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.cspans.txt @@ -0,0 +1,4 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) +Markup span at (23:0,23 [2] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [17] ) +Markup span at (25:0,25 [2] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.diag.txt new file mode 100644 index 0000000000..49aae9f038 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.diag.txt @@ -0,0 +1 @@ +(1,30): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.stree.txt new file mode 100644 index 0000000000..a9fb407701 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..43)::43 - [

                        ] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..39)::39 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..28)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..27)::17 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [23..25)::2 - [ +] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..25)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [25..27)::2 - [ 1] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..27)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [27..28)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [28..38)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [29..38)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [39..43)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.tspans.txt new file mode 100644 index 0000000000..9b75c4b72a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document31.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.cspans.txt new file mode 100644 index 0000000000..d4bd228d1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.cspans.txt @@ -0,0 +1,8 @@ +Transition span at (36:0,36 [1] ) (Accepts:None) - Parent: Expression block at (36:0,36 [13] ) +Code span at (37:0,37 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (36:0,36 [13] ) +Markup span at (49:0,49 [2] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [17] ) +Markup span at (51:0,51 [2] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [17] ) +Transition span at (86:0,86 [1] ) (Accepts:None) - Parent: Expression block at (86:0,86 [13] ) +Code span at (87:0,87 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (86:0,86 [13] ) +Markup span at (99:0,99 [2] ) (Accepts:Any) - Parent: Markup block at (86:0,86 [17] ) +Markup span at (101:0,101 [2] ) (Accepts:Any) - Parent: Markup block at (86:0,86 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.diag.txt new file mode 100644 index 0000000000..87c50385f2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.diag.txt @@ -0,0 +1,2 @@ +(1,11): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,58): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.stree.txt new file mode 100644 index 0000000000..1663d17fc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.stree.txt @@ -0,0 +1,92 @@ +RazorDocument - [0..126)::126 - [] + MarkupBlock - [0..126)::126 + MarkupTagHelperElement - [0..126)::126 - input[SelfClosing] - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [0..126)::126 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..28)::22 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..10)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [10..28)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupTagHelperAttribute - [28..54)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [29..34)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [36..53)::17 + MarkupDynamicAttributeValue - [36..49)::13 - [@DateTime.Now] + GenericBlock - [36..49)::13 + CSharpCodeBlock - [36..49)::13 + CSharpImplicitExpression - [36..49)::13 + CSharpTransition - [36..37)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [37..49)::12 + CSharpCodeBlock - [37..49)::12 + CSharpExpressionLiteral - [37..49)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [49..51)::2 - [ +] + MarkupTextLiteral - [49..50)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [50..51)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [51..53)::2 - [ 1] + MarkupTextLiteral - [51..52)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [52..53)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [53..54)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [54..78)::24 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [54..57)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [57..78)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + MarkupTagHelperAttribute - [78..104)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [78..79)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [79..84)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [85..86)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [86..103)::17 + MarkupDynamicAttributeValue - [86..99)::13 - [@DateTime.Now] + GenericBlock - [86..99)::13 + CSharpCodeBlock - [86..99)::13 + CSharpImplicitExpression - [86..99)::13 + CSharpTransition - [86..87)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [87..99)::12 + CSharpCodeBlock - [87..99)::12 + CSharpExpressionLiteral - [87..99)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [99..101)::2 - [ +] + MarkupTextLiteral - [99..100)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [100..101)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [101..103)::2 - [ 1] + MarkupTextLiteral - [101..102)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [102..103)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [103..104)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [104..122)::18 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [104..106)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [106..122)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMiscAttributeContent - [122..124)::2 + MarkupTextLiteral - [122..124)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.tspans.txt new file mode 100644 index 0000000000..ed3ef89c3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document32.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [126] ) - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.cspans.txt new file mode 100644 index 0000000000..0a331cbddd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.cspans.txt @@ -0,0 +1,8 @@ +Transition span at (23:0,23 [1] ) (Accepts:None) - Parent: Expression block at (23:0,23 [13] ) +Code span at (24:0,24 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (23:0,23 [13] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Markup block at (23:0,23 [17] ) +Markup span at (38:0,38 [2] ) (Accepts:Any) - Parent: Markup block at (23:0,23 [17] ) +Transition span at (64:0,64 [1] ) (Accepts:None) - Parent: Expression block at (64:0,64 [13] ) +Code span at (65:0,65 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (64:0,64 [13] ) +Markup span at (77:0,77 [2] ) (Accepts:Any) - Parent: Markup block at (64:0,64 [17] ) +Markup span at (79:0,79 [2] ) (Accepts:Any) - Parent: Markup block at (64:0,64 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.diag.txt new file mode 100644 index 0000000000..482a02baa0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.diag.txt @@ -0,0 +1,3 @@ +(1,7): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,45): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,85): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.stree.txt new file mode 100644 index 0000000000..a84a2d3683 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.stree.txt @@ -0,0 +1,93 @@ +RazorDocument - [0..101)::101 - [

                        ] + MarkupBlock - [0..101)::101 + MarkupTagHelperElement - [0..101)::101 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..97)::97 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..15)::13 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..6)::4 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..15)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupTagHelperAttribute - [15..41)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [16..21)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [23..40)::17 + MarkupDynamicAttributeValue - [23..36)::13 - [@DateTime.Now] + GenericBlock - [23..36)::13 + CSharpCodeBlock - [23..36)::13 + CSharpImplicitExpression - [23..36)::13 + CSharpTransition - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [24..36)::12 + CSharpCodeBlock - [24..36)::12 + CSharpExpressionLiteral - [24..36)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [36..38)::2 - [ +] + MarkupTextLiteral - [36..37)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [37..38)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [38..40)::2 - [ 1] + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [39..40)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [40..41)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [41..56)::15 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [41..44)::3 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [44..56)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + MarkupTagHelperAttribute - [56..82)::26 - class - SingleQuotes - Unbound - [ class='@DateTime.Now + 1'] + MarkupTextLiteral - [56..57)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [57..62)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [63..64)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [64..81)::17 + MarkupDynamicAttributeValue - [64..77)::13 - [@DateTime.Now] + GenericBlock - [64..77)::13 + CSharpCodeBlock - [64..77)::13 + CSharpImplicitExpression - [64..77)::13 + CSharpTransition - [64..65)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [65..77)::12 + CSharpCodeBlock - [65..77)::12 + CSharpExpressionLiteral - [65..77)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [77..79)::2 - [ +] + MarkupTextLiteral - [77..78)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [78..79)::1 - [+] - Gen - SpanEditHandler;Accepts:Any + Text;[+]; + MarkupLiteralAttributeValue - [79..81)::2 - [ 1] + MarkupTextLiteral - [79..80)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [80..81)::1 - [1] - Gen - SpanEditHandler;Accepts:Any + Text;[1]; + MarkupTextLiteral - [81..82)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [82..96)::14 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [82..84)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [84..96)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [97..101)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.tspans.txt new file mode 100644 index 0000000000..2c2b6d9444 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document33.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [101] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.diag.txt new file mode 100644 index 0000000000..7c6942351c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.stree.txt new file mode 100644 index 0000000000..a2981d26cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..28)::28 - [] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - input[SelfClosing] - InputTagHelper2 - InputTagHelper3 + MarkupTagHelperStartTag - [0..28)::28 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..25)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..25)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMiscAttributeContent - [25..26)::1 + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.tspans.txt new file mode 100644 index 0000000000..61fc991231 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.diag.txt new file mode 100644 index 0000000000..522de8be51 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.stree.txt new file mode 100644 index 0000000000..3fcce47716 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..17)::17 - [

                        ] + MarkupBlock - [0..17)::17 + MarkupTagHelperElement - [0..17)::17 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..13)::13 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..12)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..12)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [13..17)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.tspans.txt new file mode 100644 index 0000000000..3e5ab2dd80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [17] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.diag.txt new file mode 100644 index 0000000000..087db6b299 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'int-dictionary' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Collections.Generic.IDictionary' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.stree.txt new file mode 100644 index 0000000000..40a3abd8ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..23)::23 - [] + MarkupBlock - [0..23)::23 + MarkupTagHelperElement - [0..23)::23 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..23)::23 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..21)::15 - int-dictionary - Minimized - Bound - [ int-dictionary] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..21)::14 - [int-dictionary] - Gen - SpanEditHandler;Accepts:Any + Text;[int-dictionary]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.tspans.txt new file mode 100644 index 0000000000..9e2dbbf7ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.diag.txt new file mode 100644 index 0000000000..2d79facfa7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.diag.txt @@ -0,0 +1 @@ +(1,8): Error RZ2008: Attribute 'string-dictionary' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Collections.Generic.IDictionary' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.stree.txt new file mode 100644 index 0000000000..b4727002f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..27)::27 - [] + MarkupBlock - [0..27)::27 + MarkupTagHelperElement - [0..27)::27 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..27)::27 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..24)::18 - string-dictionary - Minimized - Bound - [ string-dictionary] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..24)::17 - [string-dictionary] - Gen - SpanEditHandler;Accepts:Any + Text;[string-dictionary]; + MarkupMiscAttributeContent - [24..25)::1 + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.tspans.txt new file mode 100644 index 0000000000..a3749faee2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [27] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.diag.txt new file mode 100644 index 0000000000..0b5a932381 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.diag.txt @@ -0,0 +1,2 @@ +(1,8): Error RZ2008: Attribute 'int-prefix-' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,8): Error RZ1029: The tag helper attribute 'int-prefix-' in element 'input' is missing a key. The syntax is ''. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.stree.txt new file mode 100644 index 0000000000..b0f4f09641 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..21)::21 - [] + MarkupBlock - [0..21)::21 + MarkupTagHelperElement - [0..21)::21 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..21)::21 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..18)::12 - int-prefix- - Minimized - Bound - [ int-prefix-] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..18)::11 - [int-prefix-] - Gen - SpanEditHandler;Accepts:Any + Text;[int-prefix-]; + MarkupMiscAttributeContent - [18..19)::1 + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.tspans.txt new file mode 100644 index 0000000000..d140288679 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [21] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.diag.txt new file mode 100644 index 0000000000..6b9780fc87 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.diag.txt @@ -0,0 +1,2 @@ +(1,8): Error RZ2008: Attribute 'string-prefix-' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,8): Error RZ1029: The tag helper attribute 'string-prefix-' in element 'input' is missing a key. The syntax is ''. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.stree.txt new file mode 100644 index 0000000000..d352a5b08f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.stree.txt @@ -0,0 +1,13 @@ +RazorDocument - [0..23)::23 - [] + MarkupBlock - [0..23)::23 + MarkupTagHelperElement - [0..23)::23 - input[SelfClosing] - InputTagHelper3 + MarkupTagHelperStartTag - [0..23)::23 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..21)::15 - string-prefix- - Minimized - Bound - [ string-prefix-] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..21)::14 - [string-prefix-] - Gen - SpanEditHandler;Accepts:Any + Text;[string-prefix-]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.tspans.txt new file mode 100644 index 0000000000..9e2dbbf7ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_Document9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.diag.txt new file mode 100644 index 0000000000..b90634a515 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'input'. +(1,2): Error RZ1034: Found a malformed 'input' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.stree.txt new file mode 100644 index 0000000000..b3980dc81a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..23)::23 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..23)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..23)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.tspans.txt new file mode 100644 index 0000000000..c0685318c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.diag.txt new file mode 100644 index 0000000000..3b6c11fc6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'input'. +(1,2): Error RZ1034: Found a malformed 'input' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,8): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.stree.txt new file mode 100644 index 0000000000..3a1bb42157 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..28)::28 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..28)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..28)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.tspans.txt new file mode 100644 index 0000000000..918bc21db0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - InputTagHelper1 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.diag.txt new file mode 100644 index 0000000000..cb730a6dc9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'input'. +(1,2): Error RZ1034: Found a malformed 'input' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,8): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.stree.txt new file mode 100644 index 0000000000..bb81e143f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..25)::25 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..25)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..25)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.tspans.txt new file mode 100644 index 0000000000..27bc016b3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.diag.txt new file mode 100644 index 0000000000..19ac9103b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.diag.txt @@ -0,0 +1,4 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'input'. +(1,2): Error RZ1034: Found a malformed 'input' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,8): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,44): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.stree.txt new file mode 100644 index 0000000000..edceae1dac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..64)::64 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..25)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..25)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMinimizedTagHelperAttribute - [25..42)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..42)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMinimizedTagHelperAttribute - [42..64)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [43..64)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.tspans.txt new file mode 100644 index 0000000000..49cb0fe449 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [64] ) - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.diag.txt new file mode 100644 index 0000000000..a1ee83bf6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,4): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.stree.txt new file mode 100644 index 0000000000..0b7dc80111 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..15)::15 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..15)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..15)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.tspans.txt new file mode 100644 index 0000000000..6a366b1c64 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [15] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.diag.txt new file mode 100644 index 0000000000..fb20eab90d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,4): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.stree.txt new file mode 100644 index 0000000000..151355fd87 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..12)::12 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..12)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..12)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.tspans.txt new file mode 100644 index 0000000000..5cd52523a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [12] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.diag.txt new file mode 100644 index 0000000000..4d7e0d9d26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.diag.txt @@ -0,0 +1,4 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,4): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,14): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.stree.txt new file mode 100644 index 0000000000..4cc7c8aebb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..25)::25 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [2..12)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..12)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupMinimizedTagHelperAttribute - [12..25)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [13..25)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.tspans.txt new file mode 100644 index 0000000000..e3e08d013c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.diag.txt new file mode 100644 index 0000000000..c64141f180 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.diag.txt @@ -0,0 +1,8 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'input'. +(1,2): Error RZ1034: Found a malformed 'input' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,8): Error RZ2008: Attribute 'bound-required-int' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,44): Error RZ2008: Attribute 'bound-required-string' on tag helper element 'input' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. +(1,66): Error RZ1035: Missing close angle for tag helper 'p'. +(1,66): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,68): Error RZ2008: Attribute 'bound-int' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.Int32' cannot be empty or contain only whitespace. +(1,78): Error RZ2008: Attribute 'bound-string' on tag helper element 'p' requires a value. Tag helper bound attributes of type 'System.String' cannot be empty or contain only whitespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.stree.txt new file mode 100644 index 0000000000..bf383c8b52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..89)::89 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..25)::19 - bound-required-int - Minimized - Bound - [ bound-required-int] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..25)::18 - [bound-required-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-int]; + MarkupMinimizedTagHelperAttribute - [25..42)::17 - unbound-required - Minimized - Unbound - [ unbound-required] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..42)::16 - [unbound-required] - Gen - SpanEditHandler;Accepts:Any + Text;[unbound-required]; + MarkupMinimizedTagHelperAttribute - [42..64)::22 - bound-required-string - Minimized - Bound - [ bound-required-string] + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [43..64)::21 - [bound-required-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-required-string]; + CloseAngle;[]; + MarkupTagHelperElement - [64..89)::25 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [64..89)::25 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMinimizedTagHelperAttribute - [66..76)::10 - bound-int - Minimized - Bound - [ bound-int] + MarkupTextLiteral - [66..67)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [67..76)::9 - [bound-int] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-int]; + MarkupMinimizedTagHelperAttribute - [76..89)::13 - bound-string - Minimized - Bound - [ bound-string] + MarkupTextLiteral - [76..77)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [77..89)::12 - [bound-string] - Gen - SpanEditHandler;Accepts:Any + Text;[bound-string]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.tspans.txt new file mode 100644 index 0000000000..846bc42dc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedAttributes_PartialTags8.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [64] ) - InputTagHelper1 - InputTagHelper2 - InputTagHelper3 +TagHelper span at (64:0,64 [25] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.stree.txt new file mode 100644 index 0000000000..116e8180ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..37)::37 - [] + MarkupBlock - [0..37)::37 + MarkupTagHelperElement - [0..37)::37 - input[SelfClosing] - InputTagHelper + MarkupTagHelperStartTag - [0..37)::37 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMinimizedTagHelperAttribute - [6..16)::10 - boundbool - Minimized - Bound - [ boundbool] + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [7..16)::9 - [boundbool] - Gen - SpanEditHandler;Accepts:Any + Text;[boundbool]; + MarkupMinimizedTagHelperAttribute - [16..34)::18 - boundbooldict-key - Minimized - Bound - [ boundbooldict-key] + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [17..34)::17 - [boundbooldict-key] - Gen - SpanEditHandler;Accepts:Any + Text;[boundbooldict-key]; + MarkupMiscAttributeContent - [34..35)::1 + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.tspans.txt new file mode 100644 index 0000000000..c28ec2a704 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMinimizedBooleanBoundAttributes.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [37] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.cspans.txt new file mode 100644 index 0000000000..017c88aff0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.cspans.txt @@ -0,0 +1 @@ +Code span at (13:0,13 [13] ) (Accepts:AnyExceptNewline) - Parent: Tag block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.stree.txt new file mode 100644 index 0000000000..5a116dae22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..30)::30 - [] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - person[SelfClosing] - PersonTagHelper + MarkupTagHelperStartTag - [0..30)::30 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[person]; + MarkupTagHelperAttribute - [7..27)::20 - age - DoubleQuotes - Bound - [ age="(() => 123)()"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..11)::3 - [age] - Gen - SpanEditHandler;Accepts:Any + Text;[age]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [13..26)::13 + CSharpExpressionLiteral - [13..26)::13 - [(() => 123)()] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Text;[(()]; + Whitespace;[ ]; + Equals;[=]; + CloseAngle;[>]; + Whitespace;[ ]; + Text;[123)()]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [27..28)::1 + MarkupTextLiteral - [27..28)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.tspans.txt new file mode 100644 index 0000000000..6c93624813 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/UnderstandsMultipartNonStringTagHelperAttributes.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [30] ) - PersonTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers1.cspans.txt new file mode 100644 index 0000000000..4f69cb3f10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers1.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers1.stree.txt new file mode 100644 index 0000000000..c691ddf36b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers1.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..7)::7 - [] + MarkupBlock - [0..7)::7 + MarkupElement - [0..7)::7 + MarkupStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:]; + MarkupMiscAttributeContent - [4..5)::1 + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.cspans.txt new file mode 100644 index 0000000000..df2aec385d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [47] ) +Markup span at (21:0,21 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.stree.txt new file mode 100644 index 0000000000..5a1805b5d1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..47)::47 - [words and spaces] + MarkupBlock - [0..47)::47 + MarkupTagHelperElement - [0..47)::47 - th:myth[StartTagAndEndTag] - mythTagHelper + MarkupTagHelperStartTag - [0..21)::21 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth]; + MarkupTagHelperAttribute - [8..20)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [21..37)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [37..47)::10 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:myth]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.tspans.txt new file mode 100644 index 0000000000..a1b89d4d45 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [47] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.cspans.txt new file mode 100644 index 0000000000..b824ad55f1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (17:0,17 [1] ) (Accepts:None) - Parent: Expression block at (17:0,17 [13] ) +Code span at (18:0,18 [12] ) (Accepts:AnyExceptNewline) - Parent: Expression block at (17:0,17 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.stree.txt new file mode 100644 index 0000000000..59b74555a0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..34)::34 - [] + MarkupBlock - [0..34)::34 + MarkupTagHelperElement - [0..34)::34 - th:myth2[SelfClosing] - mythTagHelper2 + MarkupTagHelperStartTag - [0..34)::34 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth2]; + MarkupTagHelperAttribute - [9..31)::22 - bound - DoubleQuotes - Bound - [ bound="@DateTime.Now"] + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [10..15)::5 - [bound] - Gen - SpanEditHandler;Accepts:Any + Text;[bound]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [17..30)::13 + MarkupBlock - [17..30)::13 + CSharpCodeBlock - [17..30)::13 + CSharpImplicitExpression - [17..30)::13 + CSharpTransition - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [18..30)::12 + CSharpCodeBlock - [18..30)::12 + CSharpExpressionLiteral - [18..30)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [31..32)::1 + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.tspans.txt new file mode 100644 index 0000000000..33b53566f1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [34] ) - mythTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers2.cspans.txt new file mode 100644 index 0000000000..022d559da1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers2.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [16] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Markup span at (21:0,21 [6] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers2.stree.txt new file mode 100644 index 0000000000..e031e1ac8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers2.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..27)::27 - [words and spaces] + MarkupBlock - [0..27)::27 + MarkupElement - [0..27)::27 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:]; + CloseAngle;[>]; + MarkupTextLiteral - [5..21)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [21..27)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.stree.txt new file mode 100644 index 0000000000..0eb6fd801a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..11)::11 - [] + MarkupBlock - [0..11)::11 + MarkupTagHelperElement - [0..11)::11 - th:myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..11)::11 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth]; + MarkupMiscAttributeContent - [8..9)::1 + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.tspans.txt new file mode 100644 index 0000000000..20562b3e6b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [11] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.stree.txt new file mode 100644 index 0000000000..9f01e240d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..19)::19 - [] + MarkupBlock - [0..19)::19 + MarkupTagHelperElement - [0..19)::19 - th:myth[StartTagAndEndTag] - mythTagHelper + MarkupTagHelperStartTag - [0..9)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [9..19)::10 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:myth]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.tspans.txt new file mode 100644 index 0000000000..6dfea7ba4f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [19] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.cspans.txt new file mode 100644 index 0000000000..e868b55b3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (9:0,9 [10] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [10] ) +Markup span at (19:0,19 [11] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.stree.txt new file mode 100644 index 0000000000..bc5c8beed8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..40)::40 - [] + MarkupBlock - [0..40)::40 + MarkupTagHelperElement - [0..40)::40 - th:myth[StartTagAndEndTag] - mythTagHelper + MarkupTagHelperStartTag - [0..9)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth]; + CloseAngle;[>]; + MarkupElement - [9..30)::21 + MarkupStartTag - [9..19)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:my2th]; + CloseAngle;[>]; + MarkupEndTag - [19..30)::11 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:my2th]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [30..40)::10 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:myth]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.tspans.txt new file mode 100644 index 0000000000..9a9154c80d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [40] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers6.cspans.txt new file mode 100644 index 0000000000..d9e9a04dc1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers6.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [12] ) +Markup span at (2:0,2 [10] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers6.stree.txt new file mode 100644 index 0000000000..d5bc42d5e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers6.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..12)::12 - [] + MarkupBlock - [0..12)::12 + MarkupElement - [0..12)::12 + MarkupStartTag - [0..12)::12 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[th:myth]; + MarkupMiscAttributeContent - [9..10)::1 + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers7.cspans.txt new file mode 100644 index 0000000000..59cd08d3b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers7.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [10] ) +Markup span at (2:0,2 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [10] ) +Markup span at (10:0,10 [2] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [11] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Tag block at (10:0,10 [11] ) +Markup span at (13:0,13 [8] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers7.stree.txt new file mode 100644 index 0000000000..6f048dd34c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers7.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..21)::21 - [] + MarkupBlock - [0..21)::21 + MarkupElement - [0..21)::21 + MarkupStartTag - [0..10)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[th:myth]; + CloseAngle;[>]; + MarkupEndTag - [10..21)::11 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[th:myth]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.cspans.txt new file mode 100644 index 0000000000..3bc0454091 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.cspans.txt @@ -0,0 +1 @@ +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [23] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.stree.txt new file mode 100644 index 0000000000..a3ef260467 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..23)::23 - [] + MarkupBlock - [0..23)::23 + MarkupTagHelperElement - [0..23)::23 - th:myth[SelfClosing] - mythTagHelper + MarkupTagHelperStartTag - [0..23)::23 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth]; + MarkupTagHelperAttribute - [8..20)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [20..21)::1 + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.tspans.txt new file mode 100644 index 0000000000..17b38715bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [23] ) - mythTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.cspans.txt new file mode 100644 index 0000000000..7898d0d47e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.cspans.txt @@ -0,0 +1 @@ +Markup span at (17:0,17 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.stree.txt new file mode 100644 index 0000000000..d70be0ff14 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..24)::24 - th:myth2[SelfClosing] - mythTagHelper2 + MarkupTagHelperStartTag - [0..24)::24 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:myth2]; + MarkupTagHelperAttribute - [9..21)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [10..15)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [17..20)::3 + MarkupLiteralAttributeValue - [17..20)::3 - [btn] + MarkupTextLiteral - [17..20)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [21..22)::1 + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.tspans.txt new file mode 100644 index 0000000000..fba983601b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsPrefixedTagHelpers9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [24] ) - mythTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.cspans.txt new file mode 100644 index 0000000000..72a6a954d3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [3] ) +Markup span at (6:0,6 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (10:0,10 [4] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [4] ) +Transition span at (14:0,14 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [8] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [8] ) +Comment span at (16:0,16 [4] ) (Accepts:Any) - Parent: Comment block at (14:0,14 [8] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [8] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Comment block at (14:0,14 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.stree.txt new file mode 100644 index 0000000000..25ecc40085 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..26)::26 - [

                        asdf@*asdf*@

                        ] + MarkupBlock - [0..26)::26 + MarkupTagHelperElement - [0..26)::26 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..14)::11 + MarkupStartTag - [3..6)::3 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[b]; + CloseAngle;[>]; + MarkupTextLiteral - [6..10)::4 - [asdf] - Gen - SpanEditHandler;Accepts:Any + Text;[asdf]; + MarkupEndTag - [10..14)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[b]; + CloseAngle;[>]; + RazorComment - [14..22)::8 + RazorCommentTransition;[@]; + RazorCommentStar;[*]; + RazorCommentLiteral;[asdf]; + RazorCommentStar;[*]; + RazorCommentTransition;[@]; + MarkupTagHelperEndTag - [22..26)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.tspans.txt new file mode 100644 index 0000000000..41a4059c21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorCommentsAsChildren.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [26] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.cspans.txt new file mode 100644 index 0000000000..841cefa3f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [3] ) +Markup span at (6:0,6 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [37] ) +Markup span at (10:0,10 [4] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [4] ) +Markup span at (14:0,14 [4] ) (Accepts:None) - Parent: HtmlComment block at (14:0,14 [19] ) +Markup span at (18:0,18 [6] ) (Accepts:Whitespace) - Parent: HtmlComment block at (14:0,14 [19] ) +Transition span at (24:0,24 [1] ) (Accepts:None) - Parent: Expression block at (24:0,24 [6] ) +Code span at (25:0,25 [5] ) (Accepts:NonWhitespace) - Parent: Expression block at (24:0,24 [6] ) +Markup span at (30:0,30 [3] ) (Accepts:None) - Parent: HtmlComment block at (14:0,14 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.stree.txt new file mode 100644 index 0000000000..c66d2e2fd3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..37)::37 - [

                        asdf

                        ] + MarkupBlock - [0..37)::37 + MarkupTagHelperElement - [0..37)::37 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..14)::11 + MarkupStartTag - [3..6)::3 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[b]; + CloseAngle;[>]; + MarkupTextLiteral - [6..10)::4 - [asdf] - Gen - SpanEditHandler;Accepts:Any + Text;[asdf]; + MarkupEndTag - [10..14)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[b]; + CloseAngle;[>]; + MarkupCommentBlock - [14..33)::19 + MarkupTextLiteral - [14..18)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [33..37)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.tspans.txt new file mode 100644 index 0000000000..01ef9b42cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsRazorMarkupInHtmlComment.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [37] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.cspans.txt new file mode 100644 index 0000000000..df900ecba5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [3] ) +Markup span at (6:0,6 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [36] ) +Markup span at (10:0,10 [4] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [4] ) +Markup span at (14:0,14 [4] ) (Accepts:None) - Parent: HtmlComment block at (14:0,14 [18] ) +Markup span at (18:0,18 [11] ) (Accepts:Whitespace) - Parent: HtmlComment block at (14:0,14 [18] ) +Markup span at (29:0,29 [3] ) (Accepts:None) - Parent: HtmlComment block at (14:0,14 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.stree.txt new file mode 100644 index 0000000000..d619bdc2a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..36)::36 - [

                        asdf

                        ] + MarkupBlock - [0..36)::36 + MarkupTagHelperElement - [0..36)::36 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..14)::11 + MarkupStartTag - [3..6)::3 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[b]; + CloseAngle;[>]; + MarkupTextLiteral - [6..10)::4 - [asdf] - Gen - SpanEditHandler;Accepts:Any + Text;[asdf]; + MarkupEndTag - [10..14)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[b]; + CloseAngle;[>]; + MarkupCommentBlock - [14..32)::18 + MarkupTextLiteral - [14..18)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [32..36)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.tspans.txt new file mode 100644 index 0000000000..af2c446e1f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsSimpleHtmlCommentsAsChildren.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [36] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.cspans.txt new file mode 100644 index 0000000000..e473d0582c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [22] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [22] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (20:0,20 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (21:0,21 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [20] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.diag.txt new file mode 100644 index 0000000000..6f41e61f18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "!text" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.stree.txt new file mode 100644 index 0000000000..0cddbae480 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag1.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..22)::22 - [@{}] + MarkupBlock - [0..22)::22 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..22)::22 + CSharpStatement - [0..22)::22 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..22)::21 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..22)::20 + MarkupBlock - [2..22)::20 + MarkupElement - [2..22)::20 + MarkupStartTag - [2..21)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..20)::12 - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [21..22)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [22..22)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2.cspans.txt new file mode 100644 index 0000000000..a20ec606c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (20:0,20 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (21:0,21 [2] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [8] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Tag block at (21:0,21 [8] ) +Markup span at (24:0,24 [5] ) (Accepts:None) - Parent: Tag block at (21:0,21 [8] ) +Code span at (29:0,29 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [30] ) +MetaCode span at (29:0,29 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [30] ) +Markup span at (30:0,30 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2.stree.txt new file mode 100644 index 0000000000..33a85928e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag2.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..30)::30 - [@{}] + MarkupBlock - [0..30)::30 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..30)::30 + CSharpStatement - [0..30)::30 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..30)::29 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..29)::27 + MarkupBlock - [2..29)::27 + MarkupElement - [2..29)::27 + MarkupStartTag - [2..21)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..20)::12 - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupEndTag - [21..29)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [29..30)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3.cspans.txt new file mode 100644 index 0000000000..f4c2992c67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (20:0,20 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (21:0,21 [17] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [44] ) +Markup span at (38:0,38 [2] ) (Accepts:Any) - Parent: Tag block at (38:0,38 [8] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Tag block at (38:0,38 [8] ) +Markup span at (41:0,41 [5] ) (Accepts:None) - Parent: Tag block at (38:0,38 [8] ) +Code span at (46:0,46 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [47] ) +MetaCode span at (46:0,46 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +Markup span at (47:0,47 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3.stree.txt new file mode 100644 index 0000000000..a081ac9860 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag3.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..47)::47 - [@{words with spaces}] + MarkupBlock - [0..47)::47 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..47)::47 + CSharpStatement - [0..47)::47 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..47)::46 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..46)::44 + MarkupBlock - [2..46)::44 + MarkupElement - [2..46)::44 + MarkupStartTag - [2..21)::19 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..20)::12 - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [21..38)::17 - [words with spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[with]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [38..46)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [46..47)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4.cspans.txt new file mode 100644 index 0000000000..3c3a95f854 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [36] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [36] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [36] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [18] ) +Markup span at (16:0,16 [4] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [18] ) +Markup span at (20:0,20 [5] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [18] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [18] ) +Markup span at (26:0,26 [8] ) (Accepts:Any) - Parent: Markup block at (26:0,26 [11] ) +Markup span at (34:0,34 [3] ) (Accepts:Any) - Parent: Markup block at (26:0,26 [11] ) +Markup span at (37:0,37 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [36] ) +Markup span at (38:0,38 [2] ) (Accepts:Any) - Parent: Tag block at (38:0,38 [8] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Tag block at (38:0,38 [8] ) +Markup span at (41:0,41 [5] ) (Accepts:None) - Parent: Tag block at (38:0,38 [8] ) +Code span at (46:0,46 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [47] ) +MetaCode span at (46:0,46 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [47] ) +Markup span at (47:0,47 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4.stree.txt new file mode 100644 index 0000000000..0ce937b430 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag4.stree.txt @@ -0,0 +1,60 @@ +RazorDocument - [0..47)::47 - [@{}] + MarkupBlock - [0..47)::47 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..47)::47 + CSharpStatement - [0..47)::47 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..47)::46 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..46)::44 + MarkupBlock - [2..46)::44 + MarkupElement - [2..46)::44 + MarkupStartTag - [2..38)::36 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..26)::18 - [ class='btn1 btn2'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [16..25)::9 + MarkupLiteralAttributeValue - [16..20)::4 - [btn1] + MarkupTextLiteral - [16..20)::4 - [btn1] - Gen - SpanEditHandler;Accepts:Any + Text;[btn1]; + MarkupLiteralAttributeValue - [20..25)::5 - [ btn2] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [21..25)::4 - [btn2] - Gen - SpanEditHandler;Accepts:Any + Text;[btn2]; + MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [26..37)::11 - [ class2=btn] + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [27..33)::6 - [class2] - Gen - SpanEditHandler;Accepts:Any + Text;[class2]; + Equals;[=]; + GenericBlock - [34..37)::3 + MarkupLiteralAttributeValue - [34..37)::3 - [btn] + MarkupTextLiteral - [34..37)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + CloseAngle;[>]; + MarkupEndTag - [38..46)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [46..46)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [46..47)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5.cspans.txt new file mode 100644 index 0000000000..8543c4eeb6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5.cspans.txt @@ -0,0 +1,20 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [50] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [39] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [39] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [39] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [32] ) +Markup span at (16:0,16 [4] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [32] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (20:0,20 [14] ) +Transition span at (21:0,21 [1] ) (Accepts:None) - Parent: Expression block at (21:0,21 [13] ) +Code span at (22:0,22 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (21:0,21 [13] ) +Markup span at (34:0,34 [5] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [32] ) +Markup span at (39:0,39 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [32] ) +Markup span at (40:0,40 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [39] ) +Markup span at (41:0,41 [2] ) (Accepts:Any) - Parent: Tag block at (41:0,41 [8] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Tag block at (41:0,41 [8] ) +Markup span at (44:0,44 [5] ) (Accepts:None) - Parent: Tag block at (41:0,41 [8] ) +Code span at (49:0,49 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [50] ) +MetaCode span at (49:0,49 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [50] ) +Markup span at (50:0,50 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [50] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5.stree.txt new file mode 100644 index 0000000000..abdb6a42df --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithAttrTextTag5.stree.txt @@ -0,0 +1,64 @@ +RazorDocument - [0..50)::50 - [@{}] + MarkupBlock - [0..50)::50 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..50)::50 + CSharpStatement - [0..50)::50 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..50)::49 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..49)::47 + MarkupBlock - [2..49)::47 + MarkupElement - [2..49)::47 + MarkupStartTag - [2..41)::39 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..40)::32 - [ class='btn1 @DateTime.Now btn2'] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [16..39)::23 + MarkupLiteralAttributeValue - [16..20)::4 - [btn1] + MarkupTextLiteral - [16..20)::4 - [btn1] - Gen - SpanEditHandler;Accepts:Any + Text;[btn1]; + MarkupDynamicAttributeValue - [20..34)::14 - [ @DateTime.Now] + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + GenericBlock - [21..34)::13 + CSharpCodeBlock - [21..34)::13 + CSharpImplicitExpression - [21..34)::13 + CSharpTransition - [21..22)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [22..34)::12 + CSharpCodeBlock - [22..34)::12 + CSharpExpressionLiteral - [22..34)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [34..39)::5 - [ btn2] + MarkupTextLiteral - [34..35)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [35..39)::4 - [btn2] - Gen - SpanEditHandler;Accepts:Any + Text;[btn2]; + MarkupTextLiteral - [39..40)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [41..49)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [49..49)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [49..50)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [50..50)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.cspans.txt new file mode 100644 index 0000000000..4c82a55e34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [10] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [10] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (9:0,9 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.diag.txt new file mode 100644 index 0000000000..6f41e61f18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "!text" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.stree.txt new file mode 100644 index 0000000000..adc9746a55 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag1.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..10)::10 - [@{}] + MarkupBlock - [0..10)::10 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..10)::10 + CSharpStatement - [0..10)::10 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..10)::9 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..10)::8 + MarkupBlock - [2..10)::8 + MarkupElement - [2..10)::8 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [9..10)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [10..10)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.cspans.txt new file mode 100644 index 0000000000..d849d367fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [8] ) +MetaCode span at (4:0,4 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [8] ) +Markup span at (5:0,5 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [8] ) +Code span at (10:0,10 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.diag.txt new file mode 100644 index 0000000000..5bcfe7b2f4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1026: Encountered end tag "!text" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.stree.txt new file mode 100644 index 0000000000..fe12c3634d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag2.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..11)::11 - [@{}] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpStatement - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..10)::8 + MarkupBlock - [2..10)::8 + MarkupElement - [2..10)::8 + MarkupEndTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3.cspans.txt new file mode 100644 index 0000000000..8c4834386d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (9:0,9 [2] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [8] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Tag block at (9:0,9 [8] ) +Markup span at (12:0,12 [5] ) (Accepts:None) - Parent: Tag block at (9:0,9 [8] ) +Code span at (17:0,17 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [18] ) +MetaCode span at (17:0,17 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (18:0,18 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3.stree.txt new file mode 100644 index 0000000000..58e11b84c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag3.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..18)::18 - [@{}] + MarkupBlock - [0..18)::18 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + CSharpStatement - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..18)::17 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..17)::15 + MarkupBlock - [2..17)::15 + MarkupElement - [2..17)::15 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupEndTag - [9..17)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [17..18)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4.cspans.txt new file mode 100644 index 0000000000..8e4cc26c88 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (9:0,9 [16] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [31] ) +Markup span at (25:0,25 [2] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [8] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Tag block at (25:0,25 [8] ) +Markup span at (28:0,28 [5] ) (Accepts:None) - Parent: Tag block at (25:0,25 [8] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4.stree.txt new file mode 100644 index 0000000000..b9443879a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag4.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..34)::34 - [@{words and spaces}] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [9..25)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [25..33)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.cspans.txt new file mode 100644 index 0000000000..bceaf09553 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (9:0,9 [7] ) (Accepts:None) - Parent: Tag block at (9:0,9 [7] ) +Code span at (16:0,16 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.diag.txt new file mode 100644 index 0000000000..9e700e22b8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.diag.txt @@ -0,0 +1,2 @@ +(1,4): Error RZ1025: The "!text" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,12): Error RZ1034: Found a malformed 'text' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.stree.txt new file mode 100644 index 0000000000..89bf9b2706 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag5.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..17)::17 - [@{}] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpStatement - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..17)::16 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..16)::14 + MarkupBlock - [2..16)::14 + MarkupElement - [2..16)::14 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupElement - [9..16)::7 + MarkupEndTag - [9..16)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.cspans.txt new file mode 100644 index 0000000000..35c9da1c43 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [2] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [8] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Tag block at (8:0,8 [8] ) +Markup span at (11:0,11 [5] ) (Accepts:None) - Parent: Tag block at (8:0,8 [8] ) +Code span at (16:0,16 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (16:0,16 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (17:0,17 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.diag.txt new file mode 100644 index 0000000000..5b84341f8d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ1025: The "text" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.stree.txt new file mode 100644 index 0000000000..ae7f265b93 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag6.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..17)::17 - [@{}] + MarkupBlock - [0..17)::17 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpStatement - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..17)::16 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..16)::14 + MarkupBlock - [2..16)::14 + MarkupElement - [2..16)::14 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupElement - [8..16)::8 + MarkupEndTag - [8..16)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [17..17)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.cspans.txt new file mode 100644 index 0000000000..e4ec1ec100 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (22:0,22 [2] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [8] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Tag block at (22:0,22 [8] ) +Markup span at (25:0,25 [5] ) (Accepts:None) - Parent: Tag block at (22:0,22 [8] ) +Code span at (30:0,30 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [31] ) +MetaCode span at (30:0,30 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [31] ) +Markup span at (31:0,31 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.stree.txt new file mode 100644 index 0000000000..d6a9f5f320 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..31)::31 - [@{}] + MarkupBlock - [0..31)::31 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..31)::31 + CSharpStatement - [0..31)::31 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..31)::30 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..30)::28 + MarkupBlock - [2..30)::28 + MarkupElement - [2..30)::28 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupTagHelperElement - [9..22)::13 - text[StartTagAndEndTag] - texttaghelper + MarkupTagHelperStartTag - [9..15)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [15..22)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + MarkupEndTag - [22..30)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [30..30)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [30..31)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [31..31)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.tspans.txt new file mode 100644 index 0000000000..9f67aaf5a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (9:0,9 [13] ) - texttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.cspans.txt new file mode 100644 index 0000000000..c21ff53c60 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [1] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [7] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Tag block at (8:0,8 [7] ) +Markup span at (10:0,10 [5] ) (Accepts:None) - Parent: Tag block at (8:0,8 [7] ) +Markup span at (15:0,15 [2] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [8] ) +MetaCode span at (17:0,17 [1] ) (Accepts:None) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (18:0,18 [5] ) (Accepts:None) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [22] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.diag.txt new file mode 100644 index 0000000000..27a90c4a3e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "text" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.stree.txt new file mode 100644 index 0000000000..8841774978 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag8.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..24)::24 - [@{}] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + MarkupBlock - [2..24)::22 + MarkupElement - [2..24)::22 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupElement - [8..23)::15 + MarkupStartTag - [8..15)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupEndTag - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [23..24)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [24..24)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.cspans.txt new file mode 100644 index 0000000000..b311f8f748 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (9:0,9 [2] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [8] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Tag block at (9:0,9 [8] ) +Markup span at (12:0,12 [5] ) (Accepts:None) - Parent: Tag block at (9:0,9 [8] ) +Markup span at (17:0,17 [7] ) (Accepts:None) - Parent: Tag block at (17:0,17 [7] ) +Code span at (24:0,24 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.diag.txt new file mode 100644 index 0000000000..d82bb8c1a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.diag.txt @@ -0,0 +1,2 @@ +(1,20): Error RZ1026: Encountered end tag "text" with no matching start tag. Are your start/end tags properly balanced? +(1,20): Error RZ1034: Found a malformed 'text' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.stree.txt new file mode 100644 index 0000000000..dd66d9333a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTHElementOptForCompleteTextTagInCSharpBlock_WithBlockTextTag9.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..25)::25 - [@{}] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + MarkupBlock - [2..17)::15 + MarkupElement - [2..17)::15 + MarkupStartTag - [2..9)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupEndTag - [9..17)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[text]; + CloseAngle;[>]; + MarkupBlock - [17..24)::7 + MarkupElement - [17..24)::7 + MarkupEndTag - [17..24)::7 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML1.cspans.txt new file mode 100644 index 0000000000..68230d2f76 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML1.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML1.stree.txt new file mode 100644 index 0000000000..61c1a03dc4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML1.stree.txt @@ -0,0 +1,5 @@ +RazorDocument - [0..2)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML2.cspans.txt new file mode 100644 index 0000000000..108c031df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML2.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML2.stree.txt new file mode 100644 index 0000000000..10d9274ac3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML2.stree.txt @@ -0,0 +1,8 @@ +RazorDocument - [0..3)::3 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML3.cspans.txt new file mode 100644 index 0000000000..9bdd5fbf73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (2:0,2 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML3.stree.txt new file mode 100644 index 0000000000..c9bce33c62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML3.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..5)::5 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupMiscAttributeContent - [3..4)::1 + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [4..5)::1 + MarkupTextLiteral - [4..5)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML4.cspans.txt new file mode 100644 index 0000000000..30af8ce509 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [10] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [10] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [10] ) +Markup span at (3:0,3 [7] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML4.stree.txt new file mode 100644 index 0000000000..3a7cde5335 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML4.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..10)::10 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..10)::7 - [ class=] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML5.cspans.txt new file mode 100644 index 0000000000..9c594e7ceb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML5.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [14] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [11] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML5.stree.txt new file mode 100644 index 0000000000..b78dfe1d29 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML5.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..14)::14 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..14)::11 - [ class="btn] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [btn] + MarkupTextLiteral - [11..14)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML6.cspans.txt new file mode 100644 index 0000000000..dd532d116d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML6.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML6.stree.txt new file mode 100644 index 0000000000..d69071ac02 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML6.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..15)::15 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..15)::12 - [ class="btn"] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [btn] + MarkupTextLiteral - [11..14)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML7.cspans.txt new file mode 100644 index 0000000000..524195f446 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML7.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [17] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (15:0,15 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML7.stree.txt new file mode 100644 index 0000000000..cbd61e6fb5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTML7.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..17)::17 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..15)::12 - [ class="btn"] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [btn] + MarkupTextLiteral - [11..14)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [15..16)::1 + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.cspans.txt new file mode 100644 index 0000000000..e2f572686f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [5] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [5] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [3] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [3] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.diag.txt new file mode 100644 index 0000000000..5e05d58d34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.stree.txt new file mode 100644 index 0000000000..22f2b09439 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock1.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..5)::5 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..5)::5 + CSharpStatement - [0..5)::5 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..5)::4 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..5)::3 + MarkupBlock - [2..5)::3 + MarkupElement - [2..5)::3 + MarkupStartTag - [2..5)::3 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [5..5)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.cspans.txt new file mode 100644 index 0000000000..269e709b18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [6] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [6] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [6] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.diag.txt new file mode 100644 index 0000000000..7fcf4c636a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.stree.txt new file mode 100644 index 0000000000..3e5244b17f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock2.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..6)::6 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..6)::6 + CSharpStatement - [0..6)::6 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..6)::5 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..6)::4 + MarkupBlock - [2..6)::4 + MarkupElement - [2..6)::4 + MarkupStartTag - [2..6)::4 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p}]; + CloseAngle;[]; + RazorMetaCode - [6..6)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.cspans.txt new file mode 100644 index 0000000000..3686f93385 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [8] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [6] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (4:0,4 [3] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (7:0,7 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.diag.txt new file mode 100644 index 0000000000..7f76f09dfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.stree.txt new file mode 100644 index 0000000000..c3079ddde3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock3.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..8)::8 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpStatement - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..8)::7 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..8)::6 + MarkupBlock - [2..8)::6 + MarkupElement - [2..8)::6 + MarkupStartTag - [2..8)::6 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupMiscAttributeContent - [5..6)::1 + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupMinimizedAttributeBlock - [7..8)::1 - [}] + MarkupTextLiteral - [7..8)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [8..8)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.cspans.txt new file mode 100644 index 0000000000..ae931de581 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [13] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [13] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [11] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [11] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [11] ) +Markup span at (5:0,5 [7] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [8] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.diag.txt new file mode 100644 index 0000000000..7f76f09dfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.stree.txt new file mode 100644 index 0000000000..ee610d65e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock4.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..13)::13 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..13)::13 + CSharpStatement - [0..13)::13 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..13)::12 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..13)::11 + MarkupBlock - [2..13)::11 + MarkupElement - [2..13)::11 + MarkupStartTag - [2..13)::11 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..13)::8 - [ class=}] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + GenericBlock - [12..13)::1 + MarkupLiteralAttributeValue - [12..13)::1 - [}] + MarkupTextLiteral - [12..13)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [13..13)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.cspans.txt new file mode 100644 index 0000000000..497c2da8bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [17] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [17] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [15] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [15] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [15] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.diag.txt new file mode 100644 index 0000000000..7f76f09dfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.stree.txt new file mode 100644 index 0000000000..006b6b4d11 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock5.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..17)::17 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..17)::17 + CSharpStatement - [0..17)::17 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..17)::16 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..17)::15 + MarkupBlock - [2..17)::15 + MarkupElement - [2..17)::15 + MarkupStartTag - [2..17)::15 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..17)::12 - [ class="btn}] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..17)::4 + MarkupLiteralAttributeValue - [13..17)::4 - [btn}] + MarkupTextLiteral - [13..17)::4 - [btn}] - Gen - SpanEditHandler;Accepts:Any + Text;[btn}]; + CloseAngle;[]; + RazorMetaCode - [17..17)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.cspans.txt new file mode 100644 index 0000000000..7280874c3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [17] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [17] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [17] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [14] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [14] ) +Markup span at (16:0,16 [1] ) (Accepts:None) - Parent: Markup block at (16:0,16 [2] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Markup block at (16:0,16 [2] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.diag.txt new file mode 100644 index 0000000000..7f76f09dfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.stree.txt new file mode 100644 index 0000000000..0c4ef5f368 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock6.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..19)::19 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpStatement - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..19)::18 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..19)::17 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..19)::14 - [ class="btn@@}] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..19)::6 + MarkupLiteralAttributeValue - [13..16)::3 - [btn] + MarkupTextLiteral - [13..16)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupBlock - [16..18)::2 + MarkupTextLiteral - [16..17)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [17..18)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [18..19)::1 - [}] + MarkupTextLiteral - [18..19)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [19..19)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.cspans.txt new file mode 100644 index 0000000000..f1e91016d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [18] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.diag.txt new file mode 100644 index 0000000000..7f76f09dfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.stree.txt new file mode 100644 index 0000000000..8cadcccfc7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock7.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..18)::18 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..18)::18 + CSharpStatement - [0..18)::18 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..18)::17 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..18)::16 + MarkupBlock - [2..18)::16 + MarkupElement - [2..18)::16 + MarkupStartTag - [2..18)::16 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..17)::12 - [ class="btn"] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [btn] + MarkupTextLiteral - [13..16)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMinimizedAttributeBlock - [17..18)::1 - [}] + MarkupTextLiteral - [17..18)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [18..18)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.cspans.txt new file mode 100644 index 0000000000..a5183e69ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (17:0,17 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (19:0,19 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.diag.txt new file mode 100644 index 0000000000..7f76f09dfe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!p" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.stree.txt new file mode 100644 index 0000000000..3bf562e849 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteHTMLInCSharpBlock8.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..20)::20 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..20)::18 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..17)::12 - [ class="btn"] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [btn] + MarkupTextLiteral - [13..16)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [17..18)::1 + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [18..19)::1 + MarkupTextLiteral - [18..19)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupMinimizedAttributeBlock - [19..20)::1 - [}] + MarkupTextLiteral - [19..20)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [20..20)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.cspans.txt new file mode 100644 index 0000000000..f4f4680be7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [9] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [9] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [9] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [7] ) +Markup span at (4:0,4 [5] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.diag.txt new file mode 100644 index 0000000000..c9edfe9426 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!text}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.stree.txt new file mode 100644 index 0000000000..35c2ab7638 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock1.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..9)::9 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..9)::9 + CSharpStatement - [0..9)::9 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..9)::8 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..9)::7 + MarkupBlock - [2..9)::7 + MarkupElement - [2..9)::7 + MarkupStartTag - [2..9)::7 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[text}]; + CloseAngle;[]; + RazorMetaCode - [9..9)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.cspans.txt new file mode 100644 index 0000000000..18195965b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [9] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [9] ) +Markup span at (4:0,4 [6] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [9] ) +Markup span at (10:0,10 [1] ) (Accepts:Any) - Parent: Markup block at (10:0,10 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.diag.txt new file mode 100644 index 0000000000..2edb2cd77e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!text" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.stree.txt new file mode 100644 index 0000000000..39f47161bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock2.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..11)::11 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpStatement - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..11)::9 + MarkupBlock - [2..11)::9 + MarkupElement - [2..11)::9 + MarkupStartTag - [2..11)::9 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupMiscAttributeContent - [8..9)::1 + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [9..10)::1 + MarkupTextLiteral - [9..10)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupMinimizedAttributeBlock - [10..11)::1 - [}] + MarkupTextLiteral - [10..11)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [11..11)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.cspans.txt new file mode 100644 index 0000000000..0e8da83799 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [14] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [14] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [14] ) +Markup span at (8:0,8 [7] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [8] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.diag.txt new file mode 100644 index 0000000000..2edb2cd77e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!text" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.stree.txt new file mode 100644 index 0000000000..1c0539e3ac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock3.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..16)::16 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + CSharpStatement - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..16)::15 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..16)::14 + MarkupBlock - [2..16)::14 + MarkupElement - [2..16)::14 + MarkupStartTag - [2..16)::14 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..16)::8 - [ class=}] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + GenericBlock - [15..16)::1 + MarkupLiteralAttributeValue - [15..16)::1 - [}] + MarkupTextLiteral - [15..16)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [16..16)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.cspans.txt new file mode 100644 index 0000000000..c8e364dcaf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [20] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [20] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [18] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (16:0,16 [4] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.diag.txt new file mode 100644 index 0000000000..2edb2cd77e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!text" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.stree.txt new file mode 100644 index 0000000000..f9d5e6ef3c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock4.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..20)::20 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..20)::20 + CSharpStatement - [0..20)::20 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..20)::19 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..20)::18 + MarkupBlock - [2..20)::18 + MarkupElement - [2..20)::18 + MarkupStartTag - [2..20)::18 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..20)::12 - [ class="btn}] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [16..20)::4 + MarkupLiteralAttributeValue - [16..20)::4 - [btn}] + MarkupTextLiteral - [16..20)::4 - [btn}] - Gen - SpanEditHandler;Accepts:Any + Text;[btn}]; + CloseAngle;[]; + RazorMetaCode - [20..20)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.cspans.txt new file mode 100644 index 0000000000..e0c99a858b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [21] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [21] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [19] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (20:0,20 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.diag.txt new file mode 100644 index 0000000000..2edb2cd77e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!text" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.stree.txt new file mode 100644 index 0000000000..4aef8cae46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock5.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..21)::21 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..21)::21 + CSharpStatement - [0..21)::21 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..21)::20 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..21)::19 + MarkupBlock - [2..21)::19 + MarkupElement - [2..21)::19 + MarkupStartTag - [2..21)::19 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..20)::12 - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMinimizedAttributeBlock - [20..21)::1 - [}] + MarkupTextLiteral - [20..21)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [21..21)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.cspans.txt new file mode 100644 index 0000000000..20509e6706 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [23] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [23] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [21] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [21] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [21] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (8:0,8 [12] ) +Markup span at (20:0,20 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [21] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.diag.txt new file mode 100644 index 0000000000..2edb2cd77e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1024: End of file or an unexpected character was reached before the "!text" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
                        ") or have matching end tags ("

                        Hello

                        "). If you intended to display a "<" character, use the "<" HTML entity. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.stree.txt new file mode 100644 index 0000000000..70dc270938 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock6.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..23)::23 - [@{ - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..23)::23 + CSharpStatement - [0..23)::23 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..23)::22 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + MarkupBlock - [2..23)::21 + MarkupElement - [2..23)::21 + MarkupStartTag - [2..23)::21 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[text]; + MarkupAttributeBlock - [8..20)::12 - [ class="btn"] + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [9..14)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [16..19)::3 + MarkupLiteralAttributeValue - [16..19)::3 - [btn] + MarkupTextLiteral - [16..19)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [19..20)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [20..21)::1 + MarkupTextLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupMiscAttributeContent - [21..22)::1 + MarkupTextLiteral - [21..22)::1 - [/] - Gen - SpanEditHandler;Accepts:Any + ForwardSlash;[/]; + MarkupMinimizedAttributeBlock - [22..23)::1 - [}] + MarkupTextLiteral - [22..23)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + CloseAngle;[]; + RazorMetaCode - [23..23)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.cspans.txt new file mode 100644 index 0000000000..e4c8d0d243 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (18:0,18 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.diag.txt new file mode 100644 index 0000000000..d208c6a957 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "!p" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.stree.txt new file mode 100644 index 0000000000..b71f09adf6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData1.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..19)::19 - [@{}] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpStatement - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..19)::18 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..19)::17 + MarkupBlock - [2..19)::17 + MarkupElement - [2..19)::17 + MarkupStartTag - [2..18)::16 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..17)::12 - [ class="btn"] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [btn] + MarkupTextLiteral - [13..16)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [18..19)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [19..19)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData2.cspans.txt new file mode 100644 index 0000000000..cf364bf3b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData2.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [5] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Tag block at (18:0,18 [5] ) +Markup span at (21:0,21 [2] ) (Accepts:None) - Parent: Tag block at (18:0,18 [5] ) +Code span at (23:0,23 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [24] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [24] ) +Markup span at (24:0,24 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData2.stree.txt new file mode 100644 index 0000000000..5f02516c0c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData2.stree.txt @@ -0,0 +1,45 @@ +RazorDocument - [0..24)::24 - [@{}] + MarkupBlock - [0..24)::24 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..24)::24 + CSharpStatement - [0..24)::24 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..24)::23 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..23)::21 + MarkupBlock - [2..23)::21 + MarkupElement - [2..23)::21 + MarkupStartTag - [2..18)::16 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..17)::12 - [ class="btn"] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [btn] + MarkupTextLiteral - [13..16)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupEndTag - [18..23)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [23..23)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [23..24)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData3.cspans.txt new file mode 100644 index 0000000000..60b9da83b0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData3.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (13:0,13 [3] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [12] ) +Markup span at (17:0,17 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [16] ) +Markup span at (18:0,18 [17] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [38] ) +Markup span at (35:0,35 [2] ) (Accepts:Any) - Parent: Tag block at (35:0,35 [5] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Tag block at (35:0,35 [5] ) +Markup span at (38:0,38 [2] ) (Accepts:None) - Parent: Tag block at (35:0,35 [5] ) +Code span at (40:0,40 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (41:0,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData3.stree.txt new file mode 100644 index 0000000000..5aceb7e8f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData3.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..41)::41 - [@{words with spaces}] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + CSharpStatement - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..41)::40 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..40)::38 + MarkupBlock - [2..40)::38 + MarkupElement - [2..40)::38 + MarkupStartTag - [2..18)::16 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..17)::12 - [ class="btn"] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [13..16)::3 + MarkupLiteralAttributeValue - [13..16)::3 - [btn] + MarkupTextLiteral - [13..16)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [16..17)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [18..35)::17 - [words with spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[with]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [35..40)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [40..41)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData4.cspans.txt new file mode 100644 index 0000000000..f3fec76103 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData4.cspans.txt @@ -0,0 +1,19 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [33] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [33] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [33] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [18] ) +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [18] ) +Markup span at (17:0,17 [5] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [18] ) +Markup span at (22:0,22 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [18] ) +Markup span at (23:0,23 [8] ) (Accepts:Any) - Parent: Markup block at (23:0,23 [11] ) +Markup span at (31:0,31 [3] ) (Accepts:Any) - Parent: Markup block at (23:0,23 [11] ) +Markup span at (34:0,34 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [33] ) +Markup span at (35:0,35 [2] ) (Accepts:Any) - Parent: Tag block at (35:0,35 [5] ) +MetaCode span at (37:0,37 [1] ) (Accepts:None) - Parent: Tag block at (35:0,35 [5] ) +Markup span at (38:0,38 [2] ) (Accepts:None) - Parent: Tag block at (35:0,35 [5] ) +Code span at (40:0,40 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [41] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [41] ) +Markup span at (41:0,41 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData4.stree.txt new file mode 100644 index 0000000000..a7a0e0f91b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData4.stree.txt @@ -0,0 +1,60 @@ +RazorDocument - [0..41)::41 - [@{}] + MarkupBlock - [0..41)::41 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..41)::41 + CSharpStatement - [0..41)::41 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..41)::40 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..40)::38 + MarkupBlock - [2..40)::38 + MarkupElement - [2..40)::38 + MarkupStartTag - [2..35)::33 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..23)::18 - [ class='btn1 btn2'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..22)::9 + MarkupLiteralAttributeValue - [13..17)::4 - [btn1] + MarkupTextLiteral - [13..17)::4 - [btn1] - Gen - SpanEditHandler;Accepts:Any + Text;[btn1]; + MarkupLiteralAttributeValue - [17..22)::5 - [ btn2] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..22)::4 - [btn2] - Gen - SpanEditHandler;Accepts:Any + Text;[btn2]; + MarkupTextLiteral - [22..23)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [23..34)::11 - [ class2=btn] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..30)::6 - [class2] - Gen - SpanEditHandler;Accepts:Any + Text;[class2]; + Equals;[=]; + GenericBlock - [31..34)::3 + MarkupLiteralAttributeValue - [31..34)::3 - [btn] + MarkupTextLiteral - [31..34)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + CloseAngle;[>]; + MarkupEndTag - [35..40)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [40..40)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [40..41)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData5.cspans.txt new file mode 100644 index 0000000000..a539659df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData5.cspans.txt @@ -0,0 +1,20 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [36] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [36] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [36] ) +Markup span at (5:0,5 [8] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [32] ) +Markup span at (13:0,13 [4] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [32] ) +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Markup block at (17:0,17 [14] ) +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Expression block at (18:0,18 [13] ) +Code span at (19:0,19 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (18:0,18 [13] ) +Markup span at (31:0,31 [5] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [32] ) +Markup span at (36:0,36 [1] ) (Accepts:Any) - Parent: Markup block at (5:0,5 [32] ) +Markup span at (37:0,37 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [36] ) +Markup span at (38:0,38 [2] ) (Accepts:Any) - Parent: Tag block at (38:0,38 [5] ) +MetaCode span at (40:0,40 [1] ) (Accepts:None) - Parent: Tag block at (38:0,38 [5] ) +Markup span at (41:0,41 [2] ) (Accepts:None) - Parent: Tag block at (38:0,38 [5] ) +Code span at (43:0,43 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [44] ) +MetaCode span at (43:0,43 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [44] ) +Markup span at (44:0,44 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData5.stree.txt new file mode 100644 index 0000000000..08bccd56b5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithAttributeData5.stree.txt @@ -0,0 +1,64 @@ +RazorDocument - [0..44)::44 - [@{}] + MarkupBlock - [0..44)::44 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..44)::44 + CSharpStatement - [0..44)::44 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..44)::43 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..43)::41 + MarkupBlock - [2..43)::41 + MarkupElement - [2..43)::41 + MarkupStartTag - [2..38)::36 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [5..37)::32 - [ class='btn1 @DateTime.Now btn2'] + MarkupTextLiteral - [5..6)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [6..11)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [12..13)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [13..36)::23 + MarkupLiteralAttributeValue - [13..17)::4 - [btn1] + MarkupTextLiteral - [13..17)::4 - [btn1] - Gen - SpanEditHandler;Accepts:Any + Text;[btn1]; + MarkupDynamicAttributeValue - [17..31)::14 - [ @DateTime.Now] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + GenericBlock - [18..31)::13 + CSharpCodeBlock - [18..31)::13 + CSharpImplicitExpression - [18..31)::13 + CSharpTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [19..31)::12 + CSharpCodeBlock - [19..31)::12 + CSharpExpressionLiteral - [19..31)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [31..36)::5 - [ btn2] + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [32..36)::4 - [btn2] - Gen - SpanEditHandler;Accepts:Any + Text;[btn2]; + MarkupTextLiteral - [36..37)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [38..43)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [43..43)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [43..44)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [44..44)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.cspans.txt new file mode 100644 index 0000000000..17ced29a2c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [7] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [7] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (6:0,6 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.diag.txt new file mode 100644 index 0000000000..d208c6a957 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "!p" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.stree.txt new file mode 100644 index 0000000000..e3f97b1ee0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData1.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..7)::7 - [@{}] + MarkupBlock - [0..7)::7 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..7)::7 + CSharpStatement - [0..7)::7 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..7)::6 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..7)::5 + MarkupBlock - [2..7)::5 + MarkupElement - [2..7)::5 + MarkupStartTag - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [6..7)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [7..7)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.cspans.txt new file mode 100644 index 0000000000..7e92920d2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (10:0,10 [2] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [5] ) +MetaCode span at (12:0,12 [1] ) (Accepts:None) - Parent: Tag block at (10:0,10 [5] ) +Markup span at (13:0,13 [2] ) (Accepts:None) - Parent: Tag block at (10:0,10 [5] ) +Markup span at (15:0,15 [9] ) (Accepts:None) - Parent: Tag block at (15:0,15 [9] ) +Code span at (24:0,24 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [25] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [25] ) +Markup span at (25:0,25 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.diag.txt new file mode 100644 index 0000000000..fba405aa8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.diag.txt @@ -0,0 +1,4 @@ +(1,4): Error RZ1025: The "strong" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,4): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,18): Error RZ1026: Encountered end tag "strong" with no matching start tag. Are your start/end tags properly balanced? +(1,18): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.stree.txt new file mode 100644 index 0000000000..ac9f4cfbdb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..25)::25 - [@{}] + MarkupBlock - [0..25)::25 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..25)::25 + CSharpStatement - [0..25)::25 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..25)::24 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..24)::22 + MarkupBlock - [2..15)::13 + MarkupTagHelperElement - [2..15)::13 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [10..15)::5 + MarkupEndTag - [10..15)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupBlock - [15..24)::9 + MarkupElement - [15..24)::9 + MarkupEndTag - [15..24)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + CSharpStatementLiteral - [24..24)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [24..25)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [25..25)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.tspans.txt new file mode 100644 index 0000000000..b716a36b7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [13] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.cspans.txt new file mode 100644 index 0000000000..a52c9fcb71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [4] ) +MetaCode span at (20:0,20 [1] ) (Accepts:None) - Parent: Tag block at (19:0,19 [4] ) +Markup span at (21:0,21 [2] ) (Accepts:None) - Parent: Tag block at (19:0,19 [4] ) +Markup span at (23:0,23 [2] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [5] ) +MetaCode span at (25:0,25 [1] ) (Accepts:None) - Parent: Tag block at (23:0,23 [5] ) +Markup span at (26:0,26 [2] ) (Accepts:None) - Parent: Tag block at (23:0,23 [5] ) +Code span at (28:0,28 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [29] ) +MetaCode span at (28:0,28 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [29] ) +Markup span at (29:0,29 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.stree.txt new file mode 100644 index 0000000000..c671926a25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..29)::29 - [@{}] + MarkupBlock - [0..29)::29 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..29)::29 + CSharpStatement - [0..29)::29 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..29)::28 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..28)::26 + MarkupBlock - [2..19)::17 + MarkupTagHelperElement - [2..19)::17 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [2..10)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [10..19)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupBlock - [19..28)::9 + MarkupElement - [19..28)::9 + MarkupStartTag - [19..23)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [23..28)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [28..29)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [29..29)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.tspans.txt new file mode 100644 index 0000000000..92502ed333 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [17] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.cspans.txt new file mode 100644 index 0000000000..54f4240fc7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.cspans.txt @@ -0,0 +1,16 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (13:0,13 [2] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [10] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Tag block at (13:0,13 [10] ) +Markup span at (16:0,16 [7] ) (Accepts:None) - Parent: Tag block at (13:0,13 [10] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [4] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Tag block at (23:0,23 [4] ) +Markup span at (25:0,25 [2] ) (Accepts:None) - Parent: Tag block at (23:0,23 [4] ) +Markup span at (27:0,27 [9] ) (Accepts:None) - Parent: Tag block at (27:0,27 [9] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [5] ) +MetaCode span at (38:0,38 [1] ) (Accepts:None) - Parent: Tag block at (36:0,36 [5] ) +Markup span at (39:0,39 [2] ) (Accepts:None) - Parent: Tag block at (36:0,36 [5] ) +Code span at (41:0,41 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [42] ) +MetaCode span at (41:0,41 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [42] ) +Markup span at (42:0,42 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.diag.txt new file mode 100644 index 0000000000..689fbedb41 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.diag.txt @@ -0,0 +1,6 @@ +(1,4): Error RZ1025: The "p" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,4): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,7): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,25): Error RZ1025: The "!p" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,30): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,39): Error RZ1026: Encountered end tag "!p" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.stree.txt new file mode 100644 index 0000000000..f727a4a496 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.stree.txt @@ -0,0 +1,57 @@ +RazorDocument - [0..42)::42 - [@{

                        }] + MarkupBlock - [0..42)::42 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..42)::42 + CSharpStatement - [0..42)::42 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..42)::41 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..41)::39 + MarkupBlock - [2..23)::21 + MarkupTagHelperElement - [2..23)::21 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [2..5)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [5..23)::18 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [5..13)::8 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [13..23)::10 + MarkupEndTag - [13..23)::10 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[strong]; + CloseAngle;[>]; + MarkupBlock - [23..36)::13 + MarkupElement - [23..36)::13 + MarkupStartTag - [23..27)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [27..36)::9 + MarkupEndTag - [27..36)::9 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupBlock - [36..41)::5 + MarkupElement - [36..41)::5 + MarkupEndTag - [36..41)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [41..41)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [42..42)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.tspans.txt new file mode 100644 index 0000000000..0357429d3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData12.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (2:0,2 [21] ) - ptaghelper +TagHelper span at (5:0,5 [18] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.cspans.txt new file mode 100644 index 0000000000..5841f5eb8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [8] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [8] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [5] ) +MetaCode span at (4:0,4 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Markup span at (5:0,5 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [5] ) +Code span at (7:0,7 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [8] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [8] ) +Markup span at (8:0,8 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.diag.txt new file mode 100644 index 0000000000..16ad86d5a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ1026: Encountered end tag "!p" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.stree.txt new file mode 100644 index 0000000000..5115d2c63a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData2.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..8)::8 - [@{}] + MarkupBlock - [0..8)::8 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..8)::8 + CSharpStatement - [0..8)::8 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..8)::7 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..7)::5 + MarkupBlock - [2..7)::5 + MarkupElement - [2..7)::5 + MarkupEndTag - [2..7)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [7..7)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [7..8)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [8..8)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData3.cspans.txt new file mode 100644 index 0000000000..87859bb82c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData3.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [5] ) +MetaCode span at (8:0,8 [1] ) (Accepts:None) - Parent: Tag block at (6:0,6 [5] ) +Markup span at (9:0,9 [2] ) (Accepts:None) - Parent: Tag block at (6:0,6 [5] ) +Code span at (11:0,11 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [12] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [12] ) +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData3.stree.txt new file mode 100644 index 0000000000..cf036dfe25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData3.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..12)::12 - [@{}] + MarkupBlock - [0..12)::12 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..12)::12 + CSharpStatement - [0..12)::12 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..12)::11 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..11)::9 + MarkupBlock - [2..11)::9 + MarkupElement - [2..11)::9 + MarkupStartTag - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [6..11)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [12..12)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData4.cspans.txt new file mode 100644 index 0000000000..d09cd360c0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData4.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (6:0,6 [16] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [25] ) +Markup span at (22:0,22 [2] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [5] ) +MetaCode span at (24:0,24 [1] ) (Accepts:None) - Parent: Tag block at (22:0,22 [5] ) +Markup span at (25:0,25 [2] ) (Accepts:None) - Parent: Tag block at (22:0,22 [5] ) +Code span at (27:0,27 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [28] ) +MetaCode span at (27:0,27 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [28] ) +Markup span at (28:0,28 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData4.stree.txt new file mode 100644 index 0000000000..f7e5009478 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData4.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..28)::28 - [@{words and spaces}] + MarkupBlock - [0..28)::28 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..28)::28 + CSharpStatement - [0..28)::28 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..28)::27 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..27)::25 + MarkupBlock - [2..27)::25 + MarkupElement - [2..27)::25 + MarkupStartTag - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [6..22)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [22..27)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [27..28)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [28..28)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.cspans.txt new file mode 100644 index 0000000000..bde99188a2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (6:0,6 [4] ) (Accepts:None) - Parent: Tag block at (6:0,6 [4] ) +Code span at (10:0,10 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.diag.txt new file mode 100644 index 0000000000..4e9f9e044a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.diag.txt @@ -0,0 +1,2 @@ +(1,4): Error RZ1025: The "!p" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,9): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.stree.txt new file mode 100644 index 0000000000..423490c99b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData5.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..11)::11 - [@{

                        }] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpStatement - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..10)::8 + MarkupBlock - [2..10)::8 + MarkupElement - [2..10)::8 + MarkupStartTag - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [6..10)::4 + MarkupEndTag - [6..10)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.cspans.txt new file mode 100644 index 0000000000..894887f157 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (5:0,5 [2] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [5] ) +MetaCode span at (7:0,7 [1] ) (Accepts:None) - Parent: Tag block at (5:0,5 [5] ) +Markup span at (8:0,8 [2] ) (Accepts:None) - Parent: Tag block at (5:0,5 [5] ) +Code span at (10:0,10 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [11] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [11] ) +Markup span at (11:0,11 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [11] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.diag.txt new file mode 100644 index 0000000000..9245068ef6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.diag.txt @@ -0,0 +1,2 @@ +(1,4): Error RZ1025: The "p" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,4): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.stree.txt new file mode 100644 index 0000000000..ac047895b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..11)::11 - [@{

                        }] + MarkupBlock - [0..11)::11 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..11)::11 + CSharpStatement - [0..11)::11 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..11)::10 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..10)::8 + MarkupBlock - [2..10)::8 + MarkupTagHelperElement - [2..10)::8 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [2..5)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [5..10)::5 + MarkupEndTag - [5..10)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [10..10)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [11..11)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.tspans.txt new file mode 100644 index 0000000000..c896ab151f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [8] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.cspans.txt new file mode 100644 index 0000000000..6e8f3d69b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (5:0,5 [1] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [4] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Tag block at (5:0,5 [4] ) +Markup span at (7:0,7 [2] ) (Accepts:None) - Parent: Tag block at (5:0,5 [4] ) +Markup span at (9:0,9 [2] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [5] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Tag block at (9:0,9 [5] ) +Markup span at (12:0,12 [2] ) (Accepts:None) - Parent: Tag block at (9:0,9 [5] ) +Code span at (18:0,18 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [19] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [19] ) +Markup span at (19:0,19 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.stree.txt new file mode 100644 index 0000000000..2320bcb8db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..19)::19 - [@{

                        }] + MarkupBlock - [0..19)::19 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..19)::19 + CSharpStatement - [0..19)::19 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..19)::18 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..18)::16 + MarkupBlock - [2..18)::16 + MarkupTagHelperElement - [2..18)::16 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [2..5)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [5..14)::9 + MarkupStartTag - [5..9)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [9..14)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [14..18)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [18..18)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [19..19)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.tspans.txt new file mode 100644 index 0000000000..9ac9825e33 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [16] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.cspans.txt new file mode 100644 index 0000000000..761b9a637b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [15] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [15] ) +Markup span at (5:0,5 [1] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [4] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Tag block at (5:0,5 [4] ) +Markup span at (7:0,7 [2] ) (Accepts:None) - Parent: Tag block at (5:0,5 [4] ) +Markup span at (9:0,9 [2] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [5] ) +MetaCode span at (11:0,11 [1] ) (Accepts:None) - Parent: Tag block at (9:0,9 [5] ) +Markup span at (12:0,12 [2] ) (Accepts:None) - Parent: Tag block at (9:0,9 [5] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.diag.txt new file mode 100644 index 0000000000..0ef166cfd0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.diag.txt @@ -0,0 +1,3 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(1,4): Error RZ1025: The "p" element was not closed. All elements must be either self-closing or have a matching end tag. +(1,4): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.stree.txt new file mode 100644 index 0000000000..ae602bff26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..15)::15 - [@{

                        }] + MarkupBlock - [0..15)::15 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..15)::15 + CSharpStatement - [0..15)::15 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..15)::14 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..15)::13 + MarkupBlock - [2..15)::13 + MarkupTagHelperElement - [2..15)::13 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [2..5)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [5..14)::9 + MarkupStartTag - [5..9)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [9..14)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [14..15)::1 - [}] - Gen - SpanEditHandler;Accepts:Any + Text;[}]; + RazorMetaCode - [15..15)::0 - Gen - SpanEditHandler;Accepts:Any + RightBrace;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.tspans.txt new file mode 100644 index 0000000000..c2ab529dc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (2:0,2 [13] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.cspans.txt new file mode 100644 index 0000000000..3c85657a46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (2:0,2 [4] ) +MetaCode span at (3:0,3 [1] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:None) - Parent: Tag block at (2:0,2 [4] ) +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [5] ) +MetaCode span at (8:0,8 [1] ) (Accepts:None) - Parent: Tag block at (6:0,6 [5] ) +Markup span at (9:0,9 [2] ) (Accepts:None) - Parent: Tag block at (6:0,6 [5] ) +Markup span at (11:0,11 [4] ) (Accepts:None) - Parent: Tag block at (11:0,11 [4] ) +Code span at (15:0,15 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [16] ) +MetaCode span at (15:0,15 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [16] ) +Markup span at (16:0,16 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.diag.txt new file mode 100644 index 0000000000..76963aab62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.diag.txt @@ -0,0 +1,2 @@ +(1,14): Error RZ1026: Encountered end tag "p" with no matching start tag. Are your start/end tags properly balanced? +(1,14): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.stree.txt new file mode 100644 index 0000000000..c6f74a99c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutCSharp_WithBlockData9.stree.txt @@ -0,0 +1,38 @@ +RazorDocument - [0..16)::16 - [@{

                        }] + MarkupBlock - [0..16)::16 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..16)::16 + CSharpStatement - [0..16)::16 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..16)::15 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..15)::13 + MarkupBlock - [2..11)::9 + MarkupElement - [2..11)::9 + MarkupStartTag - [2..6)::4 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [6..11)::5 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupBlock - [11..15)::4 + MarkupElement - [11..15)::4 + MarkupEndTag - [11..15)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [15..15)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [16..16)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData1.cspans.txt new file mode 100644 index 0000000000..db11a2b53b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData1.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData1.stree.txt new file mode 100644 index 0000000000..9e3036562e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData1.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..16)::16 - [] + MarkupBlock - [0..16)::16 + MarkupElement - [0..16)::16 + MarkupStartTag - [0..16)::16 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..15)::12 - [ class="btn"] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [btn] + MarkupTextLiteral - [11..14)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData2.cspans.txt new file mode 100644 index 0000000000..f63db8ffa0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData2.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (16:0,16 [2] ) (Accepts:Any) - Parent: Tag block at (16:0,16 [5] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Tag block at (16:0,16 [5] ) +Markup span at (19:0,19 [2] ) (Accepts:Any) - Parent: Tag block at (16:0,16 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData2.stree.txt new file mode 100644 index 0000000000..36b7be64ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData2.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..21)::21 - [] + MarkupBlock - [0..21)::21 + MarkupElement - [0..21)::21 + MarkupStartTag - [0..16)::16 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..15)::12 - [ class="btn"] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [btn] + MarkupTextLiteral - [11..14)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupEndTag - [16..21)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData3.cspans.txt new file mode 100644 index 0000000000..581430192a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData3.cspans.txt @@ -0,0 +1,11 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (11:0,11 [3] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [12] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) +Markup span at (16:0,16 [16] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [37] ) +Markup span at (32:0,32 [2] ) (Accepts:Any) - Parent: Tag block at (32:0,32 [5] ) +MetaCode span at (34:0,34 [1] ) (Accepts:None) - Parent: Tag block at (32:0,32 [5] ) +Markup span at (35:0,35 [2] ) (Accepts:Any) - Parent: Tag block at (32:0,32 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData3.stree.txt new file mode 100644 index 0000000000..567db01f9b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData3.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..37)::37 - [words and spaces] + MarkupBlock - [0..37)::37 + MarkupElement - [0..37)::37 + MarkupStartTag - [0..16)::16 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..15)::12 - [ class="btn"] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [11..14)::3 + MarkupLiteralAttributeValue - [11..14)::3 - [btn] + MarkupTextLiteral - [11..14)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [14..15)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [16..32)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [32..37)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData4.cspans.txt new file mode 100644 index 0000000000..019a92647a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData4.cspans.txt @@ -0,0 +1,13 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [18] ) +Markup span at (11:0,11 [4] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [18] ) +Markup span at (15:0,15 [5] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [18] ) +Markup span at (20:0,20 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [18] ) +Markup span at (21:0,21 [8] ) (Accepts:Any) - Parent: Markup block at (21:0,21 [11] ) +Markup span at (29:0,29 [3] ) (Accepts:Any) - Parent: Markup block at (21:0,21 [11] ) +Markup span at (32:0,32 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (33:0,33 [2] ) (Accepts:Any) - Parent: Tag block at (33:0,33 [5] ) +MetaCode span at (35:0,35 [1] ) (Accepts:None) - Parent: Tag block at (33:0,33 [5] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (33:0,33 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData4.stree.txt new file mode 100644 index 0000000000..98036f87ad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData4.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..38)::38 - [] + MarkupBlock - [0..38)::38 + MarkupElement - [0..38)::38 + MarkupStartTag - [0..33)::33 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..21)::18 - [ class='btn1 btn2'] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..20)::9 + MarkupLiteralAttributeValue - [11..15)::4 - [btn1] + MarkupTextLiteral - [11..15)::4 - [btn1] - Gen - SpanEditHandler;Accepts:Any + Text;[btn1]; + MarkupLiteralAttributeValue - [15..20)::5 - [ btn2] + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [16..20)::4 - [btn2] - Gen - SpanEditHandler;Accepts:Any + Text;[btn2]; + MarkupTextLiteral - [20..21)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupAttributeBlock - [21..32)::11 - [ class2=btn] + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [22..28)::6 - [class2] - Gen - SpanEditHandler;Accepts:Any + Text;[class2]; + Equals;[=]; + GenericBlock - [29..32)::3 + MarkupLiteralAttributeValue - [29..32)::3 - [btn] + MarkupTextLiteral - [29..32)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + CloseAngle;[>]; + MarkupEndTag - [33..38)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData5.cspans.txt new file mode 100644 index 0000000000..08163d8b85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData5.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [36] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [36] ) +Markup span at (2:0,2 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [36] ) +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [32] ) +Markup span at (11:0,11 [4] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [32] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (15:0,15 [14] ) +Transition span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (16:0,16 [13] ) +Code span at (17:0,17 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (16:0,16 [13] ) +Markup span at (29:0,29 [5] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [32] ) +Markup span at (34:0,34 [1] ) (Accepts:Any) - Parent: Markup block at (3:0,3 [32] ) +Markup span at (35:0,35 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [36] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [5] ) +MetaCode span at (38:0,38 [1] ) (Accepts:None) - Parent: Tag block at (36:0,36 [5] ) +Markup span at (39:0,39 [2] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData5.stree.txt new file mode 100644 index 0000000000..22ffd69773 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithAttributeData5.stree.txt @@ -0,0 +1,47 @@ +RazorDocument - [0..41)::41 - [] + MarkupBlock - [0..41)::41 + MarkupElement - [0..41)::41 + MarkupStartTag - [0..36)::36 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + MarkupAttributeBlock - [3..35)::32 - [ class='btn1 @DateTime.Now btn2'] + MarkupTextLiteral - [3..4)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [4..9)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [10..11)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [11..34)::23 + MarkupLiteralAttributeValue - [11..15)::4 - [btn1] + MarkupTextLiteral - [11..15)::4 - [btn1] - Gen - SpanEditHandler;Accepts:Any + Text;[btn1]; + MarkupDynamicAttributeValue - [15..29)::14 - [ @DateTime.Now] + MarkupTextLiteral - [15..16)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + GenericBlock - [16..29)::13 + CSharpCodeBlock - [16..29)::13 + CSharpImplicitExpression - [16..29)::13 + CSharpTransition - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [17..29)::12 + CSharpCodeBlock - [17..29)::12 + CSharpExpressionLiteral - [17..29)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupLiteralAttributeValue - [29..34)::5 - [ btn2] + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [30..34)::4 - [btn2] - Gen - SpanEditHandler;Accepts:Any + Text;[btn2]; + MarkupTextLiteral - [34..35)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [36..41)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData1.cspans.txt new file mode 100644 index 0000000000..a5d0c98f58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData1.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData1.stree.txt new file mode 100644 index 0000000000..f1200dcf89 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData1.stree.txt @@ -0,0 +1,8 @@ +RazorDocument - [0..4)::4 - [] + MarkupBlock - [0..4)::4 + MarkupElement - [0..4)::4 + MarkupStartTag - [0..4)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.cspans.txt new file mode 100644 index 0000000000..7c1acf2f61 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (8:0,8 [2] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [5] ) +MetaCode span at (10:0,10 [1] ) (Accepts:None) - Parent: Tag block at (8:0,8 [5] ) +Markup span at (11:0,11 [2] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.stree.txt new file mode 100644 index 0000000000..fcea222085 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..22)::22 - [] + MarkupBlock - [0..22)::22 + MarkupTagHelperElement - [0..22)::22 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [8..13)::5 + MarkupEndTag - [8..13)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [13..22)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.tspans.txt new file mode 100644 index 0000000000..ba6ff19ad3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [22] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.cspans.txt new file mode 100644 index 0000000000..6ca585931a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (17:0,17 [1] ) (Accepts:Any) - Parent: Tag block at (17:0,17 [4] ) +MetaCode span at (18:0,18 [1] ) (Accepts:None) - Parent: Tag block at (17:0,17 [4] ) +Markup span at (19:0,19 [2] ) (Accepts:Any) - Parent: Tag block at (17:0,17 [4] ) +Markup span at (21:0,21 [2] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [5] ) +MetaCode span at (23:0,23 [1] ) (Accepts:None) - Parent: Tag block at (21:0,21 [5] ) +Markup span at (24:0,24 [2] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.stree.txt new file mode 100644 index 0000000000..ceb36af825 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..26)::26 - [] + MarkupBlock - [0..26)::26 + MarkupTagHelperElement - [0..17)::17 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [8..17)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [17..26)::9 + MarkupStartTag - [17..21)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [21..26)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.tspans.txt new file mode 100644 index 0000000000..e9b9c4563b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [17] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.cspans.txt new file mode 100644 index 0000000000..09633f5839 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (11:0,11 [2] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [10] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Tag block at (11:0,11 [10] ) +Markup span at (14:0,14 [7] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [10] ) +Markup span at (21:0,21 [1] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [4] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Tag block at (21:0,21 [4] ) +Markup span at (23:0,23 [2] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [4] ) +Markup span at (34:0,34 [2] ) (Accepts:Any) - Parent: Tag block at (34:0,34 [5] ) +MetaCode span at (36:0,36 [1] ) (Accepts:None) - Parent: Tag block at (34:0,34 [5] ) +Markup span at (37:0,37 [2] ) (Accepts:Any) - Parent: Tag block at (34:0,34 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.diag.txt new file mode 100644 index 0000000000..d177eb6df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.stree.txt new file mode 100644 index 0000000000..3d7d4984bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..39)::39 - [

                        ] + MarkupBlock - [0..39)::39 + MarkupTagHelperElement - [0..39)::39 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..34)::31 - strong[StartTagAndEndTag] - strongtaghelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [11..21)::10 + MarkupEndTag - [11..21)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [21..25)::4 + MarkupStartTag - [21..25)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [25..34)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [34..39)::5 + MarkupEndTag - [34..39)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.tspans.txt new file mode 100644 index 0000000000..cfe3d3fa3b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData12.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [39] ) - ptaghelper +TagHelper span at (3:0,3 [31] ) - strongtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData2.cspans.txt new file mode 100644 index 0000000000..8fa95e872f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData2.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +MetaCode span at (2:0,2 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData2.stree.txt new file mode 100644 index 0000000000..708ea901d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData2.stree.txt @@ -0,0 +1,9 @@ +RazorDocument - [0..5)::5 - [] + MarkupBlock - [0..5)::5 + MarkupElement - [0..5)::5 + MarkupEndTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData3.cspans.txt new file mode 100644 index 0000000000..4c275ff050 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData3.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [5] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Tag block at (4:0,4 [5] ) +Markup span at (7:0,7 [2] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData3.stree.txt new file mode 100644 index 0000000000..fae760c817 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData3.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..9)::9 - [] + MarkupBlock - [0..9)::9 + MarkupElement - [0..9)::9 + MarkupStartTag - [0..4)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [4..9)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData4.cspans.txt new file mode 100644 index 0000000000..3997b127d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData4.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (4:0,4 [16] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [25] ) +Markup span at (20:0,20 [2] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [5] ) +MetaCode span at (22:0,22 [1] ) (Accepts:None) - Parent: Tag block at (20:0,20 [5] ) +Markup span at (23:0,23 [2] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData4.stree.txt new file mode 100644 index 0000000000..1f1d9262f9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData4.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..25)::25 - [words and spaces] + MarkupBlock - [0..25)::25 + MarkupElement - [0..25)::25 + MarkupStartTag - [0..4)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [4..20)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupEndTag - [20..25)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.cspans.txt new file mode 100644 index 0000000000..ccea3d9b24 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (4:0,4 [4] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.diag.txt new file mode 100644 index 0000000000..b1d7d8700f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.stree.txt new file mode 100644 index 0000000000..cdd918aa0b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData5.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..8)::8 - [

                        ] + MarkupBlock - [0..8)::8 + MarkupElement - [0..8)::8 + MarkupStartTag - [0..4)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [4..8)::4 + MarkupEndTag - [4..8)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.cspans.txt new file mode 100644 index 0000000000..d7c40f6239 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [5] ) +MetaCode span at (5:0,5 [1] ) (Accepts:None) - Parent: Tag block at (3:0,3 [5] ) +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.diag.txt new file mode 100644 index 0000000000..d177eb6df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.stree.txt new file mode 100644 index 0000000000..62b283ee73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..8)::8 - [

                        ] + MarkupBlock - [0..8)::8 + MarkupTagHelperElement - [0..8)::8 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..8)::5 + MarkupEndTag - [3..8)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.tspans.txt new file mode 100644 index 0000000000..7b15d972a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [8] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.cspans.txt new file mode 100644 index 0000000000..5f18fc72f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (3:0,3 [1] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) +MetaCode span at (4:0,4 [1] ) (Accepts:None) - Parent: Tag block at (3:0,3 [4] ) +Markup span at (5:0,5 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) +Markup span at (7:0,7 [2] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [5] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Tag block at (7:0,7 [5] ) +Markup span at (10:0,10 [2] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.stree.txt new file mode 100644 index 0000000000..c59a98b7cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..16)::16 - [

                        ] + MarkupBlock - [0..16)::16 + MarkupTagHelperElement - [0..16)::16 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..12)::9 + MarkupStartTag - [3..7)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [7..12)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [12..16)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.tspans.txt new file mode 100644 index 0000000000..52dba16922 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [16] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.cspans.txt new file mode 100644 index 0000000000..5f18fc72f8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (3:0,3 [1] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) +MetaCode span at (4:0,4 [1] ) (Accepts:None) - Parent: Tag block at (3:0,3 [4] ) +Markup span at (5:0,5 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) +Markup span at (7:0,7 [2] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [5] ) +MetaCode span at (9:0,9 [1] ) (Accepts:None) - Parent: Tag block at (7:0,7 [5] ) +Markup span at (10:0,10 [2] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.diag.txt new file mode 100644 index 0000000000..d177eb6df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.stree.txt new file mode 100644 index 0000000000..0222b2cb17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..12)::12 - [

                        ] + MarkupBlock - [0..12)::12 + MarkupTagHelperElement - [0..12)::12 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..12)::9 + MarkupStartTag - [3..7)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [7..12)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.tspans.txt new file mode 100644 index 0000000000..7cc635f45e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [12] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.cspans.txt new file mode 100644 index 0000000000..bd0517f735 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (2:0,2 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [4] ) +Markup span at (4:0,4 [2] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [5] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Tag block at (4:0,4 [5] ) +Markup span at (7:0,7 [2] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [5] ) +Markup span at (9:0,9 [4] ) (Accepts:Any) - Parent: Tag block at (9:0,9 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.diag.txt new file mode 100644 index 0000000000..08a69712ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.diag.txt @@ -0,0 +1 @@ +(1,12): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.stree.txt new file mode 100644 index 0000000000..eca9695a25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/AllowsTagHelperElementOptOutHTML_WithBlockData9.stree.txt @@ -0,0 +1,20 @@ +RazorDocument - [0..13)::13 - [

                        ] + MarkupBlock - [0..13)::13 + MarkupElement - [0..9)::9 + MarkupStartTag - [0..4)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [4..9)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Bang;[!]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [9..13)::4 + MarkupEndTag - [9..13)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.cspans.txt new file mode 100644 index 0000000000..6b69df9374 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [53] ) +Markup span at (9:1,4 [8] ) (Accepts:Any) - Parent: Tag block at (9:1,4 [8] ) +Markup span at (17:1,12 [21] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [53] ) +Markup span at (38:3,4 [9] ) (Accepts:Any) - Parent: Tag block at (38:3,4 [9] ) +Markup span at (47:3,13 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [53] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.diag.txt new file mode 100644 index 0000000000..4c1f5923fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.diag.txt @@ -0,0 +1 @@ +(2,6): Error RZ2010: The tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'br' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.stree.txt new file mode 100644 index 0000000000..3a091ff8d7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..53)::53 - [

                        LF LF HelloLF LF

                        ] + MarkupBlock - [0..53)::53 + MarkupTagHelperElement - [0..53)::53 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..9)::6 - [LF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + MarkupElement - [9..47)::38 + MarkupStartTag - [9..17)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [17..38)::21 - [LF HelloLF ] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + Whitespace;[ ]; + Text;[Hello]; + NewLine;[LF]; + Whitespace;[ ]; + MarkupEndTag - [38..47)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [47..49)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTagHelperEndTag - [49..53)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.tspans.txt new file mode 100644 index 0000000000..05765431e3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleInvalidChildrenWithWhitespace.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [53] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.cspans.txt new file mode 100644 index 0000000000..a9c65f2e8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.cspans.txt @@ -0,0 +1 @@ +Markup span at (11:0,11 [11] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.stree.txt new file mode 100644 index 0000000000..c28e528a9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..39)::39 - [

                        Hello World

                        ] + MarkupBlock - [0..39)::39 + MarkupTagHelperElement - [0..39)::39 - p[StartTagAndEndTag] - PTagHelper1 - PTagHelper2 + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..31)::28 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [11..22)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [22..31)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [31..35)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [31..35)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [35..39)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.tspans.txt new file mode 100644 index 0000000000..5b5143529f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [39] ) - PTagHelper1 - PTagHelper2 +TagHelper span at (3:0,3 [28] ) - StrongTagHelper +TagHelper span at (31:0,31 [4] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.cspans.txt new file mode 100644 index 0000000000..a9c65f2e8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.cspans.txt @@ -0,0 +1 @@ +Markup span at (11:0,11 [11] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.stree.txt new file mode 100644 index 0000000000..c28e528a9f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..39)::39 - [

                        Hello World

                        ] + MarkupBlock - [0..39)::39 + MarkupTagHelperElement - [0..39)::39 - p[StartTagAndEndTag] - PTagHelper1 - PTagHelper2 + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..31)::28 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [11..22)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [22..31)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [31..35)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [31..35)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [35..39)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.tspans.txt new file mode 100644 index 0000000000..5b5143529f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleMultipleTagHelpersWithAllowedChildren_OneNull.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [39] ) - PTagHelper1 - PTagHelper2 +TagHelper span at (3:0,3 [28] ) - StrongTagHelper +TagHelper span at (31:0,31 [4] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.stree.txt new file mode 100644 index 0000000000..5a61ddfab0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.stree.txt @@ -0,0 +1,7 @@ +RazorDocument - [0..7)::7 - [] + MarkupBlock - [0..7)::7 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.tspans.txt new file mode 100644 index 0000000000..507d5a1ed9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CanHandleStartTagOnlyTagTagMode.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.diag.txt new file mode 100644 index 0000000000..6668a36e1c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.diag.txt @@ -0,0 +1 @@ +(1,1): Error RZ2011: Tag helpers 'InputTagHelper1' and 'InputTagHelper2' targeting element 'input' must not expect different TagStructure values. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.stree.txt new file mode 100644 index 0000000000..0db5f5e70a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.stree.txt @@ -0,0 +1,7 @@ +RazorDocument - [0..7)::7 - [] + MarkupBlock - [0..7)::7 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper1 - InputTagHelper2 + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.tspans.txt new file mode 100644 index 0000000000..aa95134310 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForInconsistentTagStructures.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper1 - InputTagHelper2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.cspans.txt new file mode 100644 index 0000000000..da5af92309 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.diag.txt new file mode 100644 index 0000000000..2991a49bbc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.diag.txt @@ -0,0 +1 @@ +(1,3): Error RZ1033: Found an end tag () for tag helper 'InputTagHelper' with tag structure that disallows an end tag ('WithoutEndTag'). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.stree.txt new file mode 100644 index 0000000000..51d05bcd79 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/CreatesErrorForWithoutEndTagTagStructureForEndTags.stree.txt @@ -0,0 +1,8 @@ +RazorDocument - [0..8)::8 - [] + MarkupBlock - [0..8)::8 + MarkupElement - [0..8)::8 + MarkupEndTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.cspans.txt new file mode 100644 index 0000000000..cc2e136b18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [4] ) (Accepts:None) - Parent: HtmlComment block at (5:0,5 [20] ) +Markup span at (9:0,9 [13] ) (Accepts:Whitespace) - Parent: HtmlComment block at (5:0,5 [20] ) +Markup span at (22:0,22 [3] ) (Accepts:None) - Parent: HtmlComment block at (5:0,5 [20] ) +Markup span at (25:0,25 [6] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.stree.txt new file mode 100644 index 0000000000..892a5074bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers1.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupElement - [0..31)::31 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupCommentBlock - [5..25)::20 + MarkupTextLiteral - [5..9)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [25..31)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.cspans.txt new file mode 100644 index 0000000000..60e78976ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [4] ) (Accepts:None) - Parent: HtmlComment block at (5:0,5 [13] ) +Markup span at (9:0,9 [1] ) (Accepts:Whitespace) - Parent: HtmlComment block at (5:0,5 [13] ) +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [4] ) +Code span at (11:0,11 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [4] ) +Markup span at (14:0,14 [1] ) (Accepts:Whitespace) - Parent: HtmlComment block at (5:0,5 [13] ) +Markup span at (15:0,15 [3] ) (Accepts:None) - Parent: HtmlComment block at (5:0,5 [13] ) +Markup span at (18:0,18 [6] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.stree.txt new file mode 100644 index 0000000000..1efdfee552 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers2.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupElement - [0..24)::24 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupCommentBlock - [5..18)::13 + MarkupTextLiteral - [5..9)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupEndTag - [18..24)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.cspans.txt new file mode 100644 index 0000000000..c4ecccfbcc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [20] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (25:0,25 [6] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.stree.txt new file mode 100644 index 0000000000..3d12db4002 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers3.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupElement - [0..31)::31 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..25)::20 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupEndTag - [25..31)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.cspans.txt new file mode 100644 index 0000000000..8abca4d638 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [6] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Transition span at (11:0,11 [1] ) (Accepts:None) - Parent: Expression block at (11:0,11 [4] ) +Code span at (12:0,12 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (11:0,11 [4] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [24] ) +Markup span at (18:0,18 [6] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.stree.txt new file mode 100644 index 0000000000..ac72886d06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers4.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupElement - [0..24)::24 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..11)::6 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + QuestionMark;[?]; + Text;[xml]; + Whitespace;[ ]; + CSharpCodeBlock - [11..15)::4 + CSharpImplicitExpression - [11..15)::4 + CSharpTransition - [11..12)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [12..15)::3 + CSharpCodeBlock - [12..15)::3 + CSharpExpressionLiteral - [12..15)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [15..18)::3 - [ ?>] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + QuestionMark;[?]; + CloseAngle;[>]; + MarkupEndTag - [18..24)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.cspans.txt new file mode 100644 index 0000000000..a6fb41162b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [10] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [4] ) +Code span at (16:0,16 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (15:0,15 [4] ) +Markup span at (19:0,19 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Markup span at (21:0,21 [6] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.stree.txt new file mode 100644 index 0000000000..6dd9386d40 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers5.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..27)::27 - [] + MarkupBlock - [0..27)::27 + MarkupElement - [0..27)::27 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..15)::10 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[DOCTYPE]; + Whitespace;[ ]; + CSharpCodeBlock - [15..19)::4 + CSharpImplicitExpression - [15..19)::4 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [16..19)::3 + CSharpCodeBlock - [16..19)::3 + CSharpExpressionLiteral - [16..19)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [19..21)::2 - [ >] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupEndTag - [21..27)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.cspans.txt new file mode 100644 index 0000000000..c59f0f1953 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [25] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Markup span at (30:0,30 [6] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.stree.txt new file mode 100644 index 0000000000..b255eda476 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers6.stree.txt @@ -0,0 +1,24 @@ +RazorDocument - [0..36)::36 - [] + MarkupBlock - [0..36)::36 + MarkupElement - [0..36)::36 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..30)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + Text;[DOCTYPE]; + Whitespace;[ ]; + Text;[hello]; + Equals;[=]; + DoubleQuote;["]; + Text;[world]; + DoubleQuote;["]; + Whitespace;[ ]; + CloseAngle;[>]; + MarkupEndTag - [30..36)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.cspans.txt new file mode 100644 index 0000000000..c59f0f1953 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [25] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [36] ) +Markup span at (30:0,30 [6] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.stree.txt new file mode 100644 index 0000000000..1b43d94ac9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers7.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..36)::36 - [] + MarkupBlock - [0..36)::36 + MarkupElement - [0..36)::36 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..30)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + LeftBracket;[[]; + Text;[CDATA]; + LeftBracket;[[]; + Whitespace;[ ]; + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + RightBracket;[]]; + RightBracket;[]]; + CloseAngle;[>]; + MarkupEndTag - [30..36)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.cspans.txt new file mode 100644 index 0000000000..4024585ede --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [10] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Transition span at (15:0,15 [1] ) (Accepts:None) - Parent: Expression block at (15:0,15 [4] ) +Code span at (16:0,16 [3] ) (Accepts:NonWhitespace) - Parent: Expression block at (15:0,15 [4] ) +Markup span at (19:0,19 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [29] ) +Markup span at (23:0,23 [6] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.diag.txt new file mode 100644 index 0000000000..67536937c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.diag.txt @@ -0,0 +1,5 @@ +(0,0): Error RZ3008: Tag helpers cannot target tag name '!--' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '?xml' because it contains a '?' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '!' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '![CDATA[' because it contains a '[' character. +(0,0): Error RZ3008: Tag helpers cannot target tag name '!DOCTYPE' because it contains a '!' character. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.stree.txt new file mode 100644 index 0000000000..e9c3a9037e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteSpecialTagTagHelpers8.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..29)::29 - [] + MarkupBlock - [0..29)::29 + MarkupElement - [0..29)::29 + MarkupStartTag - [0..5)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[foo]; + CloseAngle;[>]; + MarkupTextLiteral - [5..15)::10 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Bang;[!]; + LeftBracket;[[]; + Text;[CDATA]; + LeftBracket;[[]; + Whitespace;[ ]; + CSharpCodeBlock - [15..19)::4 + CSharpImplicitExpression - [15..19)::4 + CSharpTransition - [15..16)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [16..19)::3 + CSharpCodeBlock - [16..19)::3 + CSharpExpressionLiteral - [16..19)::3 - [foo] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[foo]; + MarkupTextLiteral - [19..23)::4 - [ ]]>] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + RightBracket;[]]; + RightBracket;[]]; + CloseAngle;[>]; + MarkupEndTag - [23..29)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[foo]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.cspans.txt new file mode 100644 index 0000000000..45f2b8a0d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.cspans.txt @@ -0,0 +1 @@ +Markup span at (6:0,6 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.stree.txt new file mode 100644 index 0000000000..543bc32b48 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.stree.txt @@ -0,0 +1,16 @@ +RazorDocument - [0..24)::24 - [Hello World] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..24)::24 - text[StartTagAndEndTag] - texttaghelper + MarkupTagHelperStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [6..17)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [17..24)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.tspans.txt new file mode 100644 index 0000000000..0e0421beb4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [24] ) - texttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers2.cspans.txt new file mode 100644 index 0000000000..120838d1aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers2.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (8:0,8 [11] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [24] ) +Transition span at (19:0,19 [7] ) (Accepts:None) - Parent: Tag block at (19:0,19 [7] ) +Code span at (26:0,26 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [27] ) +MetaCode span at (26:0,26 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [27] ) +Markup span at (27:0,27 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [27] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers2.stree.txt new file mode 100644 index 0000000000..30549d1f5a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers2.stree.txt @@ -0,0 +1,33 @@ +RazorDocument - [0..27)::27 - [@{Hello World}] + MarkupBlock - [0..27)::27 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..27)::27 + CSharpStatement - [0..27)::27 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..27)::26 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..26)::24 + MarkupBlock - [2..26)::24 + MarkupElement - [2..26)::24 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [8..19)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupEndTag - [19..26)::7 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [26..26)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [26..27)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [27..27)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.cspans.txt new file mode 100644 index 0000000000..5422f86fe0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Transition span at (2:0,2 [6] ) (Accepts:None) - Parent: Tag block at (2:0,2 [6] ) +Markup span at (11:0,11 [11] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [18] ) +Transition span at (26:0,26 [7] ) (Accepts:None) - Parent: Tag block at (26:0,26 [7] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.stree.txt new file mode 100644 index 0000000000..275d4367c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..34)::34 - [@{

                        Hello World

                        }] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupElement - [2..33)::31 + MarkupStartTag - [2..8)::6 - MarkupTransition - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTagHelperElement - [8..26)::18 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [8..11)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [11..22)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [22..26)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [26..33)::7 - MarkupTransition - [
                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.tspans.txt new file mode 100644 index 0000000000..ccb04ff0a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (8:0,8 [18] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.cspans.txt new file mode 100644 index 0000000000..ca3438cacd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) +Transition span at (0:0,0 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (1:0,1 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (11:0,11 [11] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [24] ) +Code span at (33:0,33 [0] ) (Accepts:Any) - Parent: Statement block at (0:0,0 [34] ) +MetaCode span at (33:0,33 [1] ) (Accepts:None) - Parent: Statement block at (0:0,0 [34] ) +Markup span at (34:0,34 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [34] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.stree.txt new file mode 100644 index 0000000000..55d1bc3bc9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..34)::34 - [@{

                        Hello World

                        }] + MarkupBlock - [0..34)::34 + MarkupTextLiteral - [0..0)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + CSharpCodeBlock - [0..34)::34 + CSharpStatement - [0..34)::34 + CSharpTransition - [0..1)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [1..34)::33 + RazorMetaCode - [1..2)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [2..33)::31 + MarkupBlock - [2..33)::31 + MarkupTagHelperElement - [2..33)::31 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [2..5)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [5..29)::24 - text[StartTagAndEndTag] - texttaghelper + MarkupTagHelperStartTag - [5..11)::6 - [] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + Text;[text]; + CloseAngle;[>]; + MarkupTextLiteral - [11..22)::11 - [Hello World] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + MarkupTagHelperEndTag - [22..29)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[text]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [29..33)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + CSharpStatementLiteral - [33..33)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [33..34)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [34..34)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.tspans.txt new file mode 100644 index 0000000000..0e58e331ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotRewriteTextTagTransitionTagHelpers4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (2:0,2 [31] ) - ptaghelper +TagHelper span at (5:0,5 [24] ) - texttaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1.cspans.txt new file mode 100644 index 0000000000..49c8ba186f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [13] ) +Markup span at (7:0,7 [5] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [5] ) +Markup span at (12:0,12 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [13] ) +Markup span at (13:0,13 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [31] ) +Markup span at (22:0,22 [9] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1.stree.txt new file mode 100644 index 0000000000..e55e0ca85c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags1.stree.txt @@ -0,0 +1,23 @@ +RazorDocument - [0..31)::31 - [] + MarkupBlock - [0..31)::31 + MarkupElement - [0..31)::31 + MarkupStartTag - [0..13)::13 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2.cspans.txt new file mode 100644 index 0000000000..2c17954aab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (7:0,7 [8] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [18] ) +Markup span at (15:0,15 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [18] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [18] ) +Markup span at (25:0,25 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (26:0,26 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [44] ) +Markup span at (35:0,35 [9] ) (Accepts:Any) - Parent: Tag block at (35:0,35 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2.stree.txt new file mode 100644 index 0000000000..4450b4ee70 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags2.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..44)::44 - [] + MarkupBlock - [0..44)::44 + MarkupElement - [0..44)::44 + MarkupStartTag - [0..26)::26 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3.cspans.txt new file mode 100644 index 0000000000..955ace03ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (7:0,7 [7] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [25] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [25] ) +Markup span at (23:0,23 [8] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [25] ) +Markup span at (31:0,31 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [25] ) +Markup span at (32:0,32 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (33:0,33 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [51] ) +Markup span at (42:0,42 [9] ) (Accepts:Any) - Parent: Tag block at (42:0,42 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3.stree.txt new file mode 100644 index 0000000000..dbd6822130 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags3.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..51)::51 - [] + MarkupBlock - [0..51)::51 + MarkupElement - [0..51)::51 + MarkupStartTag - [0..33)::33 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4.cspans.txt new file mode 100644 index 0000000000..a41c0eb271 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [42] ) +Markup span at (7:0,7 [7] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (24:0,24 [7] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [17] ) +Markup span at (31:0,31 [9] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [17] ) +Markup span at (40:0,40 [1] ) (Accepts:Any) - Parent: Markup block at (24:0,24 [17] ) +Markup span at (41:0,41 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [42] ) +Markup span at (42:0,42 [9] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [60] ) +Markup span at (51:0,51 [9] ) (Accepts:Any) - Parent: Tag block at (51:0,51 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4.stree.txt new file mode 100644 index 0000000000..b0aca0fea5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesNotUnderstandTagHelpersInInvalidHtmlTypedScriptTags4.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..60)::60 - [] + MarkupBlock - [0..60)::60 + MarkupElement - [0..60)::60 + MarkupStartTag - [0..42)::42 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.cspans.txt new file mode 100644 index 0000000000..9c63d02543 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (3:0,3 [4] ) (Accepts:None) - Parent: HtmlComment block at (3:0,3 [12] ) +Markup span at (7:0,7 [5] ) (Accepts:Whitespace) - Parent: HtmlComment block at (3:0,3 [12] ) +Markup span at (12:0,12 [3] ) (Accepts:None) - Parent: HtmlComment block at (3:0,3 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.diag.txt new file mode 100644 index 0000000000..79250ce2c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.diag.txt @@ -0,0 +1,3 @@ +(1,4): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'b' are allowed. +(1,8): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'b' are allowed. +(1,13): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'b' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.stree.txt new file mode 100644 index 0000000000..9eda1dc0cb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..19)::19 - [

                        ] + MarkupBlock - [0..19)::19 + MarkupTagHelperElement - [0..19)::19 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupCommentBlock - [3..15)::12 + MarkupTextLiteral - [3..7)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [15..19)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.tspans.txt new file mode 100644 index 0000000000..8cb202b9d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/DoesntAllowSimpleHtmlCommentsAsChildrenWhenFeatureFlagIsOff.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [19] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.cspans.txt new file mode 100644 index 0000000000..fe9f0e011c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (3:0,3 [4] ) (Accepts:None) - Parent: HtmlComment block at (3:0,3 [12] ) +Markup span at (7:0,7 [5] ) (Accepts:Whitespace) - Parent: HtmlComment block at (3:0,3 [12] ) +Markup span at (12:0,12 [3] ) (Accepts:None) - Parent: HtmlComment block at (3:0,3 [12] ) +Markup span at (15:0,15 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +Markup span at (19:0,19 [4] ) (Accepts:None) - Parent: HtmlComment block at (19:0,19 [12] ) +Markup span at (23:0,23 [5] ) (Accepts:Whitespace) - Parent: HtmlComment block at (19:0,19 [12] ) +Markup span at (28:0,28 [3] ) (Accepts:None) - Parent: HtmlComment block at (19:0,19 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.diag.txt new file mode 100644 index 0000000000..2388259b98 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.diag.txt @@ -0,0 +1 @@ +(1,16): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'b' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.stree.txt new file mode 100644 index 0000000000..383b82ba4a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..35)::35 - [

                        asdf

                        ] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupCommentBlock - [3..15)::12 + MarkupTextLiteral - [3..7)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTextLiteral - [15..19)::4 - [asdf] - Gen - SpanEditHandler;Accepts:Any + Text;[asdf]; + MarkupCommentBlock - [19..31)::12 + MarkupTextLiteral - [19..23)::4 - [] - Gen - SpanEditHandler;Accepts:None + DoubleHyphen;[--]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [31..35)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.tspans.txt new file mode 100644 index 0000000000..548e779815 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/FailsForContentWithCommentsAsChildren.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.cspans.txt new file mode 100644 index 0000000000..9244132d92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.stree.txt new file mode 100644 index 0000000000..69237591cf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..28)::28 - [

                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - pTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - SingleQuotes - Unbound - [ class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..23)::9 - catchAll - Minimized - Unbound - [ catchAll] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.tspans.txt new file mode 100644 index 0000000000..f9a1aca732 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - pTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.cspans.txt new file mode 100644 index 0000000000..9244132d92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.stree.txt new file mode 100644 index 0000000000..9e56cc278d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..28)::28 - [

                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - CLASS - SingleQuotes - Unbound - [ CLASS='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [CLASS] - Gen - SpanEditHandler;Accepts:Any + Text;[CLASS]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..23)::9 - CATCHAll - Minimized - Unbound - [ CATCHAll] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [CATCHAll] - Gen - SpanEditHandler;Accepts:Any + Text;[CATCHAll]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.tspans.txt new file mode 100644 index 0000000000..2a9461471f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.cspans.txt new file mode 100644 index 0000000000..9244132d92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.stree.txt new file mode 100644 index 0000000000..10d12d82da --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..28)::28 - [

                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - P[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[P]; + MarkupTagHelperAttribute - [2..14)::12 - class - SingleQuotes - Unbound - [ class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..23)::9 - CATCHAll - Minimized - Unbound - [ CATCHAll] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [CATCHAll] - Gen - SpanEditHandler;Accepts:Any + Text;[CATCHAll]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[P]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.tspans.txt new file mode 100644 index 0000000000..2a9461471f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.cspans.txt new file mode 100644 index 0000000000..34f63d813d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (2:0,2 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (15:0,15 [4] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.stree.txt new file mode 100644 index 0000000000..211c7dd391 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..19)::19 - [

                        ] + MarkupBlock - [0..19)::19 + MarkupElement - [0..19)::19 + MarkupStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[P]; + MarkupAttributeBlock - [2..14)::12 - [ class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [15..19)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[P]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.cspans.txt new file mode 100644 index 0000000000..34f63d813d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (2:0,2 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (15:0,15 [4] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.stree.txt new file mode 100644 index 0000000000..205ae2dfe0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..19)::19 - [

                        ] + MarkupBlock - [0..19)::19 + MarkupElement - [0..19)::19 + MarkupStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupAttributeBlock - [2..14)::12 - [ Class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [Class] - Gen - SpanEditHandler;Accepts:Any + Text;[Class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [15..19)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.cspans.txt new file mode 100644 index 0000000000..d99115005b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Transition span at (5:0,5 [1] ) (Accepts:None) - Parent: Statement block at (5:0,5 [9] ) +MetaCode span at (6:0,6 [1] ) (Accepts:None) - Parent: Statement block at (5:0,5 [9] ) +Markup span at (7:0,7 [6] ) (Accepts:None) - Parent: Tag block at (7:0,7 [6] ) +Code span at (13:0,13 [0] ) (Accepts:Any) - Parent: Statement block at (5:0,5 [9] ) +MetaCode span at (13:0,13 [1] ) (Accepts:None) - Parent: Statement block at (5:0,5 [9] ) +Markup span at (14:0,14 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.diag.txt new file mode 100644 index 0000000000..2d09355f58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.diag.txt @@ -0,0 +1 @@ +(1,10): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.stree.txt new file mode 100644 index 0000000000..798255fcf8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesMalformedNestedNonTagHelperTags_Correctly.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..14)::14 - [
                        @{
                        }] + MarkupBlock - [0..14)::14 + MarkupElement - [0..14)::14 + MarkupStartTag - [0..5)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + CSharpCodeBlock - [5..14)::9 + CSharpStatement - [5..14)::9 + CSharpTransition - [5..6)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpStatementBody - [6..14)::8 + RazorMetaCode - [6..7)::1 - Gen - SpanEditHandler;Accepts:None + LeftBrace;[{]; + CSharpCodeBlock - [7..13)::6 + MarkupBlock - [7..13)::6 + MarkupElement - [7..13)::6 + MarkupEndTag - [7..13)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:None + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + CSharpStatementLiteral - [13..13)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; + RazorMetaCode - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + RightBrace;[}]; + MarkupTextLiteral - [14..14)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesNonTagHelperStartAndEndVoidTags_Correctly.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesNonTagHelperStartAndEndVoidTags_Correctly.cspans.txt new file mode 100644 index 0000000000..d7bd4e3d71 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesNonTagHelperStartAndEndVoidTags_Correctly.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [7] ) +Markup span at (7:0,7 [3] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [18] ) +Markup span at (10:0,10 [8] ) (Accepts:Any) - Parent: Tag block at (10:0,10 [8] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesNonTagHelperStartAndEndVoidTags_Correctly.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesNonTagHelperStartAndEndVoidTags_Correctly.stree.txt new file mode 100644 index 0000000000..55f62a7731 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesNonTagHelperStartAndEndVoidTags_Correctly.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..18)::18 - [Foo] + MarkupBlock - [0..18)::18 + MarkupElement - [0..18)::18 + MarkupStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTextLiteral - [7..10)::3 - [Foo] - Gen - SpanEditHandler;Accepts:Any + Text;[Foo]; + MarkupEndTag - [10..18)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[input]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.cspans.txt new file mode 100644 index 0000000000..67ad7c62e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.cspans.txt @@ -0,0 +1 @@ +Markup span at (6:0,6 [12] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.diag.txt new file mode 100644 index 0000000000..28629d2c01 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.diag.txt @@ -0,0 +1 @@ +(1,9): Error RZ1034: Found a malformed 'th:strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.stree.txt new file mode 100644 index 0000000000..2dded2ecc6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..25)::25 - [] + MarkupBlock - [0..25)::25 + MarkupTagHelperElement - [0..25)::25 - th:p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:p]; + CloseAngle;[>]; + MarkupElement - [6..18)::12 + MarkupEndTag - [6..18)::12 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [18..25)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.tspans.txt new file mode 100644 index 0000000000..e3e08d013c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/InvalidStructure_UnderstandsTHPrefixAndAllowedChildrenAndRequireParent.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [25] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.cspans.txt new file mode 100644 index 0000000000..4e29c0cde5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [26] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [4] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.stree.txt new file mode 100644 index 0000000000..5ee6707ec5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..26)::26 - [

                        ] + MarkupBlock - [0..26)::26 + MarkupTagHelperElement - [0..26)::26 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [15..22)::7 + MarkupStartTag - [15..18)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [18..22)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [22..26)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.tspans.txt new file mode 100644 index 0000000000..b037dceaab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [26] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.cspans.txt new file mode 100644 index 0000000000..e59c771002 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [113] ) +Markup span at (22:0,22 [8] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [8] ) +Markup span at (30:0,30 [8] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [8] ) +Markup span at (56:0,56 [2] ) (Accepts:Any) - Parent: Tag block at (38:0,38 [48] ) +Markup span at (60:0,60 [8] ) (Accepts:Any) - Parent: Tag block at (60:0,60 [8] ) +Markup span at (68:0,68 [9] ) (Accepts:Any) - Parent: Tag block at (68:0,68 [9] ) +Markup span at (86:0,86 [9] ) (Accepts:Any) - Parent: Tag block at (86:0,86 [9] ) +Markup span at (95:0,95 [9] ) (Accepts:Any) - Parent: Tag block at (95:0,95 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.stree.txt new file mode 100644 index 0000000000..b489212ead --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.stree.txt @@ -0,0 +1,80 @@ +RazorDocument - [0..113)::113 - [] + MarkupBlock - [0..113)::113 + MarkupTagHelperElement - [0..113)::113 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [22..104)::82 + MarkupStartTag - [22..30)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [30..95)::65 + MarkupStartTag - [30..38)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [38..86)::48 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [38..60)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [45..59)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [45..46)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [46..54)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [55..56)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [56..58)::2 + MarkupLiteralAttributeValue - [56..58)::2 - [hi] + MarkupTextLiteral - [56..58)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [58..59)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [60..77)::17 + MarkupStartTag - [60..68)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [68..77)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [77..86)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [86..95)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [95..104)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [104..113)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.tspans.txt new file mode 100644 index 0000000000..8ea9fb13a5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [113] ) - catchAllTagHelper +TagHelper span at (38:0,38 [48] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.cspans.txt new file mode 100644 index 0000000000..f9e18638d4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [48] ) +Markup span at (22:0,22 [8] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [8] ) +Markup span at (30:0,30 [9] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.stree.txt new file mode 100644 index 0000000000..c27b045937 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.stree.txt @@ -0,0 +1,36 @@ +RazorDocument - [0..48)::48 - [] + MarkupBlock - [0..48)::48 + MarkupTagHelperElement - [0..48)::48 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [22..39)::17 + MarkupStartTag - [22..30)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [30..39)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [39..48)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.tspans.txt new file mode 100644 index 0000000000..f20c5948bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [48] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.cspans.txt new file mode 100644 index 0000000000..285c8a6c09 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [43] ) +Markup span at (15:0,15 [8] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [8] ) +Markup span at (23:0,23 [3] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [3] ) +Markup span at (26:0,26 [4] ) (Accepts:Any) - Parent: Tag block at (26:0,26 [4] ) +Markup span at (30:0,30 [9] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.stree.txt new file mode 100644 index 0000000000..11851c327a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..43)::43 - [

                        ] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [15..39)::24 + MarkupStartTag - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [23..30)::7 + MarkupStartTag - [23..26)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [26..30)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [30..39)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [39..43)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.tspans.txt new file mode 100644 index 0000000000..9980ee41c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.cspans.txt new file mode 100644 index 0000000000..b1ebc6b375 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [55] ) +Markup span at (22:0,22 [3] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [3] ) +Markup span at (25:0,25 [8] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [8] ) +Markup span at (33:0,33 [9] ) (Accepts:Any) - Parent: Tag block at (33:0,33 [9] ) +Markup span at (42:0,42 [4] ) (Accepts:Any) - Parent: Tag block at (42:0,42 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.stree.txt new file mode 100644 index 0000000000..4470ff5da3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..55)::55 - [

                        ] + MarkupBlock - [0..55)::55 + MarkupTagHelperElement - [0..55)::55 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [22..46)::24 + MarkupStartTag - [22..25)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [25..42)::17 + MarkupStartTag - [25..33)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [33..42)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [42..46)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [46..55)::9 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.tspans.txt new file mode 100644 index 0000000000..14ff8ee19f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [55] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.cspans.txt new file mode 100644 index 0000000000..40bebc3bdc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [57] ) +Markup span at (33:0,33 [2] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [38] ) +Markup span at (37:0,37 [3] ) (Accepts:Any) - Parent: Tag block at (37:0,37 [3] ) +Markup span at (40:0,40 [4] ) (Accepts:Any) - Parent: Tag block at (40:0,40 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.stree.txt new file mode 100644 index 0000000000..6ae5f26b33 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.stree.txt @@ -0,0 +1,60 @@ +RazorDocument - [0..57)::57 - [

                        ] + MarkupBlock - [0..57)::57 + MarkupTagHelperElement - [0..57)::57 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperElement - [15..53)::38 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [15..37)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [22..36)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [22..23)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [23..31)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [32..33)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [33..35)::2 + MarkupLiteralAttributeValue - [33..35)::2 - [hi] + MarkupTextLiteral - [33..35)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [37..44)::7 + MarkupStartTag - [37..40)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [40..44)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [44..53)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [53..57)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.tspans.txt new file mode 100644 index 0000000000..2075b5b276 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [57] ) - pTagHelper +TagHelper span at (15:0,15 [38] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.cspans.txt new file mode 100644 index 0000000000..0de746f4eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [67] ) +Markup span at (32:0,32 [3] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [36] ) +Markup span at (37:0,37 [8] ) (Accepts:Any) - Parent: Tag block at (37:0,37 [8] ) +Markup span at (45:0,45 [9] ) (Accepts:Any) - Parent: Tag block at (45:0,45 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.stree.txt new file mode 100644 index 0000000000..49ea5ff24c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.stree.txt @@ -0,0 +1,60 @@ +RazorDocument - [0..67)::67 - [

                        ] + MarkupBlock - [0..67)::67 + MarkupTagHelperElement - [0..67)::67 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperElement - [22..58)::36 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [22..37)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [24..36)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [25..30)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [31..32)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [32..35)::3 + MarkupLiteralAttributeValue - [32..35)::3 - [btn] + MarkupTextLiteral - [32..35)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [37..54)::17 + MarkupStartTag - [37..45)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [45..54)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [54..58)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [58..67)::9 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.tspans.txt new file mode 100644 index 0000000000..5986b90415 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [67] ) - catchAllTagHelper +TagHelper span at (22:0,22 [36] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.cspans.txt new file mode 100644 index 0000000000..e964e23037 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [45] ) +Markup span at (25:0,25 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [26] ) +Markup span at (30:0,30 [3] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [3] ) +Markup span at (33:0,33 [4] ) (Accepts:Any) - Parent: Tag block at (33:0,33 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.stree.txt new file mode 100644 index 0000000000..01e73cba7b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.stree.txt @@ -0,0 +1,60 @@ +RazorDocument - [0..45)::45 - [

                        ] + MarkupBlock - [0..45)::45 + MarkupTagHelperElement - [0..45)::45 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperElement - [15..41)::26 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [15..30)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [17..29)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [17..18)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [18..23)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [25..28)::3 + MarkupLiteralAttributeValue - [25..28)::3 - [btn] + MarkupTextLiteral - [25..28)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [28..29)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [30..37)::7 + MarkupStartTag - [30..33)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [33..37)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [37..41)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [41..45)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.tspans.txt new file mode 100644 index 0000000000..cf6b225441 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [45] ) - pTagHelper +TagHelper span at (15:0,15 [26] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.cspans.txt new file mode 100644 index 0000000000..76cf67d320 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [79] ) +Markup span at (40:0,40 [2] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [48] ) +Markup span at (44:0,44 [8] ) (Accepts:Any) - Parent: Tag block at (44:0,44 [8] ) +Markup span at (52:0,52 [9] ) (Accepts:Any) - Parent: Tag block at (52:0,52 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.stree.txt new file mode 100644 index 0000000000..3cedd737eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.stree.txt @@ -0,0 +1,60 @@ +RazorDocument - [0..79)::79 - [] + MarkupBlock - [0..79)::79 + MarkupTagHelperElement - [0..79)::79 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperElement - [22..70)::48 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [22..44)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [29..43)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [30..38)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [39..40)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [40..42)::2 + MarkupLiteralAttributeValue - [40..42)::2 - [hi] + MarkupTextLiteral - [40..42)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [42..43)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [44..61)::17 + MarkupStartTag - [44..52)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [52..61)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [61..70)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [70..79)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.tspans.txt new file mode 100644 index 0000000000..fbb7dffddd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [79] ) - catchAllTagHelper +TagHelper span at (22:0,22 [48] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.cspans.txt new file mode 100644 index 0000000000..0e3e22141f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [59] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) +Markup span at (18:0,18 [3] ) (Accepts:Any) - Parent: Tag block at (18:0,18 [3] ) +Markup span at (31:0,31 [3] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [26] ) +Markup span at (36:0,36 [3] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [3] ) +Markup span at (39:0,39 [4] ) (Accepts:Any) - Parent: Tag block at (39:0,39 [4] ) +Markup span at (47:0,47 [4] ) (Accepts:Any) - Parent: Tag block at (47:0,47 [4] ) +Markup span at (51:0,51 [4] ) (Accepts:Any) - Parent: Tag block at (51:0,51 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.stree.txt new file mode 100644 index 0000000000..b35bc7f9ea --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.stree.txt @@ -0,0 +1,80 @@ +RazorDocument - [0..59)::59 - [

                        ] + MarkupBlock - [0..59)::59 + MarkupTagHelperElement - [0..59)::59 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [15..55)::40 + MarkupStartTag - [15..18)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [18..51)::33 + MarkupStartTag - [18..21)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [21..47)::26 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [21..36)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [23..35)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [24..29)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [31..34)::3 + MarkupLiteralAttributeValue - [31..34)::3 - [btn] + MarkupTextLiteral - [31..34)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [34..35)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupElement - [36..43)::7 + MarkupStartTag - [36..39)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [39..43)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [43..47)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [47..51)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [51..55)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [55..59)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.tspans.txt new file mode 100644 index 0000000000..86c4e400c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NestedRequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [59] ) - pTagHelper +TagHelper span at (21:0,21 [26] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.cspans.txt new file mode 100644 index 0000000000..bdb0fcc428 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (6:0,6 [8] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [8] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Tag block at (14:0,14 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.stree.txt new file mode 100644 index 0000000000..55159ceffb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..30)::30 - [] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - th:p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:p]; + CloseAngle;[>]; + MarkupElement - [6..23)::17 + MarkupStartTag - [6..14)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [14..23)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [23..30)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.tspans.txt new file mode 100644 index 0000000000..2e5914e934 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/NonTagHelperChild_UnderstandsTagHelperPrefixAndAllowedChildren.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [30] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.cspans.txt new file mode 100644 index 0000000000..29554cdec9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (17:0,17 [8] ) (Accepts:Any) - Parent: Tag block at (17:0,17 [8] ) +Markup span at (25:0,25 [9] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.diag.txt new file mode 100644 index 0000000000..b4a862c68a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.diag.txt @@ -0,0 +1 @@ +(1,19): Error RZ2010: The tag is not allowed by parent tag helper. Only child tags with name(s) 'br' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.stree.txt new file mode 100644 index 0000000000..b0a4522426 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..43)::43 - [] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..43)::43 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [0..17)::17 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupMinimizedTagHelperAttribute - [7..16)::9 - required - Minimized - Unbound - [ required] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [required] - Gen - SpanEditHandler;Accepts:Any + Text;[required]; + CloseAngle;[>]; + MarkupElement - [17..34)::17 + MarkupStartTag - [17..25)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [25..34)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [34..43)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.tspans.txt new file mode 100644 index 0000000000..43893fed53 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RecoversWhenRequiredAttributeMismatchAndRestrictedChildren.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [43] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1.cspans.txt new file mode 100644 index 0000000000..f2fa2a31e2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1.stree.txt new file mode 100644 index 0000000000..a530591f30 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly1.stree.txt @@ -0,0 +1,7 @@ +RazorDocument - [0..2)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.cspans.txt new file mode 100644 index 0000000000..2a68a378d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (16:0,16 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +Markup span at (27:0,27 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.diag.txt new file mode 100644 index 0000000000..bcf9de93f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,35): Error RZ1035: Missing close angle for tag helper 'p'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.stree.txt new file mode 100644 index 0000000000..ae7efe7aac --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..35)::35 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..19)::17 - notRequired - DoubleQuotes - Unbound - [ notRequired="hi"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..18)::2 + MarkupLiteralAttributeValue - [16..18)::2 - [hi] + MarkupTextLiteral - [16..18)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [19..31)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..25)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..30)::3 + MarkupLiteralAttributeValue - [27..30)::3 - [btn] + MarkupTextLiteral - [27..30)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [31..32)::1 + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTagHelperEndTag - [32..35)::3 - []; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.tspans.txt new file mode 100644 index 0000000000..fcef603dfd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.cspans.txt new file mode 100644 index 0000000000..864bb27b43 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [14] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.stree.txt new file mode 100644 index 0000000000..6626113510 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..14)::14 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.tspans.txt new file mode 100644 index 0000000000..22abb2b118 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [14] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.cspans.txt new file mode 100644 index 0000000000..5835fa9258 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (16:0,16 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) +Markup span at (27:0,27 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.stree.txt new file mode 100644 index 0000000000..7a091f7704 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..31)::31 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..19)::17 - notRequired - DoubleQuotes - Unbound - [ notRequired="hi"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..18)::2 + MarkupLiteralAttributeValue - [16..18)::2 - [hi] + MarkupTextLiteral - [16..18)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [19..31)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..25)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..30)::3 + MarkupLiteralAttributeValue - [27..30)::3 - [btn] + MarkupTextLiteral - [27..30)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.tspans.txt new file mode 100644 index 0000000000..ea57174e6d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly4.cspans.txt new file mode 100644 index 0000000000..811b313443 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly4.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly4.stree.txt new file mode 100644 index 0000000000..f4d112be39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly4.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..6)::6 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [3..6)::3 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.cspans.txt new file mode 100644 index 0000000000..4fcdd1af8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.diag.txt new file mode 100644 index 0000000000..d26f4a4078 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.diag.txt @@ -0,0 +1 @@ +(1,18): Error RZ1035: Missing close angle for tag helper 'p'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.stree.txt new file mode 100644 index 0000000000..dd234ccf8a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..18)::18 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [15..18)::3 - []; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.tspans.txt new file mode 100644 index 0000000000..26aeee868e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [18] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.cspans.txt new file mode 100644 index 0000000000..2a68a378d2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (16:0,16 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +Markup span at (27:0,27 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.diag.txt new file mode 100644 index 0000000000..fa993c1831 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.diag.txt @@ -0,0 +1 @@ +(1,35): Error RZ1035: Missing close angle for tag helper 'p'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.stree.txt new file mode 100644 index 0000000000..5bb9e9e16c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..35)::35 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..19)::17 - notRequired - DoubleQuotes - Unbound - [ notRequired="hi"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..18)::2 + MarkupLiteralAttributeValue - [16..18)::2 - [hi] + MarkupTextLiteral - [16..18)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [19..31)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..25)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..30)::3 + MarkupLiteralAttributeValue - [27..30)::3 - [btn] + MarkupTextLiteral - [27..30)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [32..35)::3 - []; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.tspans.txt new file mode 100644 index 0000000000..fcef603dfd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.cspans.txt new file mode 100644 index 0000000000..96cb7028ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [18] ) +Markup span at (15:0,15 [3] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.stree.txt new file mode 100644 index 0000000000..344692192b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..18)::18 - [

                        ] + MarkupBlock - [0..18)::18 + MarkupTagHelperElement - [0..18)::18 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [14..15)::1 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupElement - [15..18)::3 + MarkupStartTag - [15..18)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.tspans.txt new file mode 100644 index 0000000000..26aeee868e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [18] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.cspans.txt new file mode 100644 index 0000000000..3ca120d8ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (16:0,16 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +Markup span at (27:0,27 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +Markup span at (32:0,32 [3] ) (Accepts:Any) - Parent: Tag block at (32:0,32 [3] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.diag.txt new file mode 100644 index 0000000000..b0e5b255ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.stree.txt new file mode 100644 index 0000000000..11f8d77b73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.stree.txt @@ -0,0 +1,43 @@ +RazorDocument - [0..35)::35 - [

                        ] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..32)::32 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..19)::17 - notRequired - DoubleQuotes - Unbound - [ notRequired="hi"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..18)::2 + MarkupLiteralAttributeValue - [16..18)::2 - [hi] + MarkupTextLiteral - [16..18)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [18..19)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [19..31)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [20..25)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [26..27)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [27..30)::3 + MarkupLiteralAttributeValue - [27..30)::3 - [btn] + MarkupTextLiteral - [27..30)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [30..31)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [31..32)::1 + MarkupTextLiteral - [31..32)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupElement - [32..35)::3 + MarkupStartTag - [32..35)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.tspans.txt new file mode 100644 index 0000000000..fcef603dfd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.cspans.txt new file mode 100644 index 0000000000..4fcdd1af8c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [18] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.diag.txt new file mode 100644 index 0000000000..ad599e94e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1035: Missing close angle for tag helper 'p'. +(1,18): Error RZ1035: Missing close angle for tag helper 'p'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.stree.txt new file mode 100644 index 0000000000..02201c2860 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.stree.txt @@ -0,0 +1,29 @@ +RazorDocument - [0..18)::18 - [

                        - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [14..15)::1 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[]; + MarkupTagHelperEndTag - [15..18)::3 - []; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.tspans.txt new file mode 100644 index 0000000000..26aeee868e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [18] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.cspans.txt new file mode 100644 index 0000000000..c559127169 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.stree.txt new file mode 100644 index 0000000000..054b8b4abb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly1.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..5)::5 - [

                        ] + MarkupBlock - [0..5)::5 + MarkupElement - [0..5)::5 + MarkupStartTag - [0..5)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupMiscAttributeContent - [2..3)::1 + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.cspans.txt new file mode 100644 index 0000000000..ce7d4197ff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.cspans.txt @@ -0,0 +1 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [24] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.stree.txt new file mode 100644 index 0000000000..23834d9b7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..24)::24 - strong[SelfClosing] - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [21..22)::1 + MarkupTextLiteral - [21..22)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.tspans.txt new file mode 100644 index 0000000000..fdc44d87e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly10.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [24] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.cspans.txt new file mode 100644 index 0000000000..b5022db073 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Expression block at (18:0,18 [13] ) +Code span at (19:0,19 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (18:0,18 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.stree.txt new file mode 100644 index 0000000000..d34eb6606f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..35)::35 - [] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - strong[SelfClosing] - catchAllTagHelper + MarkupTagHelperStartTag - [0..35)::35 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..32)::25 - catchAll - DoubleQuotes - Unbound - [ catchAll="@DateTime.Now"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..31)::13 + MarkupDynamicAttributeValue - [18..31)::13 - [@DateTime.Now] + GenericBlock - [18..31)::13 + CSharpCodeBlock - [18..31)::13 + CSharpImplicitExpression - [18..31)::13 + CSharpTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [19..31)::12 + CSharpCodeBlock - [19..31)::12 + CSharpExpressionLiteral - [19..31)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [31..32)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [32..33)::1 + MarkupTextLiteral - [32..33)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.tspans.txt new file mode 100644 index 0000000000..c2c433f527 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly11.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.cspans.txt new file mode 100644 index 0000000000..022c99d374 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (18:0,18 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [47] ) +Markup span at (22:0,22 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.stree.txt new file mode 100644 index 0000000000..7bbca39c69 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..47)::47 - [words and spaces] + MarkupBlock - [0..47)::47 + MarkupTagHelperElement - [0..47)::47 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..22)::22 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..21)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..20)::2 + MarkupLiteralAttributeValue - [18..20)::2 - [hi] + MarkupTextLiteral - [18..20)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [22..38)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [38..47)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.tspans.txt new file mode 100644 index 0000000000..3919132f79 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [47] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.cspans.txt new file mode 100644 index 0000000000..65ac8fc060 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (18:0,18 [1] ) (Accepts:None) - Parent: Expression block at (18:0,18 [13] ) +Code span at (19:0,19 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (18:0,18 [13] ) +Markup span at (33:0,33 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [58] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.stree.txt new file mode 100644 index 0000000000..f1cb474637 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..58)::58 - [words and spaces] + MarkupBlock - [0..58)::58 + MarkupTagHelperElement - [0..58)::58 - strong[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..33)::33 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupTagHelperAttribute - [7..32)::25 - catchAll - DoubleQuotes - Unbound - [ catchAll="@DateTime.Now"] + MarkupTextLiteral - [7..8)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [8..16)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [18..31)::13 + MarkupDynamicAttributeValue - [18..31)::13 - [@DateTime.Now] + GenericBlock - [18..31)::13 + CSharpCodeBlock - [18..31)::13 + CSharpImplicitExpression - [18..31)::13 + CSharpTransition - [18..19)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [19..31)::12 + CSharpCodeBlock - [19..31)::12 + CSharpExpressionLiteral - [19..31)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [31..32)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [33..49)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [49..58)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.tspans.txt new file mode 100644 index 0000000000..5518b4559b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly13.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [58] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14.cspans.txt new file mode 100644 index 0000000000..b66dc822e5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [19] ) +Markup span at (4:0,4 [8] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (16:0,16 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [19] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14.stree.txt new file mode 100644 index 0000000000..5592cdc198 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly14.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..19)::19 - [

                        ] + MarkupBlock - [0..19)::19 + MarkupElement - [0..19)::19 + MarkupStartTag - [0..19)::19 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupAttributeBlock - [4..16)::12 - [ class="btn"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [btn] + MarkupTextLiteral - [12..15)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15.cspans.txt new file mode 100644 index 0000000000..01fd0f4301 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [4] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) +Markup span at (4:0,4 [8] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (12:0,12 [3] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Markup block at (4:0,4 [12] ) +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) +Markup span at (17:0,17 [6] ) (Accepts:Any) - Parent: Tag block at (17:0,17 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15.stree.txt new file mode 100644 index 0000000000..abfb90c482 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly15.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..23)::23 - [
                        ] + MarkupBlock - [0..23)::23 + MarkupElement - [0..23)::23 + MarkupStartTag - [0..17)::17 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupAttributeBlock - [4..16)::12 - [ class="btn"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + GenericBlock - [12..15)::3 + MarkupLiteralAttributeValue - [12..15)::3 - [btn] + MarkupTextLiteral - [12..15)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupEndTag - [17..23)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.cspans.txt new file mode 100644 index 0000000000..266c0f349a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) +Markup span at (26:0,26 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [33] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.stree.txt new file mode 100644 index 0000000000..3b64e047c2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..33)::33 - [

                        ] + MarkupBlock - [0..33)::33 + MarkupTagHelperElement - [0..33)::33 - p[SelfClosing] - pTagHelper + MarkupTagHelperStartTag - [0..33)::33 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..18)::16 - notRequired - DoubleQuotes - Unbound - [ notRequired="a"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..17)::1 + MarkupLiteralAttributeValue - [16..17)::1 - [a] + MarkupTextLiteral - [16..17)::1 - [a] - Gen - SpanEditHandler;Accepts:Any + Text;[a]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [18..30)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..24)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [25..26)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [26..29)::3 + MarkupLiteralAttributeValue - [26..29)::3 - [btn] + MarkupTextLiteral - [26..29)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [29..30)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [30..31)::1 + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.tspans.txt new file mode 100644 index 0000000000..523daac96f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly16.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [33] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.cspans.txt new file mode 100644 index 0000000000..494b62f7a4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (16:0,16 [1] ) (Accepts:None) - Parent: Expression block at (16:0,16 [13] ) +Code span at (17:0,17 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (16:0,16 [13] ) +Markup span at (38:0,38 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.stree.txt new file mode 100644 index 0000000000..7bd28b0ac8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..45)::45 - [

                        ] + MarkupBlock - [0..45)::45 + MarkupTagHelperElement - [0..45)::45 - p[SelfClosing] - pTagHelper + MarkupTagHelperStartTag - [0..45)::45 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..30)::28 - notRequired - DoubleQuotes - Unbound - [ notRequired="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..29)::13 + MarkupDynamicAttributeValue - [16..29)::13 - [@DateTime.Now] + GenericBlock - [16..29)::13 + CSharpCodeBlock - [16..29)::13 + CSharpImplicitExpression - [16..29)::13 + CSharpTransition - [16..17)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [17..29)::12 + CSharpCodeBlock - [17..29)::12 + CSharpExpressionLiteral - [17..29)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [29..30)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [30..42)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [30..31)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [31..36)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [37..38)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [38..41)::3 + MarkupLiteralAttributeValue - [38..41)::3 - [btn] + MarkupTextLiteral - [38..41)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [41..42)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [42..43)::1 + MarkupTextLiteral - [42..43)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.tspans.txt new file mode 100644 index 0000000000..0209fdf6c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly17.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [45] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.cspans.txt new file mode 100644 index 0000000000..4962ba5ad6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (16:0,16 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [51] ) +Markup span at (26:0,26 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [51] ) +Markup span at (31:0,31 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.stree.txt new file mode 100644 index 0000000000..602f472c61 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..51)::51 - [

                        words and spaces

                        ] + MarkupBlock - [0..51)::51 + MarkupTagHelperElement - [0..51)::51 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..31)::31 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..18)::16 - notRequired - DoubleQuotes - Unbound - [ notRequired="a"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..14)::11 - [notRequired] - Gen - SpanEditHandler;Accepts:Any + Text;[notRequired]; + Equals;[=]; + MarkupTextLiteral - [15..16)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [16..17)::1 + MarkupLiteralAttributeValue - [16..17)::1 - [a] + MarkupTextLiteral - [16..17)::1 - [a] - Gen - SpanEditHandler;Accepts:Any + Text;[a]; + MarkupTextLiteral - [17..18)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [18..30)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [18..19)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [19..24)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [25..26)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [26..29)::3 + MarkupLiteralAttributeValue - [26..29)::3 - [btn] + MarkupTextLiteral - [26..29)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [29..30)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [31..47)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [47..51)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.tspans.txt new file mode 100644 index 0000000000..5f0754439a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly18.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [51] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.cspans.txt new file mode 100644 index 0000000000..2930101dc1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.stree.txt new file mode 100644 index 0000000000..0a1508e927 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..28)::28 - [
                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - div[SelfClosing] - divTagHelper + MarkupTagHelperStartTag - [0..28)::28 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [25..26)::1 + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.tspans.txt new file mode 100644 index 0000000000..15e7f93acc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly19.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - divTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.cspans.txt new file mode 100644 index 0000000000..38768af66f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [3] ) +Markup span at (3:0,3 [4] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.stree.txt new file mode 100644 index 0000000000..946629e678 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly2.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..7)::7 - [

                        ] + MarkupBlock - [0..7)::7 + MarkupElement - [0..7)::7 + MarkupStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [3..7)::4 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.cspans.txt new file mode 100644 index 0000000000..1ff5028dc0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [13] ) +Code span at (13:0,13 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [13] ) +Markup span at (34:0,34 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [41] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.stree.txt new file mode 100644 index 0000000000..ea25294ac4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.stree.txt @@ -0,0 +1,48 @@ +RazorDocument - [0..41)::41 - [
                        ] + MarkupBlock - [0..41)::41 + MarkupTagHelperElement - [0..41)::41 - div[SelfClosing] - divTagHelper + MarkupTagHelperStartTag - [0..41)::41 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..26)::22 - style - DoubleQuotes - Unbound - [ style="@DateTime.Now"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..25)::13 + MarkupDynamicAttributeValue - [12..25)::13 - [@DateTime.Now] + GenericBlock - [12..25)::13 + CSharpCodeBlock - [12..25)::13 + CSharpImplicitExpression - [12..25)::13 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..25)::12 + CSharpCodeBlock - [13..25)::12 + CSharpExpressionLiteral - [13..25)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [25..26)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [26..38)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [27..32)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [33..34)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [34..37)::3 + MarkupLiteralAttributeValue - [34..37)::3 - [btn] + MarkupTextLiteral - [34..37)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [37..38)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [38..39)::1 + MarkupTextLiteral - [38..39)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.tspans.txt new file mode 100644 index 0000000000..267c9ba9b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly20.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [41] ) - divTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.cspans.txt new file mode 100644 index 0000000000..17da676f68 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [48] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [48] ) +Markup span at (26:0,26 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [48] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.stree.txt new file mode 100644 index 0000000000..e86496b7c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..48)::48 - [
                        words and spaces
                        ] + MarkupBlock - [0..48)::48 + MarkupTagHelperElement - [0..48)::48 - div[StartTagAndEndTag] - divTagHelper + MarkupTagHelperStartTag - [0..26)::26 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [26..42)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [42..48)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.tspans.txt new file mode 100644 index 0000000000..1fa759ade1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly21.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [48] ) - divTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.cspans.txt new file mode 100644 index 0000000000..b5ef904e18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.cspans.txt @@ -0,0 +1,5 @@ +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [13] ) +Code span at (13:0,13 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [13] ) +Transition span at (34:0,34 [1] ) (Accepts:None) - Parent: Expression block at (34:0,34 [13] ) +Code span at (35:0,35 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (34:0,34 [13] ) +Markup span at (49:0,49 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [71] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.stree.txt new file mode 100644 index 0000000000..4710b0fc3b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.stree.txt @@ -0,0 +1,64 @@ +RazorDocument - [0..71)::71 - [
                        words and spaces
                        ] + MarkupBlock - [0..71)::71 + MarkupTagHelperElement - [0..71)::71 - div[StartTagAndEndTag] - divTagHelper + MarkupTagHelperStartTag - [0..49)::49 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..26)::22 - style - DoubleQuotes - Unbound - [ style="@DateTime.Now"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..25)::13 + MarkupDynamicAttributeValue - [12..25)::13 - [@DateTime.Now] + GenericBlock - [12..25)::13 + CSharpCodeBlock - [12..25)::13 + CSharpImplicitExpression - [12..25)::13 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..25)::12 + CSharpCodeBlock - [13..25)::12 + CSharpExpressionLiteral - [13..25)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [25..26)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [26..48)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [27..32)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [33..34)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [34..47)::13 + MarkupDynamicAttributeValue - [34..47)::13 - [@DateTime.Now] + GenericBlock - [34..47)::13 + CSharpCodeBlock - [34..47)::13 + CSharpImplicitExpression - [34..47)::13 + CSharpTransition - [34..35)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [35..47)::12 + CSharpCodeBlock - [35..47)::12 + CSharpExpressionLiteral - [35..47)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [47..48)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [49..65)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [65..71)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.tspans.txt new file mode 100644 index 0000000000..dffecb5c26 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly22.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [71] ) - divTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.cspans.txt new file mode 100644 index 0000000000..a788e1773e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (26:0,26 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (31:0,31 [8] ) (Accepts:Any) - Parent: Tag block at (31:0,31 [8] ) +Markup span at (39:0,39 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (42:0,42 [9] ) (Accepts:Any) - Parent: Tag block at (42:0,42 [9] ) +Markup span at (51:0,51 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.stree.txt new file mode 100644 index 0000000000..a968b1125d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.stree.txt @@ -0,0 +1,54 @@ +RazorDocument - [0..63)::63 - [
                        wordsandspaces
                        ] + MarkupBlock - [0..63)::63 + MarkupTagHelperElement - [0..63)::63 - div[StartTagAndEndTag] - divTagHelper + MarkupTagHelperStartTag - [0..26)::26 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [26..31)::5 - [words] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + MarkupElement - [31..51)::20 + MarkupStartTag - [31..39)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [39..42)::3 - [and] - Gen - SpanEditHandler;Accepts:Any + Text;[and]; + MarkupEndTag - [42..51)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [51..57)::6 - [spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[spaces]; + MarkupTagHelperEndTag - [57..63)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.tspans.txt new file mode 100644 index 0000000000..ed9fa4bce0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly23.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [63] ) - divTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.cspans.txt new file mode 100644 index 0000000000..0d58538fb8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) +Markup span at (25:0,25 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [31] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.stree.txt new file mode 100644 index 0000000000..022c83310c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.stree.txt @@ -0,0 +1,39 @@ +RazorDocument - [0..31)::31 - [

                        ] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - p[SelfClosing] - pTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..31)::31 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [14..28)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [25..27)::2 + MarkupLiteralAttributeValue - [25..27)::2 - [hi] + MarkupTextLiteral - [25..27)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [27..28)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [28..29)::1 + MarkupTextLiteral - [28..29)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.tspans.txt new file mode 100644 index 0000000000..6fb86e9357 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly24.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [31] ) - pTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.cspans.txt new file mode 100644 index 0000000000..4e62a5fb59 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [49] ) +Markup span at (25:0,25 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [49] ) +Markup span at (29:0,29 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [49] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.stree.txt new file mode 100644 index 0000000000..a9c4c20ef5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..49)::49 - [

                        words and spaces

                        ] + MarkupBlock - [0..49)::49 + MarkupTagHelperElement - [0..49)::49 - p[StartTagAndEndTag] - pTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..29)::29 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [14..28)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [25..27)::2 + MarkupLiteralAttributeValue - [25..27)::2 - [hi] + MarkupTextLiteral - [25..27)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [27..28)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [29..45)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [45..49)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.tspans.txt new file mode 100644 index 0000000000..df0f66ba2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly25.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [49] ) - pTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.cspans.txt new file mode 100644 index 0000000000..4a50e7e4a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.cspans.txt @@ -0,0 +1,3 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [42] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [42] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [42] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.stree.txt new file mode 100644 index 0000000000..4f7b900664 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.stree.txt @@ -0,0 +1,51 @@ +RazorDocument - [0..42)::42 - [
                        ] + MarkupBlock - [0..42)::42 + MarkupTagHelperElement - [0..42)::42 - div[SelfClosing] - divTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..42)::42 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [25..39)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..34)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [36..38)::2 + MarkupLiteralAttributeValue - [36..38)::2 - [hi] + MarkupTextLiteral - [36..38)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [38..39)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [39..40)::1 + MarkupTextLiteral - [39..40)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.tspans.txt new file mode 100644 index 0000000000..4820770a5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly26.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [42] ) - divTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.cspans.txt new file mode 100644 index 0000000000..49b2350a05 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) +Markup span at (41:0,41 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [63] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.stree.txt new file mode 100644 index 0000000000..063a4bd7a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..63)::63 - [
                        words and spaces
                        ] + MarkupBlock - [0..63)::63 + MarkupTagHelperElement - [0..63)::63 - div[StartTagAndEndTag] - divTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..41)::41 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [25..39)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..34)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [36..38)::2 + MarkupLiteralAttributeValue - [36..38)::2 - [hi] + MarkupTextLiteral - [36..38)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [38..39)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [39..40)::1 + MarkupTextLiteral - [39..40)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [41..57)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [57..63)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.tspans.txt new file mode 100644 index 0000000000..107a34c817 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly27.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [63] ) - divTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.cspans.txt new file mode 100644 index 0000000000..b76fbd29f0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [65] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [65] ) +Markup span at (36:0,36 [1] ) (Accepts:None) - Parent: Markup block at (36:0,36 [2] ) +Markup span at (37:0,37 [1] ) (Accepts:None) - Parent: Markup block at (36:0,36 [2] ) +Markup span at (38:0,38 [2] ) (Accepts:Any) - Parent: Markup block at (36:0,36 [4] ) +Markup span at (43:0,43 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [65] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.stree.txt new file mode 100644 index 0000000000..299d41d22b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.stree.txt @@ -0,0 +1,66 @@ +RazorDocument - [0..65)::65 - [
                        words and spaces
                        ] + MarkupBlock - [0..65)::65 + MarkupTagHelperElement - [0..65)::65 - div[StartTagAndEndTag] - divTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..43)::43 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [25..41)::16 - catchAll - DoubleQuotes - Unbound - [ catchAll="@@hi"] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..34)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [36..40)::4 + MarkupBlock - [36..38)::2 + MarkupTextLiteral - [36..37)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupEphemeralTextLiteral - [37..38)::1 - [@] - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + MarkupLiteralAttributeValue - [38..40)::2 - [hi] + MarkupTextLiteral - [38..40)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [40..41)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [41..42)::1 + MarkupTextLiteral - [41..42)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [43..59)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [59..65)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.tspans.txt new file mode 100644 index 0000000000..c45dca540d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly28.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [65] ) - divTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.cspans.txt new file mode 100644 index 0000000000..e1f21dcb28 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.cspans.txt @@ -0,0 +1,7 @@ +Transition span at (12:0,12 [1] ) (Accepts:None) - Parent: Expression block at (12:0,12 [13] ) +Code span at (13:0,13 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (12:0,12 [13] ) +Transition span at (34:0,34 [1] ) (Accepts:None) - Parent: Expression block at (34:0,34 [13] ) +Code span at (35:0,35 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (34:0,34 [13] ) +Transition span at (59:0,59 [1] ) (Accepts:None) - Parent: Expression block at (59:0,59 [13] ) +Code span at (60:0,60 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (59:0,59 [13] ) +Markup span at (75:0,75 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [97] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.stree.txt new file mode 100644 index 0000000000..66753f7bd0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.stree.txt @@ -0,0 +1,90 @@ +RazorDocument - [0..97)::97 - [
                        words and spaces
                        ] + MarkupBlock - [0..97)::97 + MarkupTagHelperElement - [0..97)::97 - div[StartTagAndEndTag] - divTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..75)::75 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..26)::22 - style - DoubleQuotes - Unbound - [ style="@DateTime.Now"] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..25)::13 + MarkupDynamicAttributeValue - [12..25)::13 - [@DateTime.Now] + GenericBlock - [12..25)::13 + CSharpCodeBlock - [12..25)::13 + CSharpImplicitExpression - [12..25)::13 + CSharpTransition - [12..13)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [13..25)::12 + CSharpCodeBlock - [13..25)::12 + CSharpExpressionLiteral - [13..25)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [25..26)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [26..48)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [26..27)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [27..32)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [33..34)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [34..47)::13 + MarkupDynamicAttributeValue - [34..47)::13 - [@DateTime.Now] + GenericBlock - [34..47)::13 + CSharpCodeBlock - [34..47)::13 + CSharpImplicitExpression - [34..47)::13 + CSharpTransition - [34..35)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [35..47)::12 + CSharpCodeBlock - [35..47)::12 + CSharpExpressionLiteral - [35..47)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [47..48)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [48..73)::25 - catchAll - DoubleQuotes - Unbound - [ catchAll="@DateTime.Now"] + MarkupTextLiteral - [48..49)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [49..57)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [58..59)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [59..72)::13 + MarkupDynamicAttributeValue - [59..72)::13 - [@DateTime.Now] + GenericBlock - [59..72)::13 + CSharpCodeBlock - [59..72)::13 + CSharpImplicitExpression - [59..72)::13 + CSharpTransition - [59..60)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [60..72)::12 + CSharpCodeBlock - [60..72)::12 + CSharpExpressionLiteral - [60..72)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [72..73)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [73..74)::1 + MarkupTextLiteral - [73..74)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [75..91)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [91..97)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.tspans.txt new file mode 100644 index 0000000000..5b10442647 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly29.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [97] ) - divTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.cspans.txt new file mode 100644 index 0000000000..4f69cb3f10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.cspans.txt @@ -0,0 +1 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.stree.txt new file mode 100644 index 0000000000..306fe73b84 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly3.stree.txt @@ -0,0 +1,11 @@ +RazorDocument - [0..7)::7 - [
                        ] + MarkupBlock - [0..7)::7 + MarkupElement - [0..7)::7 + MarkupStartTag - [0..7)::7 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupMiscAttributeContent - [4..5)::1 + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.cspans.txt new file mode 100644 index 0000000000..9fec06bb52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (12:0,12 [0] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [78] ) +Markup span at (21:0,21 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [78] ) +Markup span at (36:0,36 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [78] ) +Markup span at (41:0,41 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [78] ) +Markup span at (46:0,46 [8] ) (Accepts:Any) - Parent: Tag block at (46:0,46 [8] ) +Markup span at (54:0,54 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [78] ) +Markup span at (57:0,57 [9] ) (Accepts:Any) - Parent: Tag block at (57:0,57 [9] ) +Markup span at (66:0,66 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [78] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.stree.txt new file mode 100644 index 0000000000..fae4f1917f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.stree.txt @@ -0,0 +1,71 @@ +RazorDocument - [0..78)::78 - [
                        wordsandspaces
                        ] + MarkupBlock - [0..78)::78 + MarkupTagHelperElement - [0..78)::78 - div[StartTagAndEndTag] - divTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..41)::41 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + MarkupTagHelperAttribute - [4..13)::9 - style - DoubleQuotes - Unbound - [ style=""] + MarkupTextLiteral - [4..5)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [5..10)::5 - [style] - Gen - SpanEditHandler;Accepts:Any + Text;[style]; + Equals;[=]; + MarkupTextLiteral - [11..12)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [12..12)::0 + MarkupTextLiteral - [12..12)::0 - [] + MarkupTextLiteral - [12..13)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [13..25)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [13..14)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [14..19)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [20..21)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [21..24)::3 + MarkupLiteralAttributeValue - [21..24)::3 - [btn] + MarkupTextLiteral - [21..24)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [24..25)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttribute - [25..39)::14 - catchAll - DoubleQuotes - Unbound - [ catchAll="hi"] + MarkupTextLiteral - [25..26)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [26..34)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + Equals;[=]; + MarkupTextLiteral - [35..36)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [36..38)::2 + MarkupLiteralAttributeValue - [36..38)::2 - [hi] + MarkupTextLiteral - [36..38)::2 - [hi] - Gen - SpanEditHandler;Accepts:Any + Text;[hi]; + MarkupTextLiteral - [38..39)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [39..40)::1 + MarkupTextLiteral - [39..40)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + CloseAngle;[>]; + MarkupTextLiteral - [41..46)::5 - [words] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + MarkupElement - [46..66)::20 + MarkupStartTag - [46..54)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [54..57)::3 - [and] - Gen - SpanEditHandler;Accepts:Any + Text;[and]; + MarkupEndTag - [57..66)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [66..72)::6 - [spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[spaces]; + MarkupTagHelperEndTag - [72..78)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.tspans.txt new file mode 100644 index 0000000000..e10503a044 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly30.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [78] ) - divTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.cspans.txt new file mode 100644 index 0000000000..b02774d867 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (5:0,5 [6] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.stree.txt new file mode 100644 index 0000000000..251a137553 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly4.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..11)::11 - [
                        ] + MarkupBlock - [0..11)::11 + MarkupElement - [0..11)::11 + MarkupStartTag - [0..5)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupEndTag - [5..11)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.cspans.txt new file mode 100644 index 0000000000..7514a2b315 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.stree.txt new file mode 100644 index 0000000000..f801f2c8f1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..17)::17 - [

                        ] + MarkupBlock - [0..17)::17 + MarkupTagHelperElement - [0..17)::17 - p[SelfClosing] - pTagHelper + MarkupTagHelperStartTag - [0..17)::17 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [14..15)::1 + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.tspans.txt new file mode 100644 index 0000000000..a46dc9658a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [17] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.cspans.txt new file mode 100644 index 0000000000..0dd5fb1015 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.cspans.txt @@ -0,0 +1,2 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.stree.txt new file mode 100644 index 0000000000..de832b25f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.stree.txt @@ -0,0 +1,34 @@ +RazorDocument - [0..27)::27 - [

                        ] + MarkupBlock - [0..27)::27 + MarkupTagHelperElement - [0..27)::27 - p[SelfClosing] - pTagHelper + MarkupTagHelperStartTag - [0..27)::27 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..23)::13 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupMiscAttributeContent - [24..25)::1 + MarkupTextLiteral - [24..25)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.tspans.txt new file mode 100644 index 0000000000..13aba97ce9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly6.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [27] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.cspans.txt new file mode 100644 index 0000000000..82a1ccb4b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) +Markup span at (15:0,15 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [35] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.stree.txt new file mode 100644 index 0000000000..d6bf5ef204 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..35)::35 - [

                        words and spaces

                        ] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [15..31)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [31..35)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.tspans.txt new file mode 100644 index 0000000000..fcef603dfd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly7.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [35] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.cspans.txt new file mode 100644 index 0000000000..57aac25125 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.cspans.txt @@ -0,0 +1,3 @@ +Transition span at (10:0,10 [1] ) (Accepts:None) - Parent: Expression block at (10:0,10 [13] ) +Code span at (11:0,11 [12] ) (Accepts:NonWhitespace) - Parent: Expression block at (10:0,10 [13] ) +Markup span at (25:0,25 [16] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.stree.txt new file mode 100644 index 0000000000..d6ec53fc94 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.stree.txt @@ -0,0 +1,41 @@ +RazorDocument - [0..45)::45 - [

                        words and spaces

                        ] + MarkupBlock - [0..45)::45 + MarkupTagHelperElement - [0..45)::45 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..25)::25 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..24)::22 - class - DoubleQuotes - Unbound - [ class="@DateTime.Now"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..23)::13 + MarkupDynamicAttributeValue - [10..23)::13 - [@DateTime.Now] + GenericBlock - [10..23)::13 + CSharpCodeBlock - [10..23)::13 + CSharpImplicitExpression - [10..23)::13 + CSharpTransition - [10..11)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [11..23)::12 + CSharpCodeBlock - [11..23)::12 + CSharpExpressionLiteral - [11..23)::12 - [DateTime.Now] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[DateTime]; + Dot;[.]; + Identifier;[Now]; + MarkupTextLiteral - [23..24)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [25..41)::16 - [words and spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + Whitespace;[ ]; + Text;[and]; + Whitespace;[ ]; + Text;[spaces]; + MarkupTagHelperEndTag - [41..45)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.tspans.txt new file mode 100644 index 0000000000..0209fdf6c5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly8.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [45] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.cspans.txt new file mode 100644 index 0000000000..aac0423123 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [50] ) +Markup span at (15:0,15 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [50] ) +Markup span at (20:0,20 [8] ) (Accepts:Any) - Parent: Tag block at (20:0,20 [8] ) +Markup span at (28:0,28 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [50] ) +Markup span at (31:0,31 [9] ) (Accepts:Any) - Parent: Tag block at (31:0,31 [9] ) +Markup span at (40:0,40 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [50] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.stree.txt new file mode 100644 index 0000000000..7811d88207 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.stree.txt @@ -0,0 +1,42 @@ +RazorDocument - [0..50)::50 - [

                        wordsandspaces

                        ] + MarkupBlock - [0..50)::50 + MarkupTagHelperElement - [0..50)::50 - p[StartTagAndEndTag] - pTagHelper + MarkupTagHelperStartTag - [0..15)::15 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - DoubleQuotes - Unbound - [ class="btn"] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [btn] + MarkupTextLiteral - [10..13)::3 - [btn] - Gen - SpanEditHandler;Accepts:Any + Text;[btn]; + MarkupTextLiteral - [13..14)::1 - ["] - Gen - SpanEditHandler;Accepts:Any + DoubleQuote;["]; + CloseAngle;[>]; + MarkupTextLiteral - [15..20)::5 - [words] - Gen - SpanEditHandler;Accepts:Any + Text;[words]; + MarkupElement - [20..40)::20 + MarkupStartTag - [20..28)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [28..31)::3 - [and] - Gen - SpanEditHandler;Accepts:Any + Text;[and]; + MarkupEndTag - [31..40)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [40..46)::6 - [spaces] - Gen - SpanEditHandler;Accepts:Any + Text;[spaces]; + MarkupTagHelperEndTag - [46..50)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.tspans.txt new file mode 100644 index 0000000000..f26abbe016 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RequiredAttributeDescriptorsCreateTagHelperBlocksCorrectly9.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [50] ) - pTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.stree.txt new file mode 100644 index 0000000000..80fe4a7c6a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..18)::18 - [

                        ] + MarkupBlock - [0..18)::18 + MarkupTagHelperElement - [0..18)::18 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..14)::11 - div[StartTagAndEndTag] - divtaghelper + MarkupTagHelperStartTag - [3..8)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [8..14)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [14..18)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.tspans.txt new file mode 100644 index 0000000000..c6e74368cc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks1.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [18] ) - ptaghelper +TagHelper span at (3:0,3 [11] ) - divtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.cspans.txt new file mode 100644 index 0000000000..217baf9220 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [12] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [30] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.stree.txt new file mode 100644 index 0000000000..878ac67dcb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..30)::30 - [

                        Hello World

                        ] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..15)::12 - [Hello World ] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + Whitespace;[ ]; + Text;[World]; + Whitespace;[ ]; + MarkupTagHelperElement - [15..26)::11 - div[StartTagAndEndTag] - divtaghelper + MarkupTagHelperStartTag - [15..20)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [20..26)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [26..30)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.tspans.txt new file mode 100644 index 0000000000..a24b08ac0e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [30] ) - ptaghelper +TagHelper span at (15:0,15 [11] ) - divtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.cspans.txt new file mode 100644 index 0000000000..5eee6a7160 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [19] ) +Markup span at (9:0,9 [2] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [9] ) +Markup span at (19:0,19 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [43] ) +Markup span at (28:0,28 [5] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.stree.txt new file mode 100644 index 0000000000..1b8b0b8258 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..43)::43 - [

                        Hel

                        lo

                        World

                        ] + MarkupBlock - [0..43)::43 + MarkupTagHelperElement - [0..19)::19 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..6)::3 - [Hel] - Gen - SpanEditHandler;Accepts:Any + Text;[Hel]; + MarkupTagHelperElement - [6..15)::9 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [6..9)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [9..11)::2 - [lo] - Gen - SpanEditHandler;Accepts:Any + Text;[lo]; + MarkupTagHelperEndTag - [11..15)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [15..19)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [20..43)::23 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [20..23)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [23..39)::16 - div[StartTagAndEndTag] - divtaghelper + MarkupTagHelperStartTag - [23..28)::5 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [28..33)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupTagHelperEndTag - [33..39)::6 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [39..43)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.tspans.txt new file mode 100644 index 0000000000..99e05e1570 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks3.tspans.txt @@ -0,0 +1,4 @@ +TagHelper span at (0:0,0 [19] ) - ptaghelper +TagHelper span at (6:0,6 [9] ) - ptaghelper +TagHelper span at (20:0,20 [23] ) - ptaghelper +TagHelper span at (23:0,23 [16] ) - divtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.cspans.txt new file mode 100644 index 0000000000..34608d7a1d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (3:0,3 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [29] ) +Markup span at (6:0,6 [8] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [8] ) +Markup span at (14:0,14 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [29] ) +Markup span at (16:0,16 [9] ) (Accepts:Any) - Parent: Tag block at (16:0,16 [9] ) +Markup span at (29:0,29 [1] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [55] ) +Markup span at (33:0,33 [6] ) (Accepts:Any) - Parent: Tag block at (33:0,33 [6] ) +Markup span at (39:0,39 [5] ) (Accepts:Any) - Parent: Tag block at (30:0,30 [25] ) +Markup span at (44:0,44 [7] ) (Accepts:Any) - Parent: Tag block at (44:0,44 [7] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.stree.txt new file mode 100644 index 0000000000..23f1042fb1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..55)::55 - [

                        Hello

                        World

                        ] + MarkupBlock - [0..55)::55 + MarkupTagHelperElement - [0..29)::29 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..6)::3 - [Hel] - Gen - SpanEditHandler;Accepts:Any + Text;[Hel]; + MarkupElement - [6..25)::19 + MarkupStartTag - [6..14)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [14..16)::2 - [lo] - Gen - SpanEditHandler;Accepts:Any + Text;[lo]; + MarkupEndTag - [16..25)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [25..29)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [30..55)::25 - p[StartTagAndEndTag] - ptaghelper + MarkupTagHelperStartTag - [30..33)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [33..51)::18 + MarkupStartTag - [33..39)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [39..44)::5 - [World] - Gen - SpanEditHandler;Accepts:Any + Text;[World]; + MarkupEndTag - [44..51)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [51..55)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.tspans.txt new file mode 100644 index 0000000000..9ff63342bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/RewritesNestedTagHelperTagBlocks4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [29] ) - ptaghelper +TagHelper span at (30:0,30 [25] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.stree.txt new file mode 100644 index 0000000000..8d2006107c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..13)::13 - [


                        ] + MarkupBlock - [0..13)::13 + MarkupTagHelperElement - [0..13)::13 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..9)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [3..9)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [9..13)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.tspans.txt new file mode 100644 index 0000000000..f1b18b4065 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren1.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [13] ) - PTagHelper +TagHelper span at (3:0,3 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.cspans.txt new file mode 100644 index 0000000000..d2c5955635 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [47] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [4] ) +Markup span at (25:0,25 [11] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [47] ) +Markup span at (36:0,36 [5] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [5] ) +Markup span at (56:0,56 [9] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [69] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.diag.txt new file mode 100644 index 0000000000..251fa1828e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.diag.txt @@ -0,0 +1,5 @@ +(1,12): Error RZ2009: The parent tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong' are allowed. +(1,19): Error RZ2010: The
                        tag is not allowed by parent tag helper. Only child tags with name(s) 'strong' are allowed. +(1,23): Error RZ2010: The tag is not allowed by parent tag helper. Only child tags with name(s) 'strong' are allowed. +(1,52): Error RZ2010: The
                        tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'strong' are allowed. +(1,57): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.stree.txt new file mode 100644 index 0000000000..3bf30508ec --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.stree.txt @@ -0,0 +1,56 @@ +RazorDocument - [0..69)::69 - [

                        Title:
                        A Very Cool

                        Something

                        ] + MarkupBlock - [0..69)::69 + MarkupTagHelperElement - [0..69)::69 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..50)::47 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [11..17)::6 - [Title:] - Gen - SpanEditHandler;Accepts:Any + Text;[Title:]; + MarkupTagHelperElement - [17..21)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [17..21)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupElement - [21..41)::20 + MarkupStartTag - [21..25)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[em]; + CloseAngle;[>]; + MarkupTextLiteral - [25..36)::11 - [A Very Cool] - Gen - SpanEditHandler;Accepts:Any + Text;[A]; + Whitespace;[ ]; + Text;[Very]; + Whitespace;[ ]; + Text;[Cool]; + MarkupEndTag - [36..41)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[em]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [41..50)::9 - [
                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [50..56)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [50..56)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [53..54)::1 + MarkupTextLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [56..65)::9 - [Something] - Gen - SpanEditHandler;Accepts:Any + Text;[Something]; + MarkupTagHelperEndTag - [65..69)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.tspans.txt new file mode 100644 index 0000000000..882c9f8332 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren10.tspans.txt @@ -0,0 +1,4 @@ +TagHelper span at (0:0,0 [69] ) - PTagHelper +TagHelper span at (3:0,3 [47] ) - StrongTagHelper +TagHelper span at (17:0,17 [4] ) - BRTagHelper +TagHelper span at (50:0,50 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.cspans.txt new file mode 100644 index 0000000000..22b36ea704 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.cspans.txt @@ -0,0 +1,7 @@ +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [8] ) +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [69] ) +Markup span at (21:0,21 [4] ) (Accepts:Any) - Parent: Tag block at (21:0,21 [4] ) +Markup span at (25:0,25 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [69] ) +Markup span at (36:0,36 [5] ) (Accepts:Any) - Parent: Tag block at (36:0,36 [5] ) +Markup span at (41:0,41 [9] ) (Accepts:Any) - Parent: Tag block at (41:0,41 [9] ) +Markup span at (56:0,56 [9] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [69] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.diag.txt new file mode 100644 index 0000000000..6589efa832 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.diag.txt @@ -0,0 +1,2 @@ +(1,52): Error RZ2010: The
                        tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'custom' are allowed. +(1,57): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'custom' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.stree.txt new file mode 100644 index 0000000000..3ff1ebec20 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.stree.txt @@ -0,0 +1,56 @@ +RazorDocument - [0..69)::69 - [

                        Title:
                        A Very Cool

                        Something

                        ] + MarkupBlock - [0..69)::69 + MarkupTagHelperElement - [0..69)::69 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..50)::47 + MarkupStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[custom]; + CloseAngle;[>]; + MarkupTextLiteral - [11..17)::6 - [Title:] - Gen - SpanEditHandler;Accepts:Any + Text;[Title:]; + MarkupTagHelperElement - [17..21)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [17..21)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupElement - [21..41)::20 + MarkupStartTag - [21..25)::4 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[em]; + CloseAngle;[>]; + MarkupTextLiteral - [25..36)::11 - [A Very Cool] - Gen - SpanEditHandler;Accepts:Any + Text;[A]; + Whitespace;[ ]; + Text;[Very]; + Whitespace;[ ]; + Text;[Cool]; + MarkupEndTag - [36..41)::5 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[em]; + CloseAngle;[>]; + MarkupEndTag - [41..50)::9 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[custom]; + CloseAngle;[>]; + MarkupTagHelperElement - [50..56)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [50..56)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [53..54)::1 + MarkupTextLiteral - [53..54)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [56..65)::9 - [Something] - Gen - SpanEditHandler;Accepts:Any + Text;[Something]; + MarkupTagHelperEndTag - [65..69)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.tspans.txt new file mode 100644 index 0000000000..9456a2bf5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren11.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [69] ) - PTagHelper +TagHelper span at (17:0,17 [4] ) - BRTagHelper +TagHelper span at (50:0,50 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.cspans.txt new file mode 100644 index 0000000000..b3958cf71b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.diag.txt new file mode 100644 index 0000000000..063da0eb5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'custom' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.stree.txt new file mode 100644 index 0000000000..5a9413f6d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..9)::9 - [

                        ] + MarkupBlock - [0..9)::9 + MarkupTagHelperElement - [0..9)::9 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..5)::2 + MarkupEndTag - [3..5)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [5..9)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.tspans.txt new file mode 100644 index 0000000000..60f5356683 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren12.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [9] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.cspans.txt new file mode 100644 index 0000000000..31c8ea8ce8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [1] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [1] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.diag.txt new file mode 100644 index 0000000000..063da0eb5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'custom' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.stree.txt new file mode 100644 index 0000000000..4ca6ee6ef6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..8)::8 - [

                        <

                        ] + MarkupBlock - [0..8)::8 + MarkupTagHelperElement - [0..8)::8 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..4)::1 + MarkupStartTag - [3..4)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [4..8)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.tspans.txt new file mode 100644 index 0000000000..b8f64937bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren13.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [8] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.cspans.txt new file mode 100644 index 0000000000..92bc9cb1dc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (3:0,3 [8] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [8] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [76] ) +Markup span at (32:0,32 [5] ) (Accepts:Any) - Parent: Tag block at (24:0,24 [22] ) +Markup span at (55:0,55 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [76] ) +Markup span at (56:0,56 [7] ) (Accepts:Any) - Parent: Tag block at (56:0,56 [7] ) +Markup span at (63:0,63 [9] ) (Accepts:Any) - Parent: Tag block at (63:0,63 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.diag.txt new file mode 100644 index 0000000000..dba76059c7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.diag.txt @@ -0,0 +1 @@ +(1,33): Error RZ2009: The parent tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'custom, strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.stree.txt new file mode 100644 index 0000000000..854aed8c29 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..76)::76 - [


                        :Hello:

                        ] + MarkupBlock - [0..76)::76 + MarkupTagHelperElement - [0..76)::76 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..72)::69 + MarkupStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[custom]; + CloseAngle;[>]; + MarkupTagHelperElement - [11..15)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [11..15)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTextLiteral - [15..16)::1 - [:] - Gen - SpanEditHandler;Accepts:Any + Text;[:]; + MarkupTagHelperElement - [16..55)::39 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [16..24)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [24..46)::22 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [24..32)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [32..37)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [37..46)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [46..55)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [55..56)::1 - [:] - Gen - SpanEditHandler;Accepts:Any + Text;[:]; + MarkupElement - [56..63)::7 + MarkupStartTag - [56..63)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupEndTag - [63..72)::9 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[custom]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [72..76)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.tspans.txt new file mode 100644 index 0000000000..bcff6cc882 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren14.tspans.txt @@ -0,0 +1,4 @@ +TagHelper span at (0:0,0 [76] ) - PTagHelper +TagHelper span at (11:0,11 [4] ) - BRTagHelper +TagHelper span at (16:0,16 [39] ) - StrongTagHelper +TagHelper span at (24:0,24 [22] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.cspans.txt new file mode 100644 index 0000000000..ed768b841c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) +Markup span at (11:1,6 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [17] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.stree.txt new file mode 100644 index 0000000000..e7698afb7f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.stree.txt @@ -0,0 +1,25 @@ +RazorDocument - [0..17)::17 - [

                        LF
                        LF

                        ] + MarkupBlock - [0..17)::17 + MarkupTagHelperElement - [0..17)::17 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..5)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTagHelperElement - [5..11)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [5..11)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [8..9)::1 + MarkupTextLiteral - [8..9)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [11..13)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTagHelperEndTag - [13..17)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.tspans.txt new file mode 100644 index 0000000000..e1f410f604 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [17] ) - PTagHelper +TagHelper span at (5:1,0 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.diag.txt new file mode 100644 index 0000000000..a7c54ec3cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ2010: The
                        tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.stree.txt new file mode 100644 index 0000000000..d0e1b59dd7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..11)::11 - [


                        ] + MarkupBlock - [0..11)::11 + MarkupTagHelperElement - [0..11)::11 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..7)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [3..7)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [7..11)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.tspans.txt new file mode 100644 index 0000000000..ae1b0f8418 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [11] ) - PTagHelper +TagHelper span at (3:0,3 [4] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.cspans.txt new file mode 100644 index 0000000000..51162d34c3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [12] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.diag.txt new file mode 100644 index 0000000000..e4dbe01b43 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.stree.txt new file mode 100644 index 0000000000..504b072dfb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.stree.txt @@ -0,0 +1,14 @@ +RazorDocument - [0..12)::12 - [

                        Hello

                        ] + MarkupBlock - [0..12)::12 + MarkupTagHelperElement - [0..12)::12 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..8)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [8..12)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.tspans.txt new file mode 100644 index 0000000000..5cd52523a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [12] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.cspans.txt new file mode 100644 index 0000000000..85c1b5ca5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.diag.txt new file mode 100644 index 0000000000..538e0bf30f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.diag.txt @@ -0,0 +1 @@ +(1,5): Error RZ2010: The
                        tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'br, strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.stree.txt new file mode 100644 index 0000000000..e220712ca9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.stree.txt @@ -0,0 +1,21 @@ +RazorDocument - [0..13)::13 - [


                        ] + MarkupBlock - [0..13)::13 + MarkupTagHelperElement - [0..13)::13 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..9)::6 + MarkupStartTag - [3..9)::6 - [


                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[hr]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [9..13)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.tspans.txt new file mode 100644 index 0000000000..a947feb3b1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [13] ) - PTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.cspans.txt new file mode 100644 index 0000000000..5e84b178d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.cspans.txt @@ -0,0 +1 @@ +Markup span at (7:0,7 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [16] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.diag.txt new file mode 100644 index 0000000000..4206048463 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.diag.txt @@ -0,0 +1,2 @@ +(1,5): Error RZ2010: The
                        tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'strong' are allowed. +(1,8): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.stree.txt new file mode 100644 index 0000000000..bbbaa92ea1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.stree.txt @@ -0,0 +1,19 @@ +RazorDocument - [0..16)::16 - [


                        Hello

                        ] + MarkupBlock - [0..16)::16 + MarkupTagHelperElement - [0..16)::16 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..7)::4 - br[StartTagOnly] - BRTagHelper + MarkupTagHelperStartTag - [3..7)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTextLiteral - [7..12)::5 - [Hello] - Gen - SpanEditHandler;Accepts:Any + Text;[Hello]; + MarkupTagHelperEndTag - [12..16)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.tspans.txt new file mode 100644 index 0000000000..43f281c42c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren6.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [16] ) - PTagHelper +TagHelper span at (3:0,3 [4] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.cspans.txt new file mode 100644 index 0000000000..7815c5f788 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [23] ) +Markup span at (32:0,32 [9] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.diag.txt new file mode 100644 index 0000000000..5c40a3ac80 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.diag.txt @@ -0,0 +1,3 @@ +(1,12): Error RZ2009: The parent tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong' are allowed. +(1,28): Error RZ2010: The
                        tag is not allowed by parent

                        tag helper. Only child tags with name(s) 'strong' are allowed. +(1,33): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.stree.txt new file mode 100644 index 0000000000..a26f2202b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..45)::45 - [

                        Title:
                        Something

                        ] + MarkupBlock - [0..45)::45 + MarkupTagHelperElement - [0..45)::45 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..26)::23 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [11..17)::6 - [Title:] - Gen - SpanEditHandler;Accepts:Any + Text;[Title:]; + MarkupTagHelperEndTag - [17..26)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [26..32)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [26..32)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [29..30)::1 + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [32..41)::9 - [Something] - Gen - SpanEditHandler;Accepts:Any + Text;[Something]; + MarkupTagHelperEndTag - [41..45)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.tspans.txt new file mode 100644 index 0000000000..c28f7d8242 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren7.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [45] ) - PTagHelper +TagHelper span at (3:0,3 [23] ) - StrongTagHelper +TagHelper span at (26:0,26 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.cspans.txt new file mode 100644 index 0000000000..7815c5f788 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (11:0,11 [6] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [23] ) +Markup span at (32:0,32 [9] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.diag.txt new file mode 100644 index 0000000000..97cf99a535 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.diag.txt @@ -0,0 +1,2 @@ +(1,12): Error RZ2009: The parent tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong, br' are allowed. +(1,33): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong, br' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.stree.txt new file mode 100644 index 0000000000..a26f2202b7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.stree.txt @@ -0,0 +1,35 @@ +RazorDocument - [0..45)::45 - [

                        Title:
                        Something

                        ] + MarkupBlock - [0..45)::45 + MarkupTagHelperElement - [0..45)::45 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..26)::23 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [11..17)::6 - [Title:] - Gen - SpanEditHandler;Accepts:Any + Text;[Title:]; + MarkupTagHelperEndTag - [17..26)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperElement - [26..32)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [26..32)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [29..30)::1 + MarkupTextLiteral - [29..30)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [32..41)::9 - [Something] - Gen - SpanEditHandler;Accepts:Any + Text;[Something]; + MarkupTagHelperEndTag - [41..45)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.tspans.txt new file mode 100644 index 0000000000..c28f7d8242 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren8.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [45] ) - PTagHelper +TagHelper span at (3:0,3 [23] ) - StrongTagHelper +TagHelper span at (26:0,26 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.cspans.txt new file mode 100644 index 0000000000..5b996a5f72 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [51] ) +Markup span at (13:0,13 [6] ) (Accepts:Any) - Parent: Tag block at (5:0,5 [23] ) +Markup span at (28:0,28 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [51] ) +Markup span at (36:0,36 [11] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [51] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.diag.txt new file mode 100644 index 0000000000..8209310bcf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.diag.txt @@ -0,0 +1,2 @@ +(1,14): Error RZ2009: The parent tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong, br' are allowed. +(1,39): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'strong, br' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.stree.txt new file mode 100644 index 0000000000..604ea8b5e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..51)::51 - [

                        Title:
                        Something

                        ] + MarkupBlock - [0..51)::51 + MarkupTagHelperElement - [0..51)::51 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTextLiteral - [3..5)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [5..28)::23 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [5..13)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [13..19)::6 - [Title:] - Gen - SpanEditHandler;Accepts:Any + Text;[Title:]; + MarkupTagHelperEndTag - [19..28)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTextLiteral - [28..30)::2 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTagHelperElement - [30..36)::6 - br[SelfClosing] - BRTagHelper + MarkupTagHelperStartTag - [30..36)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [33..34)::1 + MarkupTextLiteral - [33..34)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTextLiteral - [36..47)::11 - [ Something] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + Text;[Something]; + MarkupTagHelperEndTag - [47..51)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.tspans.txt new file mode 100644 index 0000000000..6b47d0c8f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsAllowedChildren9.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [51] ) - PTagHelper +TagHelper span at (5:0,5 [23] ) - StrongTagHelper +TagHelper span at (30:0,30 [6] ) - BRTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent1.cspans.txt new file mode 100644 index 0000000000..5b82e351ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent1.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [9] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent1.stree.txt new file mode 100644 index 0000000000..d0bebed030 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent1.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..17)::17 - [] + MarkupBlock - [0..17)::17 + MarkupElement - [0..17)::17 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [8..17)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.stree.txt new file mode 100644 index 0000000000..585ba3a17c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..24)::24 - [

                        ] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..24)::24 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..20)::17 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [11..20)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [20..24)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.tspans.txt new file mode 100644 index 0000000000..bc23211df6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [24] ) - PTagHelper +TagHelper span at (3:0,3 [17] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.cspans.txt new file mode 100644 index 0000000000..55c7fac46e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (0:0,0 [5] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [5] ) +Markup span at (22:0,22 [6] ) (Accepts:Any) - Parent: Tag block at (22:0,22 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.stree.txt new file mode 100644 index 0000000000..540608c5a6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..28)::28 - [
                        ] + MarkupBlock - [0..28)::28 + MarkupElement - [0..28)::28 + MarkupStartTag - [0..5)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTagHelperElement - [5..22)::17 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [5..13)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [13..22)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [22..28)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.tspans.txt new file mode 100644 index 0000000000..fc33dac63f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (5:0,5 [17] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent4.cspans.txt new file mode 100644 index 0000000000..730a1aeeb4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [8] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [8] ) +Markup span at (8:0,8 [8] ) (Accepts:Any) - Parent: Tag block at (8:0,8 [8] ) +Markup span at (16:0,16 [9] ) (Accepts:Any) - Parent: Tag block at (16:0,16 [9] ) +Markup span at (25:0,25 [9] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent4.stree.txt new file mode 100644 index 0000000000..c4c7affb20 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent4.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..34)::34 - [] + MarkupBlock - [0..34)::34 + MarkupElement - [0..34)::34 + MarkupStartTag - [0..8)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [8..25)::17 + MarkupStartTag - [8..16)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [16..25)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [25..34)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.cspans.txt new file mode 100644 index 0000000000..87adb1fdcf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (11:0,11 [8] ) (Accepts:Any) - Parent: Tag block at (11:0,11 [8] ) +Markup span at (19:0,19 [9] ) (Accepts:Any) - Parent: Tag block at (19:0,19 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.stree.txt new file mode 100644 index 0000000000..af8b35de67 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.stree.txt @@ -0,0 +1,32 @@ +RazorDocument - [0..41)::41 - [

                        ] + MarkupBlock - [0..41)::41 + MarkupTagHelperElement - [0..41)::41 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..37)::34 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [11..28)::17 + MarkupStartTag - [11..19)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [19..28)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [28..37)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [37..41)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.tspans.txt new file mode 100644 index 0000000000..f75dd01918 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedRequiredParent5.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [41] ) - PTagHelper +TagHelper span at (3:0,3 [34] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.cspans.txt new file mode 100644 index 0000000000..000e3e842a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (7:0,7 [8] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [8] ) +Markup span at (15:0,15 [9] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.stree.txt new file mode 100644 index 0000000000..884fbc2bab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupElement - [7..24)::17 + MarkupStartTag - [7..15)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [15..24)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.tspans.txt new file mode 100644 index 0000000000..507d5a1ed9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.stree.txt new file mode 100644 index 0000000000..e72021baa2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..31)::31 - [

                        ] + MarkupBlock - [0..31)::31 + MarkupTagHelperElement - [0..31)::31 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..10)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [3..10)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupTagHelperElement - [10..27)::17 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [10..18)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [18..27)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [27..31)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.tspans.txt new file mode 100644 index 0000000000..d7fdf8d909 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent2.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [31] ) - PTagHelper +TagHelper span at (3:0,3 [7] ) - InputTagHelper +TagHelper span at (10:0,10 [17] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.cspans.txt new file mode 100644 index 0000000000..fa4040f4e1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [4] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.stree.txt new file mode 100644 index 0000000000..ab19150491 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..28)::28 - [


                        ] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..7)::4 + MarkupStartTag - [3..7)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTagHelperElement - [7..24)::17 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [7..15)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [15..24)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.tspans.txt new file mode 100644 index 0000000000..73e31cf725 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [28] ) - PTagHelper +TagHelper span at (7:0,7 [17] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.cspans.txt new file mode 100644 index 0000000000..932e4c0847 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.cspans.txt @@ -0,0 +1 @@ +Markup span at (6:0,6 [4] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.stree.txt new file mode 100644 index 0000000000..305e173046 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..35)::35 - [


                        ] + MarkupBlock - [0..35)::35 + MarkupTagHelperElement - [0..35)::35 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..14)::11 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [3..6)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [6..10)::4 + MarkupStartTag - [6..10)::4 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [10..14)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [14..31)::17 - strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [14..22)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [22..31)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [31..35)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.tspans.txt new file mode 100644 index 0000000000..0220afb1bc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent4.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [35] ) - PTagHelper +TagHelper span at (3:0,3 [11] ) - PTagHelper +TagHelper span at (14:0,14 [17] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.cspans.txt new file mode 100644 index 0000000000..000e3e842a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.cspans.txt @@ -0,0 +1,2 @@ +Markup span at (7:0,7 [8] ) (Accepts:Any) - Parent: Tag block at (7:0,7 [8] ) +Markup span at (15:0,15 [9] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.stree.txt new file mode 100644 index 0000000000..884fbc2bab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..24)::24 - [] + MarkupBlock - [0..24)::24 + MarkupTagHelperElement - [0..7)::7 - input[StartTagOnly] - InputTagHelper + MarkupTagHelperStartTag - [0..7)::7 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + CloseAngle;[>]; + MarkupElement - [7..24)::17 + MarkupStartTag - [7..15)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupEndTag - [15..24)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.tspans.txt new file mode 100644 index 0000000000..507d5a1ed9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent5.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [7] ) - InputTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.stree.txt new file mode 100644 index 0000000000..120d5d3b73 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..26)::26 - [

                        ] + MarkupBlock - [0..26)::26 + MarkupTagHelperElement - [0..26)::26 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..12)::9 - input[SelfClosing] - InputTagHelper + MarkupTagHelperStartTag - [3..12)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[input]; + MarkupMiscAttributeContent - [9..10)::1 + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperElement - [12..22)::10 - strong[SelfClosing] - StrongTagHelper + MarkupTagHelperStartTag - [12..22)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupMiscAttributeContent - [19..20)::1 + MarkupTextLiteral - [19..20)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [22..26)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.tspans.txt new file mode 100644 index 0000000000..64d44d0707 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent6.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [26] ) - PTagHelper +TagHelper span at (3:0,3 [9] ) - InputTagHelper +TagHelper span at (12:0,12 [10] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.cspans.txt new file mode 100644 index 0000000000..85c1b5ca5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [6] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.stree.txt new file mode 100644 index 0000000000..ba2a0caa9a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..23)::23 - [


                        ] + MarkupBlock - [0..23)::23 + MarkupTagHelperElement - [0..23)::23 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..9)::6 + MarkupStartTag - [3..9)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [6..7)::1 + MarkupTextLiteral - [6..7)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperElement - [9..19)::10 - strong[SelfClosing] - StrongTagHelper + MarkupTagHelperStartTag - [9..19)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupMiscAttributeContent - [16..17)::1 + MarkupTextLiteral - [16..17)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [19..23)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.tspans.txt new file mode 100644 index 0000000000..4148089e22 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent7.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [23] ) - PTagHelper +TagHelper span at (9:0,9 [10] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.cspans.txt new file mode 100644 index 0000000000..42ce74cdcf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.cspans.txt @@ -0,0 +1 @@ +Markup span at (6:0,6 [6] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.stree.txt new file mode 100644 index 0000000000..eaf02a847a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.stree.txt @@ -0,0 +1,40 @@ +RazorDocument - [0..30)::30 - [


                        ] + MarkupBlock - [0..30)::30 + MarkupTagHelperElement - [0..30)::30 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..16)::13 - p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [3..6)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [6..12)::6 + MarkupStartTag - [6..12)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[br]; + MarkupMiscAttributeContent - [9..10)::1 + MarkupTextLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [12..16)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [16..26)::10 - strong[SelfClosing] - StrongTagHelper + MarkupTagHelperStartTag - [16..26)::10 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + MarkupMiscAttributeContent - [23..24)::1 + MarkupTextLiteral - [23..24)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + ForwardSlash;[/]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [26..30)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.tspans.txt new file mode 100644 index 0000000000..9e2ff7f56f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNestedVoidSelfClosingRequiredParent8.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [30] ) - PTagHelper +TagHelper span at (3:0,3 [13] ) - PTagHelper +TagHelper span at (16:0,16 [10] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.cspans.txt new file mode 100644 index 0000000000..b3958cf71b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.cspans.txt @@ -0,0 +1 @@ +Markup span at (3:0,3 [2] ) (Accepts:Any) - Parent: Tag block at (3:0,3 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.diag.txt new file mode 100644 index 0000000000..063da0eb5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.diag.txt @@ -0,0 +1 @@ +(1,4): Error RZ2009: The parent

                        tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'custom' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.stree.txt new file mode 100644 index 0000000000..c3ce3b808e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..9)::9 - [

                        ] + MarkupBlock - [0..9)::9 + MarkupTagHelperElement - [0..9)::9 - p[StartTagAndEndTag] - PTagHelper - CatchAllTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [3..5)::2 + MarkupEndTag - [3..5)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [5..9)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.tspans.txt new file mode 100644 index 0000000000..742c49e552 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAll.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [9] ) - PTagHelper - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.cspans.txt new file mode 100644 index 0000000000..9f25e95db6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.cspans.txt @@ -0,0 +1 @@ +Markup span at (6:0,6 [2] ) (Accepts:Any) - Parent: Tag block at (6:0,6 [2] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.diag.txt new file mode 100644 index 0000000000..ea784070ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.diag.txt @@ -0,0 +1 @@ +(1,7): Error RZ2009: The parent tag helper does not allow non-tag content. Only child tag helper(s) targeting tag name(s) 'custom' are allowed. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.stree.txt new file mode 100644 index 0000000000..96f4542570 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.stree.txt @@ -0,0 +1,18 @@ +RazorDocument - [0..15)::15 - [] + MarkupBlock - [0..15)::15 + MarkupTagHelperElement - [0..15)::15 - th:p[StartTagAndEndTag] - PTagHelper - CatchAllTagHelper + MarkupTagHelperStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:p]; + CloseAngle;[>]; + MarkupElement - [6..8)::2 + MarkupEndTag - [6..8)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [8..15)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.tspans.txt new file mode 100644 index 0000000000..9c88cfee63 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsNullTagNameWithAllowedChildrenForCatchAllWithPrefix.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [15] ) - PTagHelper - CatchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.diag.txt new file mode 100644 index 0000000000..66ca144635 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,5): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.stree.txt new file mode 100644 index 0000000000..7ceb2b793e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.stree.txt @@ -0,0 +1,12 @@ +RazorDocument - [0..11)::11 - [

                        ] + MarkupBlock - [0..11)::11 + MarkupTagHelperElement - [0..11)::11 - p[StartTagAndEndTag] - PTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..11)::8 - strong[StartTagAndEndTag] - StrongTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.tspans.txt new file mode 100644 index 0000000000..90c108ed6f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags1.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [11] ) - PTagHelper - CatchALlTagHelper +TagHelper span at (3:0,3 [8] ) - StrongTagHelper - CatchALlTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.diag.txt new file mode 100644 index 0000000000..d177eb6df7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.stree.txt new file mode 100644 index 0000000000..0fd6778b92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.stree.txt @@ -0,0 +1,17 @@ +RazorDocument - [0..20)::20 - [

                        ] + MarkupBlock - [0..20)::20 + MarkupTagHelperElement - [0..20)::20 - p[StartTagAndEndTag] - PTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..20)::17 - strong[StartTagAndEndTag] - StrongTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [11..20)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.tspans.txt new file mode 100644 index 0000000000..c845290524 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags2.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [20] ) - PTagHelper - CatchALlTagHelper +TagHelper span at (3:0,3 [17] ) - StrongTagHelper - CatchALlTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.diag.txt new file mode 100644 index 0000000000..c430b77aba --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.diag.txt @@ -0,0 +1,2 @@ +(1,5): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. +(1,17): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.stree.txt new file mode 100644 index 0000000000..f398f7e621 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..23)::23 - [

                        ] + MarkupBlock - [0..23)::23 + MarkupTagHelperElement - [0..15)::15 - p[StartTagAndEndTag] - PTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [0..3)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [3..11)::8 - strong[StartTagAndEndTag] - StrongTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [3..11)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [11..15)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupTagHelperElement - [15..23)::8 - strong[StartTagAndEndTag] - StrongTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [15..23)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.tspans.txt new file mode 100644 index 0000000000..15f95fc055 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags3.tspans.txt @@ -0,0 +1,3 @@ +TagHelper span at (0:0,0 [15] ) - PTagHelper - CatchALlTagHelper +TagHelper span at (3:0,3 [8] ) - StrongTagHelper - CatchALlTagHelper +TagHelper span at (15:0,15 [8] ) - StrongTagHelper - CatchALlTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.cspans.txt new file mode 100644 index 0000000000..0ddda3f56c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [1] ) +Markup span at (13:0,13 [2] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [2] ) +Markup span at (23:0,23 [9] ) (Accepts:Any) - Parent: Tag block at (23:0,23 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.diag.txt new file mode 100644 index 0000000000..23376ed537 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.diag.txt @@ -0,0 +1,2 @@ +(1,18): Error RZ1035: Missing close angle for tag helper 'strong'. +(1,26): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.stree.txt new file mode 100644 index 0000000000..7f1b3852f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..36)::36 - [<

                        <

                        ] + MarkupBlock - [0..36)::36 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [1..36)::35 - p[StartTagAndEndTag] - PTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [1..4)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [4..5)::1 + MarkupStartTag - [4..5)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [5..23)::18 - strong[StartTagAndEndTag] - StrongTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [5..13)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [13..15)::2 + MarkupEndTag - [13..15)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [15..23)::8 - []; + MarkupElement - [23..32)::9 + MarkupEndTag - [23..32)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [32..36)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.tspans.txt new file mode 100644 index 0000000000..a2439ab80f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags4.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (1:0,1 [35] ) - PTagHelper - CatchALlTagHelper +TagHelper span at (5:0,5 [18] ) - StrongTagHelper - CatchALlTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.cspans.txt new file mode 100644 index 0000000000..6b5900843d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [1] ) +Markup span at (13:0,13 [2] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [2] ) +Markup span at (24:0,24 [9] ) (Accepts:Any) - Parent: Tag block at (24:0,24 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.diag.txt new file mode 100644 index 0000000000..2ec0cc5b46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.diag.txt @@ -0,0 +1 @@ +(1,27): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.stree.txt new file mode 100644 index 0000000000..de50b379ce --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..37)::37 - [<

                        <

                        ] + MarkupBlock - [0..37)::37 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [1..37)::36 - p[StartTagAndEndTag] - PTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [1..4)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [4..5)::1 + MarkupStartTag - [4..5)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [5..24)::19 - strong[StartTagAndEndTag] - StrongTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [5..13)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [13..15)::2 + MarkupEndTag - [13..15)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [15..24)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupElement - [24..33)::9 + MarkupEndTag - [24..33)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [33..37)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.tspans.txt new file mode 100644 index 0000000000..4ba2086e2d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags5.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (1:0,1 [36] ) - PTagHelper - CatchALlTagHelper +TagHelper span at (5:0,5 [19] ) - StrongTagHelper - CatchALlTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.cspans.txt new file mode 100644 index 0000000000..f84fc1d9eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.cspans.txt @@ -0,0 +1,5 @@ +Markup span at (0:0,0 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [1] ) +Markup span at (4:0,4 [1] ) (Accepts:Any) - Parent: Tag block at (4:0,4 [1] ) +Markup span at (13:0,13 [2] ) (Accepts:Any) - Parent: Tag block at (13:0,13 [2] ) +Markup span at (15:0,15 [1] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [1] ) +Markup span at (25:0,25 [9] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.diag.txt new file mode 100644 index 0000000000..593733688c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.diag.txt @@ -0,0 +1 @@ +(1,28): Error RZ1034: Found a malformed 'custom' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.stree.txt new file mode 100644 index 0000000000..22b0433adb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.stree.txt @@ -0,0 +1,49 @@ +RazorDocument - [0..38)::38 - [<

                        <

                        ] + MarkupBlock - [0..38)::38 + MarkupElement - [0..1)::1 + MarkupStartTag - [0..1)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [1..38)::37 - p[StartTagAndEndTag] - PTagHelper - CatchALlTagHelper + MarkupTagHelperStartTag - [1..4)::3 - [

                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + CloseAngle;[>]; + MarkupElement - [4..5)::1 + MarkupStartTag - [4..5)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperElement - [5..25)::20 - custom[StartTagAndEndTag] - CatchALlTagHelper + MarkupTagHelperStartTag - [5..13)::8 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[custom]; + CloseAngle;[>]; + MarkupElement - [13..15)::2 + MarkupEndTag - [13..15)::2 - [ - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[]; + CloseAngle;[]; + MarkupElement - [15..16)::1 + MarkupStartTag - [15..16)::1 - [<] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[]; + CloseAngle;[]; + MarkupTagHelperEndTag - [16..25)::9 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[custom]; + CloseAngle;[>]; + MarkupElement - [25..34)::9 + MarkupEndTag - [25..34)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[custom]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [34..38)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.tspans.txt new file mode 100644 index 0000000000..69e6d665e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsPartialRequiredParentTags6.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (1:0,1 [37] ) - PTagHelper - CatchALlTagHelper +TagHelper span at (5:0,5 [20] ) - CatchALlTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.stree.txt new file mode 100644 index 0000000000..d4340fbaf9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..36)::36 - [] + MarkupBlock - [0..36)::36 + MarkupTagHelperElement - [0..36)::36 - th:p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:p]; + CloseAngle;[>]; + MarkupTagHelperElement - [6..29)::23 - th:strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [6..17)::11 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [17..29)::12 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [29..36)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.tspans.txt new file mode 100644 index 0000000000..3d7cf53630 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildren.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [36] ) - PTagHelper +TagHelper span at (6:0,6 [23] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.cspans.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.stree.txt new file mode 100644 index 0000000000..d4340fbaf9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.stree.txt @@ -0,0 +1,22 @@ +RazorDocument - [0..36)::36 - [] + MarkupBlock - [0..36)::36 + MarkupTagHelperElement - [0..36)::36 - th:p[StartTagAndEndTag] - PTagHelper + MarkupTagHelperStartTag - [0..6)::6 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:p]; + CloseAngle;[>]; + MarkupTagHelperElement - [6..29)::23 - th:strong[StartTagAndEndTag] - StrongTagHelper + MarkupTagHelperStartTag - [6..17)::11 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[th:strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [17..29)::12 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:strong]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [29..36)::7 - [] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[th:p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.tspans.txt new file mode 100644 index 0000000000..3d7cf53630 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelperPrefixAndAllowedChildrenAndRequireParent.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (0:0,0 [36] ) - PTagHelper +TagHelper span at (6:0,6 [23] ) - StrongTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.cspans.txt new file mode 100644 index 0000000000..b5c72f9c7c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (7:0,7 [7] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (34:0,34 [9] ) (Accepts:Any) - Parent: Tag block at (34:0,34 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.stree.txt new file mode 100644 index 0000000000..f96a8ae57b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.stree.txt @@ -0,0 +1,37 @@ +RazorDocument - [0..43)::43 - [] + MarkupBlock - [0..43)::43 + MarkupElement - [0..43)::43 + MarkupStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.tspans.txt new file mode 100644 index 0000000000..d4c27b6e7a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (25:0,25 [9] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.cspans.txt new file mode 100644 index 0000000000..8bd8e1509f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [58] ) +Markup span at (7:0,7 [5] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [15] ) +Markup span at (12:0,12 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [15] ) +Markup span at (21:0,21 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [15] ) +Markup span at (22:0,22 [7] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [17] ) +Markup span at (29:0,29 [9] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [17] ) +Markup span at (38:0,38 [1] ) (Accepts:Any) - Parent: Markup block at (22:0,22 [17] ) +Markup span at (39:0,39 [8] ) (Accepts:Any) - Parent: Markup block at (39:0,39 [18] ) +Markup span at (47:0,47 [9] ) (Accepts:Any) - Parent: Markup block at (39:0,39 [18] ) +Markup span at (56:0,56 [1] ) (Accepts:Any) - Parent: Markup block at (39:0,39 [18] ) +Markup span at (57:0,57 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [58] ) +Markup span at (67:0,67 [9] ) (Accepts:Any) - Parent: Tag block at (67:0,67 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.stree.txt new file mode 100644 index 0000000000..96cec55978 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.stree.txt @@ -0,0 +1,65 @@ +RazorDocument - [0..76)::76 - [] + MarkupBlock - [0..76)::76 + MarkupElement - [0..76)::76 + MarkupStartTag - [0..58)::58 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.tspans.txt new file mode 100644 index 0000000000..3621fc53bf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (58:0,58 [9] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.cspans.txt new file mode 100644 index 0000000000..2d9ed79313 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.cspans.txt @@ -0,0 +1,12 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (7:0,7 [7] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (28:0,28 [7] ) (Accepts:Any) - Parent: Tag block at (28:0,28 [25] ) +Markup span at (35:0,35 [7] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [17] ) +Markup span at (42:0,42 [9] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [17] ) +Markup span at (51:0,51 [1] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [17] ) +Markup span at (52:0,52 [1] ) (Accepts:Any) - Parent: Tag block at (28:0,28 [25] ) +Markup span at (62:0,62 [9] ) (Accepts:Any) - Parent: Tag block at (62:0,62 [9] ) +Markup span at (75:0,75 [9] ) (Accepts:Any) - Parent: Tag block at (75:0,75 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.stree.txt new file mode 100644 index 0000000000..486a563920 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.stree.txt @@ -0,0 +1,73 @@ +RazorDocument - [0..84)::84 - [

                        ] + MarkupBlock - [0..84)::84 + MarkupElement - [0..84)::84 + MarkupStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [71..75)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [75..84)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.tspans.txt new file mode 100644 index 0000000000..5f9f687bee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags3.tspans.txt @@ -0,0 +1,2 @@ +TagHelper span at (25:0,25 [50] ) - ptaghelper +TagHelper span at (53:0,53 [9] ) - inputtaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.cspans.txt new file mode 100644 index 0000000000..b8ce9ee314 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.cspans.txt @@ -0,0 +1,14 @@ +Markup span at (0:0,0 [7] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (7:0,7 [7] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (14:0,14 [9] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (23:0,23 [1] ) (Accepts:Any) - Parent: Markup block at (7:0,7 [17] ) +Markup span at (24:0,24 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [25] ) +Markup span at (28:0,28 [7] ) (Accepts:Any) - Parent: Tag block at (28:0,28 [26] ) +Markup span at (35:0,35 [7] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [18] ) +Markup span at (42:0,42 [5] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [18] ) +Markup span at (47:0,47 [5] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [18] ) +Markup span at (52:0,52 [1] ) (Accepts:Any) - Parent: Markup block at (35:0,35 [18] ) +Markup span at (53:0,53 [1] ) (Accepts:Any) - Parent: Tag block at (28:0,28 [26] ) +Markup span at (54:0,54 [9] ) (Accepts:Any) - Parent: Tag block at (25:0,25 [51] ) +Markup span at (63:0,63 [9] ) (Accepts:Any) - Parent: Tag block at (63:0,63 [9] ) +Markup span at (76:0,76 [9] ) (Accepts:Any) - Parent: Tag block at (76:0,76 [9] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.stree.txt new file mode 100644 index 0000000000..29d9adaaa4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.stree.txt @@ -0,0 +1,74 @@ +RazorDocument - [0..85)::85 - [

                        ] + MarkupBlock - [0..85)::85 + MarkupElement - [0..85)::85 + MarkupStartTag - [0..25)::25 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [72..76)::4 - [

                        ] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; + MarkupEndTag - [76..85)::9 - [] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[script]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.tspans.txt new file mode 100644 index 0000000000..31ab64ca0b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/UnderstandsTagHelpersInHtmlTypedScriptTags4.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (25:0,25 [51] ) - ptaghelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/WhiteSpaceRewriterTest/Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/WhiteSpaceRewriterTest/Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block.cspans.txt new file mode 100644 index 0000000000..64df8a7ddd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/WhiteSpaceRewriterTest/Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block.cspans.txt @@ -0,0 +1,18 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Markup span at (2:1,0 [5] ) (Accepts:Any) - Parent: Tag block at (2:1,0 [5] ) +Markup span at (7:1,5 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Markup span at (9:2,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Transition span at (13:2,4 [1] ) (Accepts:None) - Parent: Expression block at (13:2,4 [7] ) +Code span at (14:2,5 [6] ) (Accepts:NonWhitespace) - Parent: Expression block at (13:2,4 [7] ) +Markup span at (20:2,11 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Markup span at (22:3,0 [6] ) (Accepts:Any) - Parent: Tag block at (22:3,0 [6] ) +Markup span at (28:3,6 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Markup span at (30:4,0 [5] ) (Accepts:Any) - Parent: Tag block at (30:4,0 [5] ) +Markup span at (35:4,5 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Markup span at (37:5,0 [4] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Transition span at (41:5,4 [1] ) (Accepts:None) - Parent: Expression block at (41:5,4 [9] ) +MetaCode span at (42:5,5 [1] ) (Accepts:None) - Parent: Expression block at (41:5,4 [9] ) +Code span at (43:5,6 [6] ) (Accepts:Any) - Parent: Expression block at (41:5,4 [9] ) +MetaCode span at (49:5,12 [1] ) (Accepts:None) - Parent: Expression block at (41:5,4 [9] ) +Markup span at (50:5,13 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [58] ) +Markup span at (52:6,0 [6] ) (Accepts:Any) - Parent: Tag block at (52:6,0 [6] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/WhiteSpaceRewriterTest/Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/WhiteSpaceRewriterTest/Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block.stree.txt new file mode 100644 index 0000000000..6fc0095f30 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/WhiteSpaceRewriterTest/Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block.stree.txt @@ -0,0 +1,58 @@ +RazorDocument - [0..58)::58 - [LF
                        LF @resultLF
                        LF
                        LF @(result)LF
                        ] + MarkupBlock - [0..58)::58 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [2..28)::26 + MarkupStartTag - [2..7)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [7..9)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [9..13)::4 - [ ] + Whitespace;[ ]; + CSharpCodeBlock - [13..20)::7 + CSharpImplicitExpression - [13..20)::7 + CSharpTransition - [13..14)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpImplicitExpressionBody - [14..20)::6 + CSharpCodeBlock - [14..20)::6 + CSharpExpressionLiteral - [14..20)::6 - [result] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + Identifier;[result]; + MarkupTextLiteral - [20..22)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [22..28)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [28..30)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupElement - [30..58)::28 + MarkupStartTag - [30..35)::5 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[div]; + CloseAngle;[>]; + MarkupTextLiteral - [35..37)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupTextLiteral - [37..41)::4 - [ ] + Whitespace;[ ]; + CSharpCodeBlock - [41..50)::9 + CSharpExplicitExpression - [41..50)::9 + CSharpTransition - [41..42)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + CSharpExplicitExpressionBody - [42..50)::8 + RazorMetaCode - [42..43)::1 - Gen - SpanEditHandler;Accepts:None + LeftParenthesis;[(]; + CSharpCodeBlock - [43..49)::6 + CSharpExpressionLiteral - [43..49)::6 - [result] - Gen - SpanEditHandler;Accepts:Any + Identifier;[result]; + RazorMetaCode - [49..50)::1 - Gen - SpanEditHandler;Accepts:None + RightParenthesis;[)]; + MarkupTextLiteral - [50..52)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + MarkupEndTag - [52..58)::6 - [
                        ] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[div]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/Source/BasicMarkup.cshtml b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/Source/BasicMarkup.cshtml new file mode 100644 index 0000000000..384a7a6deb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/Source/BasicMarkup.cshtml @@ -0,0 +1,8 @@ + + + This is the title. + + + Link to Contoso. + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/nested-1000.html b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/nested-1000.html new file mode 100644 index 0000000000..3c35bdbcbe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/nested-1000.html @@ -0,0 +1,2002 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestRazorProject.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestRazorProject.cs new file mode 100644 index 0000000000..1c4faa7b5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestRazorProject.cs @@ -0,0 +1,47 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class TestRazorProject : RazorProject + { + private readonly Dictionary _lookup; + + public TestRazorProject() + : this(new RazorProjectItem[0]) + { + } + + public TestRazorProject(IList items) + { + _lookup = items.ToDictionary(item => item.FilePath); + } + + public override IEnumerable EnumerateItems(string basePath) + { + throw new NotImplementedException(); + } + + [Obsolete("Use GetItem(string path, string fileKind) instead.")] + public override RazorProjectItem GetItem(string path) + { + return GetItem(path, fileKind: null); + } + + public override RazorProjectItem GetItem(string path, string fileKind) + { + if (!_lookup.TryGetValue(path, out var value)) + { + value = new NotFoundProjectItem("", path, fileKind); + } + + return value; + } + + public new string NormalizeAndEnsureValidPath(string path) => base.NormalizeAndEnsureValidPath(path); + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/VirtualRazorProjectFileSystemTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/VirtualRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..227ed02e07 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/VirtualRazorProjectFileSystemTest.cs @@ -0,0 +1,400 @@ +// 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 Xunit; +using DirectoryNode = Microsoft.AspNetCore.Razor.Language.VirtualRazorProjectFileSystem.DirectoryNode; +using FileNode = Microsoft.AspNetCore.Razor.Language.VirtualRazorProjectFileSystem.FileNode; + +namespace Microsoft.AspNetCore.Razor.Language +{ + public class VirtualRazorProjectFileSystemTest + { + [Fact] + public void GetItem_ReturnsNotFound_IfFileDoesNotExistInRoot() + { + // Arrange + var path = "/root-file.cshtml"; + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + projectSystem.Add(new TestRazorProjectItem("/different-file.cshtml")); + var result = projectSystem.GetItem(path, fileKind: null); + + // Assert + Assert.False(result.Exists); + } + + [Fact] + public void GetItem_ReturnsItemAddedToRoot() + { + // Arrange + var path = "/root-file.cshtml"; + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem(path); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem(path, fileKind: null); + + // Assert + Assert.Same(projectItem, actual); + } + + [Theory] + [InlineData("/subDirectory/file.cshtml")] + [InlineData("/subDirectory/dir2/file.cshtml")] + [InlineData("/subDirectory/dir2/dir3/file.cshtml")] + public void GetItem_ReturnsItemAddedToNestedDirectory(string path) + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem(path); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem(path, fileKind: null); + + // Assert + Assert.Same(projectItem, actual); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml", fileKind: null); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenNestedDirectoryDoesNotExist_AndPeerDirectoryExists() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml"); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem("/subDirectory/dir3/file.cshtml", fileKind: null); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void GetItem_ReturnsNotFound_WhenFileDoesNotExistInNestedDirectory() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var projectItem = new TestRazorProjectItem("/subDirectory/dir2/file.cshtml"); + + // Act + projectSystem.Add(projectItem); + var actual = projectSystem.GetItem("/subDirectory/dir2/file2.cshtml", fileKind: null); + + // Assert + Assert.False(actual.Exists); + } + + [Fact] + public void EnumerateItems_AtRoot_ReturnsAllFiles() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var file1 = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"); + var file2 = new TestRazorProjectItem("/file2.cshtml"); + var file3 = new TestRazorProjectItem("/dir3/file3.cshtml"); + var file4 = new TestRazorProjectItem("/subDirectory/file4.cshtml"); + projectSystem.Add(file1); + projectSystem.Add(file2); + projectSystem.Add(file3); + projectSystem.Add(file4); + + // Act + var result = projectSystem.EnumerateItems("/"); + + // Assert + Assert.Equal(new[] { file2, file4, file1, file3 }, result); + } + + [Fact] + public void EnumerateItems_AtSubDirectory_ReturnsAllFilesUnderDirectoryHierarchy() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var file1 = new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml"); + var file2 = new TestRazorProjectItem("/file2.cshtml"); + var file3 = new TestRazorProjectItem("/dir3/file3.cshtml"); + var file4 = new TestRazorProjectItem("/subDirectory/file4.cshtml"); + projectSystem.Add(file1); + projectSystem.Add(file2); + projectSystem.Add(file3); + projectSystem.Add(file4); + + // Act + var result = projectSystem.EnumerateItems("/subDirectory"); + + // Assert + Assert.Equal(new[] { file4, file1 }, result); + } + + [Fact] + public void EnumerateItems_WithNoFilesInRoot_ReturnsEmptySequence() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + + // Act + var result = projectSystem.EnumerateItems("/"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void EnumerateItems_ForNonExistentDirectory_ReturnsEmptySequence() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + projectSystem.Add(new TestRazorProjectItem("/subDirectory/dir2/file1.cshtml")); + projectSystem.Add(new TestRazorProjectItem("/file2.cshtml")); + + // Act + var result = projectSystem.EnumerateItems("/dir3"); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void GetHierarchicalItems_Works() + { + // Arrange + var projectSystem = new VirtualRazorProjectFileSystem(); + var viewImport1 = new TestRazorProjectItem("/_ViewImports.cshtml"); + var viewImport2 = new TestRazorProjectItem("/Views/Home/_ViewImports.cshtml"); + projectSystem.Add(viewImport1); + projectSystem.Add(viewImport2); + + // Act + var items = projectSystem.FindHierarchicalItems("/", "/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => Assert.Same(viewImport2, item), + item => Assert.False(item.Exists), + item => Assert.Same(viewImport1, item)); + } + + [Fact] + public void DirectoryNode_GetDirectory_ReturnsRoot() + { + // Arrange + var root = new DirectoryNode("/"); + + // Act + var result = root.GetDirectory("/"); + + // Assert + Assert.Same(root, result); + } + + [Fact] + public void DirectoryNode_GetDirectory_ReturnsNull_IfDirectoryDoesNotExist() + { + // Arrange + var root = new DirectoryNode("/"); + + // Act + var result = root.GetDirectory("/does-not/exist"); + + // Assert + Assert.Null(result); + } + + [Fact] + public void DirectoryNode_AddFile_CanAddToRoot() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/File.txt"); + + // Act + root.AddFile(new FileNode("/File.txt", projectItem)); + + // Assert + Assert.Empty(root.Directories); + Assert.Collection( + root.Files, + file => Assert.Same(projectItem, file.ProjectItem)); + } + + [Fact] + public void DirectoryNode_AddFile_CanAddToNestedDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/Pages/Shared/_Layout.cshtml"); + + // Act + root.AddFile(new FileNode("/Pages/Shared/_Layout.cshtml", projectItem)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Shared/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_AddMultipleFiles_ToSameDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Pages/Shared/_Layout.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Pages/Shared/_Partial.cshtml"); + + // Act + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Shared/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem1, file.ProjectItem), + file => Assert.Same(projectItem2, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_AddsFiles_ToSiblingDirectories() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Pages/Products/Index.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Pages/Accounts/About.cshtml"); + + // Act + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Assert + Assert.Collection( + root.Directories, + directory => + { + Assert.Equal("/Pages/", directory.Path); + Assert.Empty(directory.Files); + + Assert.Collection( + directory.Directories, + subDirectory => + { + Assert.Equal("/Pages/Products/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem1, file.ProjectItem)); + }, + subDirectory => + { + Assert.Equal("/Pages/Accounts/", subDirectory.Path); + Assert.Collection( + subDirectory.Files, + file => Assert.Same(projectItem2, file.ProjectItem)); + }); + }); + } + + [Fact] + public void DirectoryNode_GetItem_ReturnsItemAtRoot() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem = new TestRazorProjectItem("/_ViewStart.cshtml"); + root.AddFile(new FileNode(projectItem.FilePath, projectItem)); + + // Act + var result = root.GetItem(projectItem.FilePath); + + // Assert + Assert.Same(result, projectItem); + } + + [Fact] + public void DirectoryNode_GetItem_WhenFilePathSharesSameNameAsSiblingDirectory() + { + // Arrange + var root = new DirectoryNode("/"); + var projectItem1 = new TestRazorProjectItem("/Home.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Home/About.cshtml"); + root.AddFile(new FileNode(projectItem1.FilePath, projectItem1)); + root.AddFile(new FileNode(projectItem2.FilePath, projectItem2)); + + // Act + var result = root.GetItem(projectItem1.FilePath); + + // Assert + Assert.Same(result, projectItem1); + } + + [Fact] + public void DirectoryNode_GetItem_WhenFileNameIsSameAsDirectoryName() + { + // Arrange + var projectItem1 = new TestRazorProjectItem("/Home/Home.cshtml"); + var projectItem2 = new TestRazorProjectItem("/Home/About.cshtml"); + var root = new DirectoryNode("/") + { + Directories = + { + new DirectoryNode("/Home/") + { + Files = + { + new FileNode(projectItem1.FilePath, projectItem1), + new FileNode(projectItem2.FilePath, projectItem2), + } + } + }, + }; + + // Act + var result = root.GetItem(projectItem1.FilePath); + + // Assert + Assert.Same(result, projectItem1); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/xunit.runner.json b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/xunit.runner.json new file mode 100644 index 0000000000..fcf172c8fc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "methodDisplay": "method", + "shadowCopy": false +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Application.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Application.cs new file mode 100644 index 0000000000..9c63203f66 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Application.cs @@ -0,0 +1,114 @@ +// 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.Reflection; +using System.Threading; +using Microsoft.CodeAnalysis; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class Application : CommandLineApplication + { + public Application( + CancellationToken cancellationToken, + ExtensionAssemblyLoader loader, + ExtensionDependencyChecker checker, + Func assemblyReferenceProvider, + TextWriter output = null, + TextWriter error = null) + { + CancellationToken = cancellationToken; + Checker = checker; + Loader = loader; + AssemblyReferenceProvider = assemblyReferenceProvider; + Out = output ?? Out; + Error = error ?? Error; + + Name = "rzc"; + FullName = "Microsoft ASP.NET Core Razor CLI tool"; + Description = "CLI interface to perform Razor operations."; + ShortVersionGetter = GetInformationalVersion; + + HelpOption("-?|-h|--help"); + + Commands.Add(new ServerCommand(this)); + Commands.Add(new ShutdownCommand(this)); + Commands.Add(new DiscoverCommand(this)); + Commands.Add(new GenerateCommand(this)); + } + + public CancellationToken CancellationToken { get; } + + public ExtensionAssemblyLoader Loader { get; } + + public ExtensionDependencyChecker Checker { get; } + + public Func AssemblyReferenceProvider { get; } + + public new int Execute(params string[] args) + { + try + { + return base.Execute(ExpandResponseFiles(args)); + } + catch (AggregateException ex) when (ex.InnerException != null) + { + foreach (var innerException in ex.Flatten().InnerExceptions) + { + Error.WriteLine(innerException.Message); + Error.WriteLine(innerException.StackTrace); + } + return 1; + } + catch (CommandParsingException ex) + { + // Don't show a call stack when we have unneeded arguments, just print the error message. + // The code that throws this exception will print help, so no need to do it here. + Error.WriteLine(ex.Message); + return 1; + } + catch (OperationCanceledException) + { + // This is a cancellation, not a failure. + Error.WriteLine("Cancelled"); + return 1; + } + catch (Exception ex) + { + Error.WriteLine(ex.Message); + Error.WriteLine(ex.StackTrace); + return 1; + } + } + + private string GetInformationalVersion() + { + var assembly = typeof(Application).GetTypeInfo().Assembly; + var attribute = assembly.GetCustomAttribute(); + return attribute.InformationalVersion; + } + + private static string[] ExpandResponseFiles(string[] args) + { + var expandedArgs = new List(); + foreach (var arg in args) + { + if (!arg.StartsWith("@", StringComparison.Ordinal)) + { + expandedArgs.Add(arg); + } + else + { + var fileName = arg.Substring(1); + expandedArgs.AddRange(File.ReadLines(fileName)); + } + } + + return expandedArgs.ToArray(); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CachingMetadataReference.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CachingMetadataReference.cs new file mode 100644 index 0000000000..0aeb381b21 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CachingMetadataReference.cs @@ -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.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal sealed class CachingMetadataReference : PortableExecutableReference + { + private static readonly MetadataCache _metadataCache = new MetadataCache(); + + public CachingMetadataReference(string fullPath, MetadataReferenceProperties properties) + : base(properties, fullPath) + { + } + + protected override DocumentationProvider CreateDocumentationProvider() + { + return DocumentationProvider.Default; + } + + protected override Metadata GetMetadataImpl() + { + return _metadataCache.GetMetadata(FilePath); + } + + protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties) + { + return new CachingMetadataReference(FilePath, properties); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Client.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Client.cs new file mode 100644 index 0000000000..cf94173337 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Client.cs @@ -0,0 +1,200 @@ +// 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.IO.Pipes; +#if NETFRAMEWORK +using System.Security.AccessControl; +using System.Security.Principal; +#endif +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class Client : IDisposable + { + private static int counter; + + // From https://github.com/dotnet/corefx/blob/29cd6a0b0ac2993cee23ebaf36ca3d4bce6dd75f/src/System.IO.Pipes/ref/System.IO.Pipes.cs#L93. + // Using the enum value directly as this option is not available in netstandard. + private const PipeOptions PipeOptionCurrentUserOnly = (PipeOptions)536870912; + + private static readonly PipeOptions _pipeOptions = GetPipeOptions(); + + public abstract Stream Stream { get; } + + public abstract string Identifier { get; } + + public void Dispose() + { + Dispose(disposing: true); + } + + public abstract Task WaitForDisconnectAsync(CancellationToken cancellationToken); + + protected virtual void Dispose(bool disposing) + { + } + + // Based on: https://github.com/dotnet/roslyn/blob/14aed138a01c448143b9acf0fe77a662e3dfe2f4/src/Compilers/Shared/BuildServerConnection.cs#L290 + public static async Task ConnectAsync(string pipeName, TimeSpan? timeout, CancellationToken cancellationToken) + { + var timeoutMilliseconds = timeout == null ? Timeout.Infinite : (int)timeout.Value.TotalMilliseconds; + + try + { + // Machine-local named pipes are named "\\.\pipe\". + // We use the SHA1 of the directory the compiler exes live in as the pipe name. + // The NamedPipeClientStream class handles the "\\.\pipe\" part for us. + ServerLogger.Log("Attempt to open named pipe '{0}'", pipeName); + + var stream = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, _pipeOptions); + cancellationToken.ThrowIfCancellationRequested(); + + ServerLogger.Log("Attempt to connect named pipe '{0}'", pipeName); + try + { + await stream.ConnectAsync(timeoutMilliseconds, cancellationToken); + } + catch (Exception e) when (e is IOException || e is TimeoutException) + { + // Note: IOException can also indicate timeout. + // From docs: + // - TimeoutException: Could not connect to the server within the specified timeout period. + // - IOException: The server is connected to another client and the time-out period has expired. + ServerLogger.Log($"Connecting to server timed out after {timeoutMilliseconds} ms"); + return null; + } + + ServerLogger.Log("Named pipe '{0}' connected", pipeName); + cancellationToken.ThrowIfCancellationRequested(); + +#if NETFRAMEWORK + // Verify that we own the pipe. + if (!CheckPipeConnectionOwnership(stream)) + { + ServerLogger.Log("Owner of named pipe is incorrect"); + return null; + } +#endif + + return new NamedPipeClient(stream, GetNextIdentifier()); + } + catch (Exception e) when (!(e is TaskCanceledException || e is OperationCanceledException)) + { + ServerLogger.LogException(e, "Exception while connecting to process"); + return null; + } + } + +#if NETFRAMEWORK + /// + /// Check to ensure that the named pipe server we connected to is owned by the same + /// user. + /// + private static bool CheckPipeConnectionOwnership(NamedPipeClientStream pipeStream) + { + try + { + if (PlatformInformation.IsWindows) + { + using (var currentIdentity = WindowsIdentity.GetCurrent()) + { + var currentOwner = currentIdentity.Owner; + var remotePipeSecurity = GetPipeSecurity(pipeStream); + var remoteOwner = remotePipeSecurity.GetOwner(typeof(SecurityIdentifier)); + + return currentOwner.Equals(remoteOwner); + } + } + + // We don't need to verify on non-windows as that will be taken care of by the + // PipeOptions.CurrentUserOnly flag. + return false; + } + catch (Exception ex) + { + ServerLogger.LogException(ex, "Checking pipe connection"); + return false; + } + } + + private static ObjectSecurity GetPipeSecurity(PipeStream pipeStream) + { + return pipeStream.GetAccessControl(); + } +#endif + + private static PipeOptions GetPipeOptions() + { + var options = PipeOptions.Asynchronous; + + if (Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly)) + { + return options | PipeOptionCurrentUserOnly; + } + + return options; + } + + private static string GetNextIdentifier() + { + var id = Interlocked.Increment(ref counter); + return "clientconnection-" + id; + } + + private class NamedPipeClient : Client + { + public NamedPipeClient(NamedPipeClientStream stream, string identifier) + { + Stream = stream; + Identifier = identifier; + } + + public override Stream Stream { get; } + + public override string Identifier { get; } + + public async override Task WaitForDisconnectAsync(CancellationToken cancellationToken) + { + if (!(Stream is PipeStream pipeStream)) + { + return; + } + + // We have to poll for disconnection by reading, PipeStream.IsConnected isn't reliable unless you + // actually do a read - which will cause it to update its state. + while (!cancellationToken.IsCancellationRequested && pipeStream.IsConnected) + { + await Task.Delay(TimeSpan.FromMilliseconds(100), cancellationToken); + + try + { + ServerLogger.Log($"Before poking pipe {Identifier}."); + await Stream.ReadAsync(Array.Empty(), 0, 0, cancellationToken); + ServerLogger.Log($"After poking pipe {Identifier}."); + } + catch (OperationCanceledException) + { + } + catch (Exception e) + { + // It is okay for this call to fail. Errors will be reflected in the + // IsConnected property which will be read on the next iteration. + ServerLogger.LogException(e, $"Error poking pipe {Identifier}."); + } + } + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + Stream.Dispose(); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CommandBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CommandBase.cs new file mode 100644 index 0000000000..91904ae9f5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CommandBase.cs @@ -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 System.IO; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class CommandBase : CommandLineApplication + { + public const int ExitCodeSuccess = 0; + public const int ExitCodeFailure = 1; + public const int ExitCodeFailureRazorError = 2; + + protected CommandBase(Application parent, string name) + : base(throwOnUnexpectedArg: true) + { + if (parent == null) + { + throw new ArgumentNullException(nameof(parent)); + } + + base.Parent = parent; + Name = name; + Out = parent.Out ?? Out; + Error = parent.Error ?? Error; + + Help = HelpOption("-?|-h|--help"); + OnExecute((Func>)ExecuteAsync); + } + + protected new Application Parent => (Application)base.Parent; + + protected CancellationToken Cancelled => Parent?.CancellationToken ?? default; + + protected CommandOption Help { get; } + + protected virtual bool ValidateArguments() + { + return true; + } + + protected abstract Task ExecuteCoreAsync(); + + private async Task ExecuteAsync() + { + if (!ValidateArguments()) + { + ShowHelp(); + return ExitCodeFailureRazorError; + } + + return await ExecuteCoreAsync(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CompilerHost.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CompilerHost.cs new file mode 100644 index 0000000000..0525beed06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CompilerHost.cs @@ -0,0 +1,134 @@ +// 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.Threading; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class CompilerHost + { + public static CompilerHost Create() + { + return new DefaultCompilerHost(); + } + + public abstract ServerResponse Execute(ServerRequest request, CancellationToken cancellationToken); + + private class DefaultCompilerHost : CompilerHost + { + public DefaultCompilerHost() + { + // The loader needs to live for the lifetime of the server. + // + // This means that if a request tries to use a set of binaries that are inconsistent with what + // the server already has, then it will be rejected to try again on the client. + // + // We also check each set of extensions for missing depenencies individually, so that we can + // consistently reject a request that doesn't specify everything it needs. Otherwise the request + // could succeed sometimes if it relies on transient state. + Loader = new DefaultExtensionAssemblyLoader(Path.Combine(Path.GetTempPath(), "Razor-Server")); + + AssemblyReferenceProvider = (path, properties) => new CachingMetadataReference(path, properties); + } + + public Func AssemblyReferenceProvider { get; } + + public ExtensionAssemblyLoader Loader { get; } + + public override ServerResponse Execute(ServerRequest request, CancellationToken cancellationToken) + { + if (!TryParseArguments(request, out var parsed)) + { + return new RejectedServerResponse(); + } + + var exitCode = 0; + var commandArgs = parsed.args.ToArray(); + + var outputWriter = new StringWriter(); + var errorWriter = new StringWriter(); + + var checker = new DefaultExtensionDependencyChecker(Loader, outputWriter, errorWriter); + var app = new Application(cancellationToken, Loader, checker, AssemblyReferenceProvider, outputWriter, errorWriter); + + exitCode = app.Execute(commandArgs); + + var output = outputWriter.ToString(); + var error = errorWriter.ToString(); + + outputWriter.Dispose(); + errorWriter.Dispose(); + + // This will no-op if server logging is not enabled. + ServerLogger.Log(output); + ServerLogger.Log(error); + + return new CompletedServerResponse(exitCode, utf8output: false, output, error); + } + + private bool TryParseArguments(ServerRequest request, out (string workingDirectory, string tempDirectory, string[] args) parsed) + { + string workingDirectory = null; + string tempDirectory = null; + + var args = new List(request.Arguments.Count); + + for (var i = 0; i < request.Arguments.Count; i++) + { + var argument = request.Arguments[i]; + if (argument.Id == RequestArgument.ArgumentId.CurrentDirectory) + { + workingDirectory = argument.Value; + } + else if (argument.Id == RequestArgument.ArgumentId.TempDirectory) + { + tempDirectory = argument.Value; + } + else if (argument.Id == RequestArgument.ArgumentId.CommandLineArgument) + { + args.Add(argument.Value); + } + } + + ServerLogger.Log($"WorkingDirectory = '{workingDirectory}'"); + ServerLogger.Log($"TempDirectory = '{tempDirectory}'"); + for (var i = 0; i < args.Count; i++) + { + ServerLogger.Log($"Argument[{i}] = '{request.Arguments[i]}'"); + } + + if (string.IsNullOrEmpty(workingDirectory)) + { + ServerLogger.Log($"Rejecting build due to missing working directory"); + + parsed = default; + return false; + } + + if (string.IsNullOrEmpty(tempDirectory)) + { + ServerLogger.Log($"Rejecting build due to missing temp directory"); + + parsed = default; + return false; + } + + if (string.IsNullOrEmpty(tempDirectory)) + { + ServerLogger.Log($"Rejecting build due to missing temp directory"); + + parsed = default; + return false; + } + + parsed = (workingDirectory, tempDirectory, args.ToArray()); + return true; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CompositeRazorProjectFileSystem.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CompositeRazorProjectFileSystem.cs new file mode 100644 index 0000000000..092851d311 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/CompositeRazorProjectFileSystem.cs @@ -0,0 +1,51 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class CompositeRazorProjectFileSystem : RazorProjectFileSystem + { + public CompositeRazorProjectFileSystem(IReadOnlyList fileSystems) + { + FileSystems = fileSystems ?? throw new ArgumentNullException(nameof(fileSystems)); + } + + public IReadOnlyList FileSystems { get; } + + public override IEnumerable EnumerateItems(string basePath) + { + foreach (var fileSystem in FileSystems) + { + foreach (var result in fileSystem.EnumerateItems(basePath)) + { + yield return result; + } + } + } + + [Obsolete("Use GetItem(string path, string fileKind) instead.")] + public override RazorProjectItem GetItem(string path) + { + return GetItem(path, fileKind: null); + } + + public override RazorProjectItem GetItem(string path, string fileKind) + { + RazorProjectItem razorProjectItem = null; + foreach (var fileSystem in FileSystems) + { + razorProjectItem = fileSystem.GetItem(path, fileKind); + if (razorProjectItem != null && razorProjectItem.Exists) + { + return razorProjectItem; + } + } + + return razorProjectItem; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConcurrentLruCache.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConcurrentLruCache.cs new file mode 100644 index 0000000000..0220615ec2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConcurrentLruCache.cs @@ -0,0 +1,207 @@ +// 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.Diagnostics; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// Cache with a fixed size that evicts the least recently used members. + /// Thread-safe. + /// This was taken from https://github.com/dotnet/roslyn/blob/749c0ec135d7d080658dc1aa794d15229c3d10d2/src/Compilers/Core/Portable/InternalUtilities/ConcurrentLruCache.cs. + /// + internal class ConcurrentLruCache + { + private readonly int _capacity; + + private readonly Dictionary _cache; + private readonly LinkedList _nodeList; + // This is a naive course-grained lock, it can probably be optimized + private readonly object _lockObject = new object(); + + public ConcurrentLruCache(int capacity) + : this (capacity, EqualityComparer.Default) + { + } + + public ConcurrentLruCache(int capacity, IEqualityComparer comparer) + { + if (capacity <= 0) + { + throw new ArgumentOutOfRangeException(nameof(capacity)); + } + _capacity = capacity; + _cache = new Dictionary(capacity, comparer); + _nodeList = new LinkedList(); + } + + /// + /// Create cache from an array. The cache capacity will be the size + /// of the array. All elements of the array will be added to the + /// cache. If any duplicate keys are found in the array a + /// will be thrown. + /// + public ConcurrentLruCache(KeyValuePair[] array) + : this(array.Length) + { + foreach (var kvp in array) + { + UnsafeAdd(kvp.Key, kvp.Value); + } + } + + public int Count + { + get + { + lock (_lockObject) + { + return _cache.Count; + } + } + } + + public void Add(TKey key, TValue value) + { + lock (_lockObject) + { + UnsafeAdd(key, value); + } + } + + public TValue GetOrAdd(TKey key, TValue value) + { + lock (_lockObject) + { + if (UnsafeTryGetValue(key, out var result)) + { + return result; + } + else + { + UnsafeAdd(key, value); + return value; + } + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + lock (_lockObject) + { + return UnsafeTryGetValue(key, out value); + } + } + + public bool Remove(TKey key) + { + lock (_lockObject) + { + return UnsafeRemove(key); + } + } + + /// + /// For testing. Very expensive. + /// + internal IEnumerable> TestingEnumerable + { + get + { + lock (_lockObject) + { + foreach (var key in _nodeList) + { + var kvp = new KeyValuePair(key, _cache[key].Value); + yield return kvp; + } + } + } + } + + /// + /// Doesn't lock. + /// + private bool UnsafeTryGetValue(TKey key, out TValue value) + { + if (_cache.TryGetValue(key, out var result)) + { + MoveNodeToTop(result.Node); + value = result.Value; + return true; + } + else + { + value = default(TValue); + return false; + } + } + + private void MoveNodeToTop(LinkedListNode node) + { + if (!object.ReferenceEquals(_nodeList.First, node)) + { + _nodeList.Remove(node); + _nodeList.AddFirst(node); + } + } + + /// + /// Expects non-empty cache. Does not lock. + /// + private void UnsafeEvictLastNode() + { + Debug.Assert(_capacity > 0); + var lastNode = _nodeList.Last; + _nodeList.Remove(lastNode); + _cache.Remove(lastNode.Value); + } + + private void UnsafeAddNodeToTop(TKey key, TValue value) + { + var node = new LinkedListNode(key); + _cache.Add(key, new CacheValue(value, node)); + _nodeList.AddFirst(node); + } + + /// + /// Doesn't lock. + /// + private void UnsafeAdd(TKey key, TValue value) + { + if (_cache.TryGetValue(key, out var result)) + { + throw new ArgumentException("Key already exists", nameof(key)); + } + else + { + if (_cache.Count == _capacity) + { + UnsafeEvictLastNode(); + } + UnsafeAddNodeToTop(key, value); + } + } + + private bool UnsafeRemove(TKey key) + { + _nodeList.Remove(key); + return _cache.Remove(key); + } + + private struct CacheValue + { + public CacheValue(TValue value, LinkedListNode node) + { + Value = value; + Node = node; + } + + public TValue Value { get; } + + public LinkedListNode Node { get; } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Connection.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Connection.cs new file mode 100644 index 0000000000..9acf1589c9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Connection.cs @@ -0,0 +1,28 @@ +// 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.Threading; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class Connection : IDisposable + { + public string Identifier { get; protected set; } + + public Stream Stream { get; protected set; } + + public abstract Task WaitForDisconnectAsync(CancellationToken cancellationToken); + + public void Dispose() + { + Dispose(disposing: true); + } + + protected virtual void Dispose(bool disposing) + { + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConnectionHost.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConnectionHost.cs new file mode 100644 index 0000000000..dfa661f77d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConnectionHost.cs @@ -0,0 +1,148 @@ +// 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.IO.Pipes; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + // Heavily influenced by: + // https://github.com/dotnet/roslyn/blob/14aed138a01c448143b9acf0fe77a662e3dfe2f4/src/Compilers/Server/VBCSCompiler/NamedPipeClientConnection.cs#L17 + internal abstract class ConnectionHost + { + private static int counter; + + public abstract Task WaitForConnectionAsync(CancellationToken cancellationToken); + + public static ConnectionHost Create(string pipeName) + { + return new NamedPipeConnectionHost(pipeName); + } + + private static string GetNextIdentifier() + { + var id = Interlocked.Increment(ref counter); + return "connection-" + id; + } + + private class NamedPipeConnectionHost : ConnectionHost + { + // Size of the buffers to use: 64K + private const int PipeBufferSize = 0x10000; + + // From https://github.com/dotnet/corefx/blob/29cd6a0b0ac2993cee23ebaf36ca3d4bce6dd75f/src/System.IO.Pipes/ref/System.IO.Pipes.cs#L93. + // Using the enum value directly as this option is not available in netstandard. + private const PipeOptions PipeOptionCurrentUserOnly = (PipeOptions)536870912; + + private static readonly PipeOptions _pipeOptions = GetPipeOptions(); + + public NamedPipeConnectionHost(string pipeName) + { + PipeName = pipeName; + } + + public string PipeName { get; } + + public async override Task WaitForConnectionAsync(CancellationToken cancellationToken) + { + // Create the pipe and begin waiting for a connection. This doesn't block, but could fail + // in certain circumstances, such as the OS refusing to create the pipe for some reason + // or the pipe was disconnected before we starting listening. + var pipeStream = new NamedPipeServerStream( + PipeName, + PipeDirection.InOut, + NamedPipeServerStream.MaxAllowedServerInstances, // Maximum connections. + PipeTransmissionMode.Byte, + _pipeOptions, + PipeBufferSize, // Default input buffer + PipeBufferSize);// Default output buffer + + ServerLogger.Log("Waiting for new connection"); + await pipeStream.WaitForConnectionAsync(cancellationToken); + ServerLogger.Log("Pipe connection detected."); + + if (Environment.Is64BitProcess || Memory.IsMemoryAvailable()) + { + ServerLogger.Log("Memory available - accepting connection"); + return new NamedPipeConnection(pipeStream, GetNextIdentifier()); + } + + pipeStream.Close(); + throw new Exception("Insufficient resources to process new connection."); + } + + private static PipeOptions GetPipeOptions() + { + var options = PipeOptions.Asynchronous | PipeOptions.WriteThrough; + + if (Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly)) + { + return options | PipeOptionCurrentUserOnly; + } + + return options; + } + } + + private class NamedPipeConnection : Connection + { + public NamedPipeConnection(NamedPipeServerStream stream, string identifier) + { + Stream = stream; + Identifier = identifier; + } + + public async override Task WaitForDisconnectAsync(CancellationToken cancellationToken) + { + if (!(Stream is PipeStream pipeStream)) + { + return; + } + + // We have to poll for disconnection by reading, PipeStream.IsConnected isn't reliable unless you + // actually do a read - which will cause it to update its state. + while (!cancellationToken.IsCancellationRequested && pipeStream.IsConnected) + { + await Task.Delay(TimeSpan.FromMilliseconds(100), cancellationToken); + + try + { + ServerLogger.Log($"Before poking pipe {Identifier}."); + await Stream.ReadAsync(Array.Empty(), 0, 0, cancellationToken); + ServerLogger.Log($"After poking pipe {Identifier}."); + } + catch (OperationCanceledException) + { + } + catch (Exception e) + { + // It is okay for this call to fail. Errors will be reflected in the + // IsConnected property which will be read on the next iteration. + ServerLogger.LogException(e, $"Error poking pipe {Identifier}."); + } + } + } + + protected override void Dispose(bool disposing) + { + ServerLogger.Log($"Pipe {Identifier}: Closing."); + + try + { + Stream.Dispose(); + } + catch (Exception ex) + { + // The client connection failing to close isn't fatal to the server process. It is simply a client + // for which we can no longer communicate and that's okay because the Close method indicates we are + // done with the client already. + var message = string.Format($"Pipe {Identifier}: Error closing pipe."); + ServerLogger.LogException(ex, message); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConnectionResult.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConnectionResult.cs new file mode 100644 index 0000000000..6c20725617 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ConnectionResult.cs @@ -0,0 +1,47 @@ +// 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.Razor.Tools +{ + internal struct ConnectionResult + { + public readonly Reason CloseReason; + public readonly TimeSpan? KeepAlive; + + public ConnectionResult(Reason closeReason, TimeSpan? keepAlive = null) + { + CloseReason = closeReason; + KeepAlive = keepAlive; + } + + public enum Reason + { + /// + /// There was an error creating the request object and a compilation was never created. + /// + CompilationNotStarted, + + /// + /// The compilation completed and results were provided to the client. + /// + CompilationCompleted, + + /// + /// The compilation process was initiated and the client disconnected before the results could be provided to them. + /// + ClientDisconnect, + + /// + /// There was an unhandled exception processing the result. + /// + ClientException, + + /// + /// There was a request from the client to shutdown the server. + /// + ClientShutdownRequest, + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DebugMode.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DebugMode.cs new file mode 100644 index 0000000000..5d38654c52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DebugMode.cs @@ -0,0 +1,27 @@ +// 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.Diagnostics; +using System.Linq; +using System.Threading; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class DebugMode + { + public static void HandleDebugSwitch(ref string[] args) + { + if (args.Length > 0 && string.Equals("--debug", args[0], StringComparison.OrdinalIgnoreCase)) + { + args = args.Skip(1).ToArray(); + + Console.WriteLine("Waiting for debugger in pid: {0}", Process.GetCurrentProcess().Id); + while (!Debugger.IsAttached) + { + Thread.Sleep(TimeSpan.FromSeconds(3)); + } + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultExtensionAssemblyLoader.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultExtensionAssemblyLoader.cs new file mode 100644 index 0000000000..05dc4a09eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultExtensionAssemblyLoader.cs @@ -0,0 +1,241 @@ +// 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.IO; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using System.Runtime.Loader; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class DefaultExtensionAssemblyLoader : ExtensionAssemblyLoader + { + private readonly string _baseDirectory; + + private readonly object _lock = new object(); + private readonly Dictionary _loadedByPath; + private readonly Dictionary _loadedByIdentity; + private readonly Dictionary _identityCache; + private readonly Dictionary> _wellKnownAssemblies; + + private ShadowCopyManager _shadowCopyManager; + + public DefaultExtensionAssemblyLoader(string baseDirectory) + { + _baseDirectory = baseDirectory; + + _loadedByPath = new Dictionary(StringComparer.OrdinalIgnoreCase); + _loadedByIdentity = new Dictionary(); + _identityCache = new Dictionary(StringComparer.OrdinalIgnoreCase); + _wellKnownAssemblies = new Dictionary>(StringComparer.OrdinalIgnoreCase); + + LoadContext = new ExtensionAssemblyLoadContext(AssemblyLoadContext.GetLoadContext(typeof(ExtensionAssemblyLoader).Assembly), this); + } + + protected AssemblyLoadContext LoadContext { get; } + + public override void AddAssemblyLocation(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + if (!Path.IsPathRooted(filePath)) + { + throw new ArgumentException(nameof(filePath)); + } + + var assemblyName = Path.GetFileNameWithoutExtension(filePath); + lock (_lock) + { + if (!_wellKnownAssemblies.TryGetValue(assemblyName, out var paths)) + { + paths = new List(); + _wellKnownAssemblies.Add(assemblyName, paths); + } + + if (!paths.Contains(filePath)) + { + paths.Add(filePath); + } + } + } + + public override Assembly Load(string assemblyName) + { + if (!AssemblyIdentity.TryParseDisplayName(assemblyName, out var identity)) + { + return null; + } + + lock (_lock) + { + // First, check if this loader already loaded the requested assembly: + if (_loadedByIdentity.TryGetValue(identity, out var assembly)) + { + return assembly; + } + + // Second, check if an assembly file of the same simple name was registered with the loader: + if (_wellKnownAssemblies.TryGetValue(identity.Name, out var paths)) + { + // Multiple assemblies of the same simple name but different identities might have been registered. + // Load the one that matches the requested identity (if any). + foreach (var path in paths) + { + var candidateIdentity = GetIdentity(path); + + if (identity.Equals(candidateIdentity)) + { + return LoadFromPathUnsafe(path, candidateIdentity); + } + } + } + + // We only support loading by name from 'well-known' paths. If you need to load something by + // name and you get here, then that means we don't know where to look. + return null; + } + } + + public override Assembly LoadFromPath(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + if (!Path.IsPathRooted(filePath)) + { + throw new ArgumentException(nameof(filePath)); + } + + lock (_lock) + { + return LoadFromPathUnsafe(filePath, identity: null); + } + } + + private Assembly LoadFromPathUnsafe(string filePath, AssemblyIdentity identity) + { + // If we've already loaded the assembly by path there should be nothing else to do, + // all of our data is up to date. + if (_loadedByPath.TryGetValue(filePath, out var entry)) + { + return entry.assembly; + } + + // If we've already loaded the assembly by identity, then we might has some updating + // to do. + identity = identity ?? GetIdentity(filePath); + if (identity != null && _loadedByIdentity.TryGetValue(identity, out var assembly)) + { + // An assembly file might be replaced by another file with a different identity. + // Last one wins. + _loadedByPath[filePath] = (assembly, identity); + return assembly; + } + + // Ok we don't have this cached. Let's actually try to load the assembly. + assembly = LoadFromPathUnsafeCore(CopyAssembly(filePath)); + + identity = identity ?? AssemblyIdentity.FromAssemblyDefinition(assembly); + + // It's possible an assembly was loaded by two different paths. Just use the original then. + if (_loadedByIdentity.TryGetValue(identity, out var duplicate)) + { + assembly = duplicate; + } + else + { + _loadedByIdentity.Add(identity, assembly); + } + + _loadedByPath[filePath] = (assembly, identity); + return assembly; + } + + private AssemblyIdentity GetIdentity(string filePath) + { + if (!_identityCache.TryGetValue(filePath, out var identity)) + { + identity = ReadAssemblyIdentity(filePath); + _identityCache.Add(filePath, identity); + } + + return identity; + } + + protected virtual string CopyAssembly(string filePath) + { + if (_baseDirectory == null) + { + // Don't shadow-copy when base directory is null. This means we're running as a CLI not + // a server. + return filePath; + } + + if (_shadowCopyManager == null) + { + _shadowCopyManager = new ShadowCopyManager(_baseDirectory); + } + + return _shadowCopyManager.AddAssembly(filePath); + } + + protected virtual Assembly LoadFromPathUnsafeCore(string filePath) + { + return LoadContext.LoadFromAssemblyPath(filePath); + } + + private static AssemblyIdentity ReadAssemblyIdentity(string filePath) + { + try + { + using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)) + using (var reader = new PEReader(stream)) + { + var metadataReader = reader.GetMetadataReader(); + return metadataReader.GetAssemblyIdentity(); + } + } + catch + { + } + + return null; + } + + private class ExtensionAssemblyLoadContext : AssemblyLoadContext + { + private readonly AssemblyLoadContext _parent; + private readonly DefaultExtensionAssemblyLoader _loader; + + public ExtensionAssemblyLoadContext(AssemblyLoadContext parent, DefaultExtensionAssemblyLoader loader) + { + _parent = parent; + _loader = loader; + } + + protected override Assembly Load(AssemblyName assemblyName) + { + // Try to load from well-known paths. This will be called when loading a dependency of an extension. + var assembly = _loader.Load(assemblyName.ToString()); + if (assembly != null) + { + return assembly; + } + + // If we don't have an entry, then fall back to the default load context. This allows extensions + // to resolve assemblies that are provided by the host. + return _parent.LoadFromAssemblyName(assemblyName); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultExtensionDependencyChecker.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultExtensionDependencyChecker.cs new file mode 100644 index 0000000000..79d01afb9d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultExtensionDependencyChecker.cs @@ -0,0 +1,158 @@ +// 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.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class DefaultExtensionDependencyChecker : ExtensionDependencyChecker + { + // These are treated as prefixes. So `Microsoft.CodeAnalysis.Razor` would be assumed to work. + private static readonly string[] DefaultIgnoredAssemblies = new string[] + { + "mscorlib", + "netstandard", + "System", + "Microsoft.CodeAnalysis", + "Microsoft.AspNetCore.Razor.Language", + }; + + private readonly ExtensionAssemblyLoader _loader; + private readonly TextWriter _output; + private readonly TextWriter _error; + private readonly string[] _ignoredAssemblies; + + public DefaultExtensionDependencyChecker( + ExtensionAssemblyLoader loader, + TextWriter output, + TextWriter error, + string[] ignoredAssemblies = null) + { + _loader = loader; + _output = output; + _error = error; + _ignoredAssemblies = ignoredAssemblies ?? DefaultIgnoredAssemblies; + } + + public override bool Check(IEnumerable assmblyFilePaths) + { + try + { + return CheckCore(assmblyFilePaths); + } + catch (Exception ex) + { + _error.WriteLine("Exception performing Extension dependency check:"); + _error.WriteLine(ex.ToString()); + return false; + } + } + + private bool CheckCore(IEnumerable assemblyFilePaths) + { + var items = assemblyFilePaths.Select(a => ExtensionVerificationItem.Create(a)).ToArray(); + var assemblies = new HashSet(items.Select(i => i.Identity)); + + for (var i = 0; i < items.Length; i++) + { + var item = items[i]; + _output.WriteLine($"Verifying assembly at {item.FilePath}"); + + if (!Path.IsPathRooted(item.FilePath)) + { + _error.WriteLine($"The file path '{item.FilePath}' is not a rooted path. File paths must be absolute and fully-qualified."); + return false; + } + + foreach (var reference in item.References) + { + if (_ignoredAssemblies.Any(n => reference.Name.StartsWith(n))) + { + // This is on the allow list, keep going. + continue; + } + + if (assemblies.Contains(reference)) + { + // This was also provided as a dependency, keep going. + continue; + } + + // If we get here we can't resolve this assembly. This is an error. + _error.WriteLine($"Extension assembly '{item.Identity.Name}' depends on '{reference.ToString()} which is missing."); + return false; + } + } + + // Assuming we get this far, the set of assemblies we have is at least a coherent set (barring + // version conflicts). Register all of the paths with the loader so they can find each other by + // name. + for (var i = 0; i < items.Length; i++) + { + _loader.AddAssemblyLocation(items[i].FilePath); + } + + // Now try to load everything. This has the side effect of resolving all of these items + // in the loader's caches. + for (var i = 0; i < items.Length; i++) + { + var item = items[i]; + item.Assembly = _loader.LoadFromPath(item.FilePath); + } + + // Third, check that the MVIDs of the files on disk match the MVIDs of the loaded assemblies. + for (var i = 0; i < items.Length; i++) + { + var item = items[i]; + if (item.Mvid != item.Assembly.ManifestModule.ModuleVersionId) + { + _error.WriteLine($"Extension assembly '{item.Identity.Name}' at '{item.FilePath}' has a different ModuleVersionId than loaded assembly '{item.Assembly.FullName}'"); + return false; + } + } + + return true; + } + + private class ExtensionVerificationItem + { + public static ExtensionVerificationItem Create(string filePath) + { + using (var peReader = new PEReader(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))) + { + var metadataReader = peReader.GetMetadataReader(); + var identity = metadataReader.GetAssemblyIdentity(); + var mvid = metadataReader.GetGuid(metadataReader.GetModuleDefinition().Mvid); + var references = metadataReader.GetReferencedAssembliesOrThrow(); + + return new ExtensionVerificationItem(filePath, identity, mvid, references.ToArray()); + } + } + + private ExtensionVerificationItem(string filePath, AssemblyIdentity identity, Guid mvid, AssemblyIdentity[] references) + { + FilePath = filePath; + Identity = identity; + Mvid = mvid; + References = references; + } + + public string FilePath { get; } + + public Assembly Assembly { get; set; } + + public AssemblyIdentity Identity { get; } + + public Guid Mvid { get; } + + public IReadOnlyList References { get; } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultRequestDispatcher.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultRequestDispatcher.cs new file mode 100644 index 0000000000..59d2bbc098 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DefaultRequestDispatcher.cs @@ -0,0 +1,472 @@ +// 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.Diagnostics; +using System.Linq; +using System.Runtime; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + // Heavily influenced by: + // https://github.com/dotnet/roslyn/blob/14aed138a01c448143b9acf0fe77a662e3dfe2f4/src/Compilers/Server/ServerShared/ServerDispatcher.cs#L15 + internal class DefaultRequestDispatcher : RequestDispatcher + { + private readonly CancellationToken _cancellationToken; + private readonly CompilerHost _compilerHost; + private readonly ConnectionHost _connectionHost; + private readonly EventBus _eventBus; + + private KeepAlive _keepAlive; + private State _state; + private Task _timeoutTask; + private Task _gcTask; + private Task _listenTask; + private CancellationTokenSource _listenCancellationTokenSource; + private List> _connections = new List>(); + + public DefaultRequestDispatcher( + ConnectionHost connectionHost, + CompilerHost compilerHost, + CancellationToken cancellationToken, + EventBus eventBus = null, + TimeSpan? keepAlive = null) + { + _connectionHost = connectionHost; + _compilerHost = compilerHost; + _cancellationToken = cancellationToken; + + _eventBus = eventBus ?? EventBus.Default; + + var keepAliveTimeout = DefaultServerKeepAlive; + if (keepAlive.HasValue) + { + keepAliveTimeout = keepAlive.Value; + } + _keepAlive = new KeepAlive(keepAliveTimeout, isDefault: true); + } + + // The server accepts connections until we reach a state that requires a shutdown. At that + // time no new connections will be accepted and the server will drain existing connections. + // + // The idea is that it's better to let clients fallback to in-proc (and slow down) than it is to keep + // running in an undesired state. + public override void Run() + { + _state = State.Running; + + try + { + Listen(); + + do + { + Debug.Assert(_listenTask != null); + + MaybeCreateTimeoutTask(); + MaybeCreateGCTask(); + WaitForAnyCompletion(_cancellationToken); + CheckCompletedTasks(_cancellationToken); + } + while (_connections.Count > 0 || _state == State.Running); + } + finally + { + _state = State.Completed; + _gcTask = null; + _timeoutTask = null; + + if (_listenTask != null) + { + CloseListenTask(); + } + } + } + + + private void CheckCompletedTasks(CancellationToken cancellationToken) + { + if (cancellationToken.IsCancellationRequested) + { + HandleCancellation(); + return; + } + + if (_listenTask.IsCompleted) + { + HandleCompletedListenTask(cancellationToken); + } + + if (_timeoutTask?.IsCompleted == true) + { + HandleCompletedTimeoutTask(); + } + + if (_gcTask?.IsCompleted == true) + { + HandleCompletedGCTask(); + } + + HandleCompletedConnections(); + } + + private void HandleCancellation() + { + Debug.Assert(_listenTask != null); + + // If cancellation has been requested then the server needs to be in the process + // of shutting down. + _state = State.ShuttingDown; + + CloseListenTask(); + + try + { + Task.WaitAll(_connections.ToArray()); + } + catch + { + // It's expected that some will throw exceptions, in particular OperationCanceledException. It's + // okay for them to throw so long as they complete. + } + + HandleCompletedConnections(); + Debug.Assert(_connections.Count == 0); + } + + /// + /// The server farms out work to Task values and this method needs to wait until at least one of them + /// has completed. + /// + private void WaitForAnyCompletion(CancellationToken cancellationToken) + { + var all = new List(); + all.AddRange(_connections); + all.Add(_timeoutTask); + all.Add(_listenTask); + all.Add(_gcTask); + + try + { + var waitArray = all.Where(x => x != null).ToArray(); + Task.WaitAny(waitArray, cancellationToken); + } + catch (OperationCanceledException) + { + // Thrown when the provided cancellationToken is cancelled. This is handled in the caller, + // here it just serves to break out of the WaitAny call. + } + } + + private void Listen() + { + Debug.Assert(_listenTask == null); + Debug.Assert(_timeoutTask == null); + + _listenCancellationTokenSource = new CancellationTokenSource(); + _listenTask = _connectionHost.WaitForConnectionAsync(_listenCancellationTokenSource.Token); + _eventBus.ConnectionListening(); + } + + private void CloseListenTask() + { + Debug.Assert(_listenTask != null); + + _listenCancellationTokenSource.Cancel(); + _listenCancellationTokenSource = null; + _listenTask = null; + } + + private void HandleCompletedListenTask(CancellationToken cancellationToken) + { + _eventBus.ConnectionReceived(); + + // Don't accept any new connections once we're in shutdown mode, instead gracefully reject the request. + // This should cause the client to run in process. + var accept = _state == State.Running; + var connectionTask = AcceptConnection(_listenTask, accept, cancellationToken); + _connections.Add(connectionTask); + + // Timeout and GC are only done when there are no active connections. Now that we have a new + // connection cancel out these tasks. + _timeoutTask = null; + _gcTask = null; + + // Begin listening again for new connections. + _listenTask = null; + Listen(); + } + + private void HandleCompletedTimeoutTask() + { + _eventBus.KeepAliveReached(); + _listenCancellationTokenSource.Cancel(); + _timeoutTask = null; + _state = State.ShuttingDown; + } + + private void HandleCompletedGCTask() + { + _gcTask = null; + for (var i = 0; i < 10; i++) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; + GC.Collect(); + } + + private void MaybeCreateTimeoutTask() + { + // If there are no active clients running then the server needs to be in a timeout mode. + if (_connections.Count == 0 && _timeoutTask == null) + { + Debug.Assert(_listenTask != null); + _timeoutTask = Task.Delay(_keepAlive.TimeSpan); + } + } + + private void MaybeCreateGCTask() + { + if (_connections.Count == 0 && _gcTask == null) + { + _gcTask = Task.Delay(GCTimeout); + } + } + + /// + /// Checks the completed connection objects. + /// + /// False if the server needs to begin shutting down + private void HandleCompletedConnections() + { + var shutdown = false; + var processedCount = 0; + var i = 0; + while (i < _connections.Count) + { + var current = _connections[i]; + if (!current.IsCompleted) + { + i++; + continue; + } + + _connections.RemoveAt(i); + processedCount++; + + var result = current.Result; + if (result.KeepAlive.HasValue) + { + var updated = _keepAlive.Update(result.KeepAlive.Value); + if (updated.Equals(_keepAlive)) + { + _eventBus.UpdateKeepAlive(updated.TimeSpan); + } + } + + switch (result.CloseReason) + { + case ConnectionResult.Reason.CompilationCompleted: + case ConnectionResult.Reason.CompilationNotStarted: + // These are all normal end states. Nothing to do here. + break; + + case ConnectionResult.Reason.ClientDisconnect: + // Have to assume the worst here which is user pressing Ctrl+C at the command line and + // hence wanting all compilation to end. + _eventBus.ConnectionRudelyEnded(); + shutdown = true; + break; + + case ConnectionResult.Reason.ClientException: + case ConnectionResult.Reason.ClientShutdownRequest: + _eventBus.ConnectionRudelyEnded(); + shutdown = true; + break; + + default: + throw new InvalidOperationException($"Unexpected enum value {result.CloseReason}"); + } + } + + if (processedCount > 0) + { + _eventBus.ConnectionCompleted(processedCount); + } + + if (shutdown) + { + _state = State.ShuttingDown; + } + } + + internal async Task AcceptConnection(Task task, bool accept, CancellationToken cancellationToken) + { + Connection connection; + try + { + connection = await task; + } + catch (Exception ex) + { + // Unable to establish a connection with the client. The client is responsible for + // handling this case. Nothing else for us to do here. + ServerLogger.LogException(ex, "Error creating client named pipe"); + return new ConnectionResult(ConnectionResult.Reason.CompilationNotStarted); + } + + try + { + using (connection) + { + ServerRequest request; + try + { + ServerLogger.Log("Begin reading request."); + request = await ServerRequest.ReadAsync(connection.Stream, cancellationToken).ConfigureAwait(false); + ServerLogger.Log("End reading request."); + } + catch (Exception e) + { + ServerLogger.LogException(e, "Error reading build request."); + return new ConnectionResult(ConnectionResult.Reason.CompilationNotStarted); + } + + if (request.IsShutdownRequest()) + { + // Reply with the PID of this process so that the client can wait for it to exit. + var response = new ShutdownServerResponse(Process.GetCurrentProcess().Id); + await response.WriteAsync(connection.Stream, cancellationToken); + + // We can safely disconnect the client, then when this connection gets cleaned up by the event loop + // the server will go to a shutdown state. + return new ConnectionResult(ConnectionResult.Reason.ClientShutdownRequest); + } + else if (!accept) + { + // We're already in shutdown mode, respond gracefully so the client can run in-process. + var response = new RejectedServerResponse(); + await response.WriteAsync(connection.Stream, cancellationToken).ConfigureAwait(false); + + return new ConnectionResult(ConnectionResult.Reason.CompilationNotStarted); + } + else + { + // If we get here then this is a real request that we will accept and process. + // + // Kick off both the compilation and a task to monitor the pipe for closing. + var buildCancelled = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + + var watcher = connection.WaitForDisconnectAsync(buildCancelled.Token); + var worker = ExecuteRequestAsync(request, buildCancelled.Token); + + // await will end when either the work is complete or the connection is closed. + await Task.WhenAny(worker, watcher); + + // Do an 'await' on the completed task, preference being compilation, to force + // any exceptions to be realized in this method for logging. + ConnectionResult.Reason reason; + if (worker.IsCompleted) + { + var response = await worker; + + try + { + ServerLogger.Log("Begin writing response."); + await response.WriteAsync(connection.Stream, cancellationToken); + ServerLogger.Log("End writing response."); + + reason = ConnectionResult.Reason.CompilationCompleted; + + _eventBus.CompilationCompleted(); + } + catch + { + reason = ConnectionResult.Reason.ClientDisconnect; + } + } + else + { + await watcher; + reason = ConnectionResult.Reason.ClientDisconnect; + } + + // Begin the tear down of the Task which didn't complete. + buildCancelled.Cancel(); + + return new ConnectionResult(reason, request.KeepAlive); + } + } + } + catch (Exception ex) + { + ServerLogger.LogException(ex, "Error handling connection"); + return new ConnectionResult(ConnectionResult.Reason.ClientException); + } + } + + private Task ExecuteRequestAsync(ServerRequest buildRequest, CancellationToken cancellationToken) + { + Func func = () => + { + ServerLogger.Log("Begin processing request"); + + var response = _compilerHost.Execute(buildRequest, cancellationToken); + + ServerLogger.Log("End processing request"); + return response; + }; + + var task = new Task(func, cancellationToken, TaskCreationOptions.LongRunning); + task.Start(); + return task; + } + + private enum State + { + /// + /// Server running and accepting all requests + /// + Running, + + /// + /// Server processing existing requests, responding to shutdown commands but is not accepting + /// new build requests. + /// + ShuttingDown, + + /// + /// Server is done. + /// + Completed, + } + + private struct KeepAlive + { + public TimeSpan TimeSpan; + public bool IsDefault; + + public KeepAlive(TimeSpan timeSpan, bool isDefault) + { + TimeSpan = timeSpan; + IsDefault = isDefault; + } + + public KeepAlive Update(TimeSpan timeSpan) + { + if (IsDefault || timeSpan > TimeSpan) + { + return new KeepAlive(timeSpan, isDefault: false); + } + + return this; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DiscoverCommand.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DiscoverCommand.cs new file mode 100644 index 0000000000..1c96b83e85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/DiscoverCommand.cs @@ -0,0 +1,226 @@ +// 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.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.CodeAnalysis.Razor.Serialization; +using Microsoft.Extensions.CommandLineUtils; +using Microsoft.VisualStudio.LanguageServices.Razor.Serialization; +using Newtonsoft.Json; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class DiscoverCommand : CommandBase + { + public DiscoverCommand(Application parent) + : base(parent, "discover") + { + Assemblies = Argument("assemblies", "assemblies to search for tag helpers", multipleValues: true); + TagHelperManifest = Option("-o", "output file", CommandOptionType.SingleValue); + ProjectDirectory = Option("-p", "project root directory", CommandOptionType.SingleValue); + Version = Option("-v|--version", "Razor language version", CommandOptionType.SingleValue); + Configuration = Option("-c", "Razor configuration name", CommandOptionType.SingleValue); + ExtensionNames = Option("-n", "extension name", CommandOptionType.MultipleValue); + ExtensionFilePaths = Option("-e", "extension file path", CommandOptionType.MultipleValue); + } + + public CommandArgument Assemblies { get; } + + public CommandOption TagHelperManifest { get; } + + public CommandOption ProjectDirectory { get; } + + public CommandOption Version { get; } + + public CommandOption Configuration { get; } + + public CommandOption ExtensionNames { get; } + + public CommandOption ExtensionFilePaths { get; } + + protected override bool ValidateArguments() + { + if (string.IsNullOrEmpty(TagHelperManifest.Value())) + { + Error.WriteLine($"{TagHelperManifest.Description} must be specified."); + return false; + } + + if (Assemblies.Values.Count == 0) + { + Error.WriteLine($"{Assemblies.Name} must have at least one value."); + return false; + } + + if (string.IsNullOrEmpty(ProjectDirectory.Value())) + { + ProjectDirectory.Values.Add(Environment.CurrentDirectory); + } + + if (string.IsNullOrEmpty(Version.Value())) + { + Error.WriteLine($"{Version.Description} must be specified."); + return false; + } + else if (!RazorLanguageVersion.TryParse(Version.Value(), out _)) + { + Error.WriteLine($"Invalid option {Version.Value()} for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}."); + return false; + } + + if (string.IsNullOrEmpty(Configuration.Value())) + { + Error.WriteLine($"{Configuration.Description} must be specified."); + return false; + } + + if (ExtensionNames.Values.Count != ExtensionFilePaths.Values.Count) + { + Error.WriteLine($"{ExtensionNames.Description} and {ExtensionFilePaths.Description} should have the same number of values."); + } + + foreach (var filePath in ExtensionFilePaths.Values) + { + if (!Path.IsPathRooted(filePath)) + { + Error.WriteLine($"Extension file paths must be fully-qualified, absolute paths."); + return false; + } + } + + return true; + } + + protected override Task ExecuteCoreAsync() + { + if (!Parent.Checker.Check(ExtensionFilePaths.Values)) + { + Error.WriteLine($"Extenions could not be loaded. See output for details."); + return Task.FromResult(ExitCodeFailure); + } + + // Loading all of the extensions should succeed as the dependency checker will have already + // loaded them. + var extensions = new RazorExtension[ExtensionNames.Values.Count]; + for (var i = 0; i < ExtensionNames.Values.Count; i++) + { + extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); + } + + var version = RazorLanguageVersion.Parse(Version.Value()); + var configuration = RazorConfiguration.Create(version, Configuration.Value(), extensions); + + var result = ExecuteCore( + configuration: configuration, + projectDirectory: ProjectDirectory.Value(), + outputFilePath: TagHelperManifest.Value(), + assemblies: Assemblies.Values.ToArray()); + + return Task.FromResult(result); + } + + private int ExecuteCore(RazorConfiguration configuration, string projectDirectory, string outputFilePath, string[] assemblies) + { + outputFilePath = Path.Combine(projectDirectory, outputFilePath); + + var metadataReferences = new MetadataReference[assemblies.Length]; + for (var i = 0; i < assemblies.Length; i++) + { + metadataReferences[i] = Parent.AssemblyReferenceProvider(assemblies[i], default(MetadataReferenceProperties)); + } + + var engine = RazorProjectEngine.Create(configuration, RazorProjectFileSystem.Empty, b => + { + b.Features.Add(new DefaultMetadataReferenceFeature() { References = metadataReferences }); + b.Features.Add(new CompilationTagHelperFeature()); + b.Features.Add(new DefaultTagHelperDescriptorProvider()); + + CompilerFeatures.Register(b); + }); + + var feature = engine.Engine.Features.OfType().Single(); + var tagHelpers = feature.GetDescriptors(); + + using (var stream = new MemoryStream()) + { + Serialize(stream, tagHelpers); + + stream.Position = 0; + + var newHash = Hash(stream); + var existingHash = Hash(outputFilePath); + + if (!HashesEqual(newHash, existingHash)) + { + stream.Position = 0; + using (var output = File.Open(outputFilePath, FileMode.Create)) + { + stream.CopyTo(output); + } + } + } + + return ExitCodeSuccess; + } + + private static byte[] Hash(string path) + { + if (!File.Exists(path)) + { + return Array.Empty(); + } + + using (var stream = File.OpenRead(path)) + { + return Hash(stream); + } + } + + private static byte[] Hash(Stream stream) + { + using (var sha = SHA256.Create()) + { + sha.ComputeHash(stream); + return sha.Hash; + } + } + + private bool HashesEqual(byte[] x, byte[] y) + { + if (x.Length != y.Length) + { + return false; + } + + for (var i = 0; i < x.Length; i++) + { + if (x[i] != y[i]) + { + return false; + } + } + + return true; + } + + private static void Serialize(Stream stream, IReadOnlyList tagHelpers) + { + using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096, leaveOpen: true)) + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(new TagHelperDescriptorJsonConverter()); + serializer.Converters.Add(new RazorDiagnosticJsonConverter()); + + serializer.Serialize(writer, tagHelpers); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/EventBus.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/EventBus.cs new file mode 100644 index 0000000000..dacd5c07e7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/EventBus.cs @@ -0,0 +1,68 @@ +// 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.Razor.Tools +{ + internal abstract class EventBus + { + public static readonly EventBus Default = new DefaultEventBus(); + + /// + /// Called when the server updates the keep alive value. + /// + public virtual void UpdateKeepAlive(TimeSpan timeSpan) + { + } + + /// + /// Called each time the server listens for new connections. + /// + public virtual void ConnectionListening() + { + } + + /// + /// Called when a connection to the server occurs. + /// + public virtual void ConnectionReceived() + { + } + + /// + /// Called when one or more connections have completed processing. The number of connections + /// processed is provided in . + /// + public virtual void ConnectionCompleted(int count) + { + } + + /// + /// Called when a compilation is completed successfully and the response is written to the stream. + /// + public virtual void CompilationCompleted() + { + } + + /// + /// Called when a bad client connection was detected and the server will be shutting down as a + /// result. + /// + public virtual void ConnectionRudelyEnded() + { + } + + /// + /// Called when the server is shutting down because the keep alive timeout was reached. + /// + public virtual void KeepAliveReached() + { + } + + private class DefaultEventBus : EventBus + { + + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ExtensionAssemblyLoader.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ExtensionAssemblyLoader.cs new file mode 100644 index 0000000000..071eec2f82 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ExtensionAssemblyLoader.cs @@ -0,0 +1,16 @@ +// 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.Reflection; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class ExtensionAssemblyLoader + { + public abstract void AddAssemblyLocation(string filePath); + + public abstract Assembly Load(string assemblyName); + + public abstract Assembly LoadFromPath(string filePath); + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ExtensionDependencyChecker.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ExtensionDependencyChecker.cs new file mode 100644 index 0000000000..02fd86d9e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ExtensionDependencyChecker.cs @@ -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 System.Collections.Generic; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class ExtensionDependencyChecker + { + public abstract bool Check(IEnumerable extensionFilePaths); + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs new file mode 100644 index 0000000000..0406225fc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs @@ -0,0 +1,383 @@ +// 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.Diagnostics; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor; +using Microsoft.CodeAnalysis.Razor.Serialization; +using Microsoft.Extensions.CommandLineUtils; +using Microsoft.VisualStudio.LanguageServices.Razor.Serialization; +using Newtonsoft.Json; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class GenerateCommand : CommandBase + { + public GenerateCommand(Application parent) + : base(parent, "generate") + { + Sources = Option("-s", ".cshtml files to compile", CommandOptionType.MultipleValue); + Outputs = Option("-o", "Generated output file path", CommandOptionType.MultipleValue); + RelativePaths = Option("-r", "Relative path", CommandOptionType.MultipleValue); + FileKinds = Option("-k", "File kind", CommandOptionType.MultipleValue); + ProjectDirectory = Option("-p", "project root directory", CommandOptionType.SingleValue); + TagHelperManifest = Option("-t", "tag helper manifest file", CommandOptionType.SingleValue); + Version = Option("-v|--version", "Razor language version", CommandOptionType.SingleValue); + Configuration = Option("-c", "Razor configuration name", CommandOptionType.SingleValue); + ExtensionNames = Option("-n", "extension name", CommandOptionType.MultipleValue); + ExtensionFilePaths = Option("-e", "extension file path", CommandOptionType.MultipleValue); + RootNamespace = Option("--root-namespace", "root namespace for generated code", CommandOptionType.SingleValue); + CSharpLanguageVersion = Option("--csharp-language-version", "csharp language version generated code", CommandOptionType.SingleValue); + GenerateDeclaration = Option("--generate-declaration", "Generate declaration", CommandOptionType.NoValue); + } + + public CommandOption Sources { get; } + + public CommandOption Outputs { get; } + + public CommandOption RelativePaths { get; } + + public CommandOption FileKinds { get; } + + public CommandOption ProjectDirectory { get; } + + public CommandOption TagHelperManifest { get; } + + public CommandOption Version { get; } + + public CommandOption Configuration { get; } + + public CommandOption ExtensionNames { get; } + + public CommandOption ExtensionFilePaths { get; } + + public CommandOption RootNamespace { get; } + + public CommandOption CSharpLanguageVersion { get; } + + public CommandOption GenerateDeclaration { get; } + + protected override Task ExecuteCoreAsync() + { + if (!Parent.Checker.Check(ExtensionFilePaths.Values)) + { + Error.WriteLine($"Extensions could not be loaded. See output for details."); + return Task.FromResult(ExitCodeFailure); + } + + // Loading all of the extensions should succeed as the dependency checker will have already + // loaded them. + var extensions = new RazorExtension[ExtensionNames.Values.Count]; + for (var i = 0; i < ExtensionNames.Values.Count; i++) + { + extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); + } + + var version = RazorLanguageVersion.Parse(Version.Value()); + var configuration = RazorConfiguration.Create(version, Configuration.Value(), extensions); + + var sourceItems = GetSourceItems(ProjectDirectory.Value(), Sources.Values, Outputs.Values, RelativePaths.Values, FileKinds.Values); + + var result = ExecuteCore( + configuration: configuration, + projectDirectory: ProjectDirectory.Value(), + tagHelperManifest: TagHelperManifest.Value(), + sourceItems: sourceItems); + + return Task.FromResult(result); + } + + protected override bool ValidateArguments() + { + if (Sources.Values.Count == 0) + { + Error.WriteLine($"{Sources.Description} should have at least one value."); + return false; + } + + if (Outputs.Values.Count != Sources.Values.Count) + { + Error.WriteLine($"{Sources.Description} has {Sources.Values.Count}, but {Outputs.Description} has {Outputs.Values.Count} values."); + return false; + } + + if (RelativePaths.Values.Count != Sources.Values.Count) + { + Error.WriteLine($"{Sources.Description} has {Sources.Values.Count}, but {RelativePaths.Description} has {RelativePaths.Values.Count} values."); + return false; + } + + if (FileKinds.Values.Count != 0 && FileKinds.Values.Count != Sources.Values.Count) + { + // 2.x tasks do not specify FileKinds - in which case, no values will be present. If a kind for one file is specified, we expect as many kind entries + // as sources. + Error.WriteLine($"{Sources.Description} has {Sources.Values.Count}, but {FileKinds.Description} has {FileKinds.Values.Count} values."); + return false; + } + + if (string.IsNullOrEmpty(ProjectDirectory.Value())) + { + ProjectDirectory.Values.Add(Environment.CurrentDirectory); + } + + if (string.IsNullOrEmpty(Version.Value())) + { + Error.WriteLine($"{Version.Description} must be specified."); + return false; + } + else if (!RazorLanguageVersion.TryParse(Version.Value(), out _)) + { + Error.WriteLine($"Invalid option {Version.Value()} for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}."); + return false; + } + + if (string.IsNullOrEmpty(Configuration.Value())) + { + Error.WriteLine($"{Configuration.Description} must be specified."); + return false; + } + + if (ExtensionNames.Values.Count != ExtensionFilePaths.Values.Count) + { + Error.WriteLine($"{ExtensionNames.Description} and {ExtensionFilePaths.Description} should have the same number of values."); + } + + foreach (var filePath in ExtensionFilePaths.Values) + { + if (!Path.IsPathRooted(filePath)) + { + Error.WriteLine($"Extension file paths must be fully-qualified, absolute paths."); + return false; + } + } + + return true; + } + + private int ExecuteCore( + RazorConfiguration configuration, + string projectDirectory, + string tagHelperManifest, + SourceItem[] sourceItems) + { + tagHelperManifest = Path.Combine(projectDirectory, tagHelperManifest); + + var tagHelpers = GetTagHelpers(tagHelperManifest); + + var compositeFileSystem = new CompositeRazorProjectFileSystem(new[] + { + GetVirtualRazorProjectSystem(sourceItems), + RazorProjectFileSystem.Create(projectDirectory), + }); + + var success = true; + + var engine = RazorProjectEngine.Create(configuration, compositeFileSystem, b => + { + b.Features.Add(new StaticTagHelperFeature() { TagHelpers = tagHelpers, }); + b.Features.Add(new DefaultTypeNameFeature()); + + if (GenerateDeclaration.HasValue()) + { + b.Features.Add(new SetSuppressPrimaryMethodBodyOptionFeature()); + } + + if (RootNamespace.HasValue()) + { + b.SetRootNamespace(RootNamespace.Value()); + } + + if (CSharpLanguageVersion.HasValue()) + { + // Only set the C# language version if one was specified, otherwise it defaults to whatever + // value was set in the corresponding RazorConfiguration's extensions. + + var rawLanguageVersion = CSharpLanguageVersion.Value(); + if (LanguageVersionFacts.TryParse(rawLanguageVersion, out var csharpLanguageVersion)) + { + b.SetCSharpLanguageVersion(csharpLanguageVersion); + } + else + { + success = false; + Error.WriteLine($"Unknown C# language version {rawLanguageVersion}."); + } + } + }); + + var results = GenerateCode(engine, sourceItems); + + foreach (var result in results) + { + var errorCount = result.CSharpDocument.Diagnostics.Count; + for (var i = 0; i < errorCount; i++) + { + var error = result.CSharpDocument.Diagnostics[i]; + if (error.Severity == RazorDiagnosticSeverity.Error) + { + success = false; + } + + if (i < 100) + { + Error.WriteLine(error.ToString()); + + // Only show the first 100 errors to prevent massive string allocations. + if (i == 99) + { + Error.WriteLine($"And {errorCount - i + 1} more warnings/errors."); + } + } + } + + if (success) + { + // Only output the file if we generated it without errors. + var outputFilePath = result.InputItem.OutputPath; + File.WriteAllText(outputFilePath, result.CSharpDocument.GeneratedCode); + } + } + + return success ? ExitCodeSuccess : ExitCodeFailureRazorError; + } + + private VirtualRazorProjectFileSystem GetVirtualRazorProjectSystem(SourceItem[] inputItems) + { + var project = new VirtualRazorProjectFileSystem(); + foreach (var item in inputItems) + { + var projectItem = new DefaultRazorProjectItem( + basePath: "/", + filePath: item.FilePath, + relativePhysicalPath: item.RelativePhysicalPath, + fileKind: item.FileKind, + file: new FileInfo(item.SourcePath)); + + project.Add(projectItem); + } + + return project; + } + + private IReadOnlyList GetTagHelpers(string tagHelperManifest) + { + if (!File.Exists(tagHelperManifest)) + { + return Array.Empty(); + } + + using (var stream = File.OpenRead(tagHelperManifest)) + { + var reader = new JsonTextReader(new StreamReader(stream)); + + var serializer = new JsonSerializer(); + serializer.Converters.Add(new RazorDiagnosticJsonConverter()); + serializer.Converters.Add(new TagHelperDescriptorJsonConverter()); + + var descriptors = serializer.Deserialize>(reader); + return descriptors; + } + } + + private SourceItem[] GetSourceItems(string projectDirectory, List sources, List outputs, List relativePath, List fileKinds) + { + var items = new SourceItem[sources.Count]; + for (var i = 0; i < items.Length; i++) + { + var outputPath = Path.Combine(projectDirectory, outputs[i]); + var fileKind = fileKinds.Count > 0 ? fileKinds[i] : "mvc"; + if (Language.FileKinds.IsComponent(fileKind)) + { + fileKind = Language.FileKinds.GetComponentFileKindFromFilePath(sources[i]); + } + + items[i] = new SourceItem(sources[i], outputs[i], relativePath[i], fileKind); + } + + return items; + } + + private OutputItem[] GenerateCode(RazorProjectEngine engine, SourceItem[] inputs) + { + var outputs = new OutputItem[inputs.Length]; + Parallel.For(0, outputs.Length, new ParallelOptions() { MaxDegreeOfParallelism = Debugger.IsAttached ? 1 : 4 }, i => + { + var inputItem = inputs[i]; + + var codeDocument = engine.Process(engine.FileSystem.GetItem(inputItem.FilePath, inputItem.FileKind)); + var csharpDocument = codeDocument.GetCSharpDocument(); + outputs[i] = new OutputItem(inputItem, csharpDocument); + }); + + return outputs; + } + + private struct OutputItem + { + public OutputItem( + SourceItem inputItem, + RazorCSharpDocument cSharpDocument) + { + InputItem = inputItem; + CSharpDocument = cSharpDocument; + } + + public SourceItem InputItem { get; } + + public RazorCSharpDocument CSharpDocument { get; } + } + + private readonly struct SourceItem + { + public SourceItem(string sourcePath, string outputPath, string physicalRelativePath, string fileKind) + { + SourcePath = sourcePath; + OutputPath = outputPath; + RelativePhysicalPath = physicalRelativePath; + FilePath = '/' + physicalRelativePath + .Replace(Path.DirectorySeparatorChar, '/') + .Replace("//", "/"); + FileKind = fileKind; + } + + public string SourcePath { get; } + + public string OutputPath { get; } + + public string RelativePhysicalPath { get; } + + public string FilePath { get; } + + public string FileKind { get; } + } + + private class StaticTagHelperFeature : ITagHelperFeature + { + public RazorEngine Engine { get; set; } + + public IReadOnlyList TagHelpers { get; set; } + + public IReadOnlyList GetDescriptors() => TagHelpers; + } + + private class SetSuppressPrimaryMethodBodyOptionFeature : RazorEngineFeatureBase, IConfigureRazorCodeGenerationOptionsFeature + { + public int Order { get; set; } + + public void Configure(RazorCodeGenerationOptionsBuilder options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + options.SuppressPrimaryMethodBody = true; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Memory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Memory.cs new file mode 100644 index 0000000000..e0187ed633 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Memory.cs @@ -0,0 +1,13 @@ +// 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.Razor.Tools +{ + internal static class Memory + { + public static bool IsMemoryAvailable() + { + return true; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MetadataCache.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MetadataCache.cs new file mode 100644 index 0000000000..b0f9fd025e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MetadataCache.cs @@ -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.Diagnostics; +using System.IO; +using System.Reflection.PortableExecutable; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class MetadataCache + { + // Store 1000 entries -- arbitrary number + private const int CacheSize = 1000; + private readonly ConcurrentLruCache _metadataCache = + new ConcurrentLruCache(CacheSize, StringComparer.OrdinalIgnoreCase); + + // For testing purposes only. + internal ConcurrentLruCache Cache => _metadataCache; + + internal Metadata GetMetadata(string fullPath) + { + var timestamp = GetFileTimeStamp(fullPath); + + // Check if we have an entry in the dictionary. + if (_metadataCache.TryGetValue(fullPath, out var entry)) + { + if (timestamp.HasValue && timestamp.Value == entry.Timestamp) + { + // The file has not changed since we cached it. Return the cached entry. + return entry.Metadata; + } + else + { + // The file has changed recently. Remove the cache entry. + _metadataCache.Remove(fullPath); + } + } + + Metadata metadata; + using (var fileStream = File.OpenRead(fullPath)) + { + metadata = AssemblyMetadata.CreateFromStream(fileStream, PEStreamOptions.PrefetchMetadata); + } + + _metadataCache.GetOrAdd(fullPath, new MetadataCacheEntry(timestamp.Value, metadata)); + + return metadata; + } + + private static DateTime? GetFileTimeStamp(string fullPath) + { + try + { + Debug.Assert(Path.IsPathRooted(fullPath)); + + return File.GetLastWriteTimeUtc(fullPath); + } + catch (Exception e) + { + // There are several exceptions that can occur here: NotSupportedException or PathTooLongException + // for a bad path, UnauthorizedAccessException for access denied, etc. Rather than listing them all, + // just catch all exceptions and log. + ServerLogger.LogException(e, $"Error getting timestamp of file {fullPath}."); + + return null; + } + } + + internal struct MetadataCacheEntry + { + public MetadataCacheEntry(DateTime timestamp, Metadata metadata) + { + Debug.Assert(timestamp.Kind == DateTimeKind.Utc); + + Timestamp = timestamp; + Metadata = metadata; + } + + public DateTime Timestamp { get; } + + public Metadata Metadata { get; } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MetadataReaderExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MetadataReaderExtensions.cs new file mode 100644 index 0000000000..17da6b63be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MetadataReaderExtensions.cs @@ -0,0 +1,94 @@ +// 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.Reflection; +using System.Reflection.Metadata; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class MetadataReaderExtensions + { + internal static AssemblyIdentity GetAssemblyIdentity(this MetadataReader reader) + { + if (!reader.IsAssembly) + { + throw new BadImageFormatException(); + } + + var definition = reader.GetAssemblyDefinition(); + + return CreateAssemblyIdentity( + reader, + definition.Version, + definition.Flags, + definition.PublicKey, + definition.Name, + definition.Culture, + isReference: false); + } + + internal static AssemblyIdentity[] GetReferencedAssembliesOrThrow(this MetadataReader reader) + { + var references = new List(); + + foreach (var referenceHandle in reader.AssemblyReferences) + { + var reference = reader.GetAssemblyReference(referenceHandle); + references.Add(CreateAssemblyIdentity( + reader, + reference.Version, + reference.Flags, + reference.PublicKeyOrToken, + reference.Name, + reference.Culture, + isReference: true)); + } + + return references.ToArray(); + } + + private static AssemblyIdentity CreateAssemblyIdentity( + MetadataReader reader, + Version version, + AssemblyFlags flags, + BlobHandle publicKey, + StringHandle name, + StringHandle culture, + bool isReference) + { + var publicKeyOrToken = reader.GetBlobContent(publicKey); + bool hasPublicKey; + + if (isReference) + { + hasPublicKey = (flags & AssemblyFlags.PublicKey) != 0; + } + else + { + // Assembly definitions never contain a public key token, they only can have a full key or nothing, + // so the flag AssemblyFlags.PublicKey does not make sense for them and is ignored. + // See Ecma-335, Partition II Metadata, 22.2 "Assembly : 0x20". + // This also corresponds to the behavior of the native C# compiler and sn.exe tool. + hasPublicKey = !publicKeyOrToken.IsEmpty; + } + + if (publicKeyOrToken.IsEmpty) + { + publicKeyOrToken = default; + } + + return new AssemblyIdentity( + name: reader.GetString(name), + version: version, + cultureName: culture.IsNil ? null : reader.GetString(culture), + publicKeyOrToken: publicKeyOrToken, + hasPublicKey: hasPublicKey, + isRetargetable: (flags & AssemblyFlags.Retargetable) != 0, + contentType: (AssemblyContentType)((int)(flags & AssemblyFlags.ContentTypeMask) >> 9)); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Microsoft.AspNetCore.Razor.Tools.csproj b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Microsoft.AspNetCore.Razor.Tools.csproj new file mode 100644 index 0000000000..ffda95c107 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Microsoft.AspNetCore.Razor.Tools.csproj @@ -0,0 +1,52 @@ + + + + Razor is a markup syntax for adding server-side logic to web pages. This assembly contains infrastructure supporting Razor MSBuild integration. + + + netcoreapp3.0 + Exe + rzc + + + false + false + false + + + false + + + + + Shared\TagHelperDescriptorJsonConverter.cs + + + Shared\RazorDiagnosticJsonConverter.cs + + + + + + + + + + + + + + + + + $(ProjectRuntimeConfigFileName) + PreserveNewest + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MutexName.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MutexName.cs new file mode 100644 index 0000000000..e12888080b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/MutexName.cs @@ -0,0 +1,22 @@ +// 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.Razor.Tools +{ + internal static class MutexName + { + public static string GetClientMutexName(string pipeName) + { + return $"{pipeName}.client"; + } + + public static string GetServerMutexName(string pipeName) + { + // We want to prefix this with Global\ because we want this mutex to be visible + // across terminal sessions which is useful for cases like shutdown. + // https://msdn.microsoft.com/en-us/library/system.threading.mutex(v=vs.110).aspx#Remarks + // This still wouldn't allow other users to access the server because the pipe will fail to connect. + return $"Global\\{pipeName}.server"; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/PipeName.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/PipeName.cs new file mode 100644 index 0000000000..23fc72f90c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/PipeName.cs @@ -0,0 +1,60 @@ +// 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.Security.Cryptography; +using System.Text; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class PipeName + { + // We want each pipe to unique and predictable based on the inputs of: + // - user (security) + // - path of tool on disk (version) + // + // This allows us to meet the security and version compat requirements just by selecting a pipe name. + // + // This is similar to (and based on) the code used by Roslyn in VBCSCompiler: + // https://github.com/dotnet/roslyn/blob/c273b6a9f19570a344c274ae89185b3a2b64d93d/src/Compilers/Shared/BuildServerConnection.cs#L528 + public static string ComputeDefault(string toolDirectory = null) + { + if (string.IsNullOrEmpty(toolDirectory)) + { + // This can be null in cases where we don't have a way of knowing the tool assembly path like when someone manually + // invokes the cli tool without passing in a pipe name as argument. + toolDirectory = AppDomain.CurrentDomain.BaseDirectory; + } + + // Include a prefix so we can't conflict with VBCSCompiler if we somehow end up in the same directory. + // That would be a pretty wacky bug to try and unravel. + var baseName = ComputeBaseName("Razor:" + toolDirectory); + + // Prefix with username + var userName = Environment.UserName; + if (userName == null) + { + return null; + } + + return $"{userName}.{baseName}"; + } + + private static string ComputeBaseName(string baseDirectory) + { + // Normalize away trailing slashes. File APIs are not consistent about including it, so it's + // best to normalize and avoid ending up with two servers running accidentally. + baseDirectory = baseDirectory.TrimEnd(Path.DirectorySeparatorChar); + + using (var sha = SHA256.Create()) + { + var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(baseDirectory)); + return Convert.ToBase64String(bytes) + .Substring(0, 25) // We only have ~50 total characters on Mac, so strip that down + .Replace("/", "_") + .Replace("=", string.Empty); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Program.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Program.cs new file mode 100644 index 0000000000..3cd93a2335 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Program.cs @@ -0,0 +1,53 @@ +// 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.Threading; +using Microsoft.CodeAnalysis; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class Program + { + public static int Main(string[] args) + { + DebugMode.HandleDebugSwitch(ref args); + + var cancel = new CancellationTokenSource(); + Console.CancelKeyPress += (sender, e) => { cancel.Cancel(); }; + + var outputWriter = new StringWriter(); + var errorWriter = new StringWriter(); + + // Prevent shadow copying. + var loader = new DefaultExtensionAssemblyLoader(baseDirectory: null); + var checker = new DefaultExtensionDependencyChecker(loader, outputWriter, errorWriter); + + var application = new Application( + cancel.Token, + loader, + checker, + (path, properties) => MetadataReference.CreateFromFile(path, properties), + outputWriter, + errorWriter); + + var result = application.Execute(args); + + var output = outputWriter.ToString(); + var error = errorWriter.ToString(); + + outputWriter.Dispose(); + errorWriter.Dispose(); + + Console.Write(output); + Console.Error.Write(error); + + // This will no-op if server logging is not enabled. + ServerLogger.Log(output); + ServerLogger.Log(error); + + return result; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3770a8065e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// 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("Microsoft.AspNetCore.Razor.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/RequestDispatcher.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/RequestDispatcher.cs new file mode 100644 index 0000000000..1b46d1cbf7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/RequestDispatcher.cs @@ -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 System.Threading; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal abstract class RequestDispatcher + { + /// + /// Default time the server will stay alive after the last request disconnects. + /// + public static readonly TimeSpan DefaultServerKeepAlive = TimeSpan.FromMinutes(10); + + /// + /// Time to delay after the last connection before initiating a garbage collection + /// in the server. + /// + public static readonly TimeSpan GCTimeout = TimeSpan.FromSeconds(30); + + public abstract void Run(); + + public static RequestDispatcher Create(ConnectionHost connectionHost, CompilerHost compilerHost, CancellationToken cancellationToken, EventBus eventBus, TimeSpan? keepAlive = null) + { + return new DefaultRequestDispatcher(connectionHost, compilerHost, cancellationToken, eventBus, keepAlive); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerCommand.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerCommand.cs new file mode 100644 index 0000000000..a4aee01b3d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerCommand.cs @@ -0,0 +1,188 @@ +// 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.Diagnostics; +using System.IO; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class ServerCommand : CommandBase + { + public ServerCommand(Application parent) + : base(parent, "server") + { + Pipe = Option("-p|--pipe", "name of named pipe", CommandOptionType.SingleValue); + KeepAlive = Option("-k|--keep-alive", "sets the default idle timeout for the server in seconds", CommandOptionType.SingleValue); + } + + // For testing purposes only. + internal ServerCommand(Application parent, string pipeName, int? keepAlive = null) + : this(parent) + { + if (!string.IsNullOrEmpty(pipeName)) + { + Pipe.Values.Add(pipeName); + } + + if (keepAlive.HasValue) + { + KeepAlive.Values.Add(keepAlive.Value.ToString()); + } + } + + public CommandOption Pipe { get; } + + public CommandOption KeepAlive { get; } + + protected override bool ValidateArguments() + { + if (string.IsNullOrEmpty(Pipe.Value())) + { + Pipe.Values.Add(PipeName.ComputeDefault()); + } + + return true; + } + + protected override Task ExecuteCoreAsync() + { + // Make sure there's only one server with the same identity at a time. + var serverMutexName = MutexName.GetServerMutexName(Pipe.Value()); + Mutex serverMutex = null; + var holdsMutex = false; + + try + { + serverMutex = new Mutex(initiallyOwned: true, name: serverMutexName, createdNew: out holdsMutex); + } + catch (Exception ex) + { + // The Mutex constructor can throw in certain cases. One specific example is docker containers + // where the /tmp directory is restricted. In those cases there is no reliable way to execute + // the server and we need to fall back to the command line. + // Example: https://github.com/dotnet/roslyn/issues/24124 + + Error.Write($"Server mutex creation failed. {ex.Message}"); + + return Task.FromResult(-1); + } + + if (!holdsMutex) + { + // Another server is running, just exit. + Error.Write("Another server already running..."); + return Task.FromResult(1); + } + + FileStream pidFileStream = null; + try + { + try + { + // Write the process and pipe information to a file in a well-known location. + pidFileStream = WritePidFile(); + } + catch (Exception ex) + { + // Something happened when trying to write to the pid file. Log and move on. + ServerLogger.LogException(ex, "Failed to create PID file."); + } + + TimeSpan? keepAlive = null; + if (KeepAlive.HasValue() && int.TryParse(KeepAlive.Value(), out var result)) + { + // Keep alive times are specified in seconds + keepAlive = TimeSpan.FromSeconds(result); + } + + var host = ConnectionHost.Create(Pipe.Value()); + + var compilerHost = CompilerHost.Create(); + ExecuteServerCore(host, compilerHost, Cancelled, eventBus: null, keepAlive: keepAlive); + } + finally + { + serverMutex.ReleaseMutex(); + serverMutex.Dispose(); + pidFileStream?.Close(); + } + + return Task.FromResult(0); + } + + protected virtual void ExecuteServerCore(ConnectionHost host, CompilerHost compilerHost, CancellationToken cancellationToken, EventBus eventBus, TimeSpan? keepAlive) + { + var dispatcher = RequestDispatcher.Create(host, compilerHost, cancellationToken, eventBus, keepAlive); + dispatcher.Run(); + } + + protected virtual FileStream WritePidFile() + { + var path = GetPidFilePath(env => Environment.GetEnvironmentVariable(env)); + return WritePidFile(path); + } + + // Internal for testing. + internal virtual FileStream WritePidFile(string directoryPath) + { + if (string.IsNullOrEmpty(directoryPath)) + { + // Invalid path. Bail. + return null; + } + + // To make all the running rzc servers more discoverable, We want to write the process Id and pipe name to a file. + // The file contents will be in the following format, + // + // + // rzc + // path/to/rzc.dll + // + + const int DefaultBufferSize = 4096; + var processId = Process.GetCurrentProcess().Id; + var fileName = $"rzc-{processId}"; + + // Make sure the directory exists. + Directory.CreateDirectory(directoryPath); + + var path = Path.Combine(directoryPath, fileName); + var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, DefaultBufferSize, FileOptions.DeleteOnClose); + + using (var writer = new StreamWriter(fileStream, Encoding.UTF8, DefaultBufferSize, leaveOpen: true)) + { + var rzcPath = Assembly.GetExecutingAssembly().Location; + var content = $"{processId}{Environment.NewLine}rzc{Environment.NewLine}{rzcPath}{Environment.NewLine}{Pipe.Value()}"; + writer.Write(content); + } + + return fileStream; + } + + // Internal for testing. + internal virtual string GetPidFilePath(Func getEnvironmentVariable) + { + var path = getEnvironmentVariable("DOTNET_BUILD_PIDFILE_DIRECTORY"); + if (string.IsNullOrEmpty(path)) + { + var homeEnvVariable = PlatformInformation.IsWindows ? "USERPROFILE" : "HOME"; + var homePath = getEnvironmentVariable(homeEnvVariable); + if (string.IsNullOrEmpty(homePath)) + { + // Couldn't locate the user profile directory. Bail. + return null; + } + + path = Path.Combine(homePath, ".dotnet", "pids", "build"); + } + + return path; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/CompletedServerResponse.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/CompletedServerResponse.cs new file mode 100644 index 0000000000..98a64dba8f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/CompletedServerResponse.cs @@ -0,0 +1,58 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// Represents a Response from the server. A response is as follows. + /// + /// Field Name Type Size (bytes) + /// -------------------------------------------------- + /// Length UInteger 4 + /// ReturnCode Integer 4 + /// Output String Variable + /// ErrorOutput String Variable + /// + /// Strings are encoded via a character count prefix as a + /// 32-bit integer, followed by an array of characters. + /// + /// + internal sealed class CompletedServerResponse : ServerResponse + { + public readonly int ReturnCode; + public readonly bool Utf8Output; + public readonly string Output; + public readonly string ErrorOutput; + + public CompletedServerResponse(int returnCode, bool utf8output, string output, string error) + { + ReturnCode = returnCode; + Utf8Output = utf8output; + Output = output; + ErrorOutput = error; + } + + public override ResponseType Type => ResponseType.Completed; + + public static CompletedServerResponse Create(BinaryReader reader) + { + var returnCode = reader.ReadInt32(); + var utf8Output = reader.ReadBoolean(); + var output = ServerProtocol.ReadLengthPrefixedString(reader); + var errorOutput = ServerProtocol.ReadLengthPrefixedString(reader); + + return new CompletedServerResponse(returnCode, utf8Output, output, errorOutput); + } + + protected override void AddResponseBody(BinaryWriter writer) + { + writer.Write(ReturnCode); + writer.Write(Utf8Output); + ServerProtocol.WriteLengthPrefixedString(writer, Output); + ServerProtocol.WriteLengthPrefixedString(writer, ErrorOutput); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/MismatchedVersionServerResponse.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/MismatchedVersionServerResponse.cs new file mode 100644 index 0000000000..57293797e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/MismatchedVersionServerResponse.cs @@ -0,0 +1,17 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal sealed class MismatchedVersionServerResponse : ServerResponse + { + public override ResponseType Type => ResponseType.MismatchedVersion; + + /// + /// MismatchedVersion has no body. + /// + protected override void AddResponseBody(BinaryWriter writer) { } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/NativeMethods.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/NativeMethods.cs new file mode 100644 index 0000000000..73a7363ecb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/NativeMethods.cs @@ -0,0 +1,89 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + internal struct STARTUPINFO + { + internal Int32 cb; + internal string lpReserved; + internal string lpDesktop; + internal string lpTitle; + internal Int32 dwX; + internal Int32 dwY; + internal Int32 dwXSize; + internal Int32 dwYSize; + internal Int32 dwXCountChars; + internal Int32 dwYCountChars; + internal Int32 dwFillAttribute; + internal Int32 dwFlags; + internal Int16 wShowWindow; + internal Int16 cbReserved2; + internal IntPtr lpReserved2; + internal IntPtr hStdInput; + internal IntPtr hStdOutput; + internal IntPtr hStdError; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct PROCESS_INFORMATION + { + public IntPtr hProcess; + public IntPtr hThread; + public int dwProcessId; + public int dwThreadId; + } + + /// + /// Interop methods. + /// + internal static class NativeMethods + { + #region Constants + + internal static readonly IntPtr NullPtr = IntPtr.Zero; + internal static readonly IntPtr InvalidIntPtr = new IntPtr((int)-1); + + internal const uint NORMAL_PRIORITY_CLASS = 0x0020; + internal const uint CREATE_NO_WINDOW = 0x08000000; + internal const Int32 STARTF_USESTDHANDLES = 0x00000100; + internal const int ERROR_SUCCESS = 0; + + #endregion + + //------------------------------------------------------------------------------ + // CloseHandle + //------------------------------------------------------------------------------ + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool CloseHandle(IntPtr hObject); + + //------------------------------------------------------------------------------ + // CreateProcess + //------------------------------------------------------------------------------ + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool CreateProcess + ( + string lpApplicationName, + [In, Out]StringBuilder lpCommandLine, + IntPtr lpProcessAttributes, + IntPtr lpThreadAttributes, + [In, MarshalAs(UnmanagedType.Bool)] + bool bInheritHandles, + uint dwCreationFlags, + IntPtr lpEnvironment, + string lpCurrentDirectory, + [In] ref STARTUPINFO lpStartupInfo, + out PROCESS_INFORMATION lpProcessInformation + ); + + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + internal static extern IntPtr GetCommandLine(); + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/RejectedServerResponse.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/RejectedServerResponse.cs new file mode 100644 index 0000000000..2b6e3e894b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/RejectedServerResponse.cs @@ -0,0 +1,17 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal sealed class RejectedServerResponse : ServerResponse + { + public override ResponseType Type => ResponseType.Rejected; + + /// + /// RejectedResponse has no body. + /// + protected override void AddResponseBody(BinaryWriter writer) { } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/RequestArgument.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/RequestArgument.cs new file mode 100644 index 0000000000..96e9ae0312 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/RequestArgument.cs @@ -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.IO; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// A command line argument to the compilation. + /// An argument is formatted as follows: + /// + /// Field Name Type Size (bytes) + /// -------------------------------------------------- + /// ID UInteger 4 + /// Index UInteger 4 + /// Value String Variable + /// + /// Strings are encoded via a length prefix as a signed + /// 32-bit integer, followed by an array of characters. + /// + internal readonly struct RequestArgument + { + public readonly ArgumentId Id; + public readonly int ArgumentIndex; + public readonly string Value; + + public RequestArgument(ArgumentId argumentId, int argumentIndex, string value) + { + Id = argumentId; + ArgumentIndex = argumentIndex; + Value = value; + } + + public static RequestArgument ReadFromBinaryReader(BinaryReader reader) + { + var argId = (ArgumentId)reader.ReadInt32(); + var argIndex = reader.ReadInt32(); + var value = ServerProtocol.ReadLengthPrefixedString(reader); + return new RequestArgument(argId, argIndex, value); + } + + public void WriteToBinaryWriter(BinaryWriter writer) + { + writer.Write((int)Id); + writer.Write(ArgumentIndex); + ServerProtocol.WriteLengthPrefixedString(writer, Value); + } + + public enum ArgumentId + { + // The current directory of the client + CurrentDirectory = 0x51147221, + + // A comment line argument. The argument index indicates which one (0 .. N) + CommandLineArgument, + + // Request a longer keep alive time for the server + KeepAlive, + + // Request a server shutdown from the client + Shutdown, + + // The directory to use for temporary operations. + TempDirectory, + } + + public override string ToString() + { + return $"{Id} {Value}"; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerConnection.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerConnection.cs new file mode 100644 index 0000000000..d254be4e60 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerConnection.cs @@ -0,0 +1,390 @@ +// 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.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class ServerConnection + { + private const string ServerName = "rzc.dll"; + + // Spend up to 1s connecting to existing process (existing processes should be always responsive). + private const int TimeOutMsExistingProcess = 1000; + + // Spend up to 20s connecting to a new process, to allow time for it to start. + private const int TimeOutMsNewProcess = 20000; + + // Custom delegate that contains an out param to use with TryCreateServerCore method. + private delegate TResult TryCreateServerCoreDelegate(T1 arg1, T2 arg2, out T3 arg3, T4 arg4); + + public static bool WasServerMutexOpen(string mutexName) + { + Mutex mutex = null; + var open = false; + try + { + open = Mutex.TryOpenExisting(mutexName, out mutex); + } + catch + { + // In the case an exception occurred trying to open the Mutex then + // the assumption is that it's not open. + } + + mutex?.Dispose(); + + return open; + } + + /// + /// Gets the value of the temporary path for the current environment assuming the working directory + /// is . This function must emulate as + /// closely as possible. + /// + public static string GetTempPath(string workingDir) + { + if (PlatformInformation.IsUnix) + { + // Unix temp path is fine: it does not use the working directory + // (it uses ${TMPDIR} if set, otherwise, it returns /tmp) + return Path.GetTempPath(); + } + + var tmp = Environment.GetEnvironmentVariable("TMP"); + if (Path.IsPathRooted(tmp)) + { + return tmp; + } + + var temp = Environment.GetEnvironmentVariable("TEMP"); + if (Path.IsPathRooted(temp)) + { + return temp; + } + + if (!string.IsNullOrEmpty(workingDir)) + { + if (!string.IsNullOrEmpty(tmp)) + { + return Path.Combine(workingDir, tmp); + } + + if (!string.IsNullOrEmpty(temp)) + { + return Path.Combine(workingDir, temp); + } + } + + var userProfile = Environment.GetEnvironmentVariable("USERPROFILE"); + if (Path.IsPathRooted(userProfile)) + { + return userProfile; + } + + return Environment.GetEnvironmentVariable("SYSTEMROOT"); + } + + public static Task RunOnServer( + string pipeName, + IList arguments, + ServerPaths serverPaths, + CancellationToken cancellationToken, + string keepAlive = null, + bool debug = false) + { + if (string.IsNullOrEmpty(pipeName)) + { + pipeName = PipeName.ComputeDefault(serverPaths.ClientDirectory); + } + + return RunOnServerCore( + arguments, + serverPaths, + pipeName: pipeName, + keepAlive: keepAlive, + timeoutOverride: null, + tryCreateServerFunc: TryCreateServerCore, + cancellationToken: cancellationToken, + debug: debug); + } + + private static async Task RunOnServerCore( + IList arguments, + ServerPaths serverPaths, + string pipeName, + string keepAlive, + int? timeoutOverride, + TryCreateServerCoreDelegate tryCreateServerFunc, + CancellationToken cancellationToken, + bool debug) + { + if (pipeName == null) + { + return new RejectedServerResponse(); + } + + if (serverPaths.TempDirectory == null) + { + return new RejectedServerResponse(); + } + + var clientDir = serverPaths.ClientDirectory; + var timeoutNewProcess = timeoutOverride ?? TimeOutMsNewProcess; + var timeoutExistingProcess = timeoutOverride ?? TimeOutMsExistingProcess; + var clientMutexName = MutexName.GetClientMutexName(pipeName); + Task pipeTask = null; + + Mutex clientMutex = null; + var holdsMutex = false; + + try + { + try + { + clientMutex = new Mutex(initiallyOwned: true, name: clientMutexName, createdNew: out holdsMutex); + } + catch (Exception ex) + { + // The Mutex constructor can throw in certain cases. One specific example is docker containers + // where the /tmp directory is restricted. In those cases there is no reliable way to execute + // the server and we need to fall back to the command line. + // Example: https://github.com/dotnet/roslyn/issues/24124 + + ServerLogger.LogException(ex, "Client mutex creation failed."); + + return new RejectedServerResponse(); + } + + if (!holdsMutex) + { + try + { + holdsMutex = clientMutex.WaitOne(timeoutNewProcess); + + if (!holdsMutex) + { + return new RejectedServerResponse(); + } + } + catch (AbandonedMutexException) + { + holdsMutex = true; + } + } + + // Check for an already running server + var serverMutexName = MutexName.GetServerMutexName(pipeName); + var wasServerRunning = WasServerMutexOpen(serverMutexName); + var timeout = wasServerRunning ? timeoutExistingProcess : timeoutNewProcess; + + if (wasServerRunning || tryCreateServerFunc(clientDir, pipeName, out var _, debug)) + { + pipeTask = Client.ConnectAsync(pipeName, TimeSpan.FromMilliseconds(timeout), cancellationToken); + } + } + finally + { + if (holdsMutex) + { + clientMutex?.ReleaseMutex(); + } + + clientMutex?.Dispose(); + } + + if (pipeTask != null) + { + var client = await pipeTask.ConfigureAwait(false); + if (client != null) + { + var request = ServerRequest.Create( + serverPaths.WorkingDirectory, + serverPaths.TempDirectory, + arguments, + keepAlive); + + return await TryProcessRequest(client, request, cancellationToken).ConfigureAwait(false); + } + } + + return new RejectedServerResponse(); + } + + /// + /// Try to process the request using the server. Returns a null-containing Task if a response + /// from the server cannot be retrieved. + /// + private static async Task TryProcessRequest( + Client client, + ServerRequest request, + CancellationToken cancellationToken) + { + ServerResponse response; + using (client) + { + // Write the request + try + { + ServerLogger.Log("Begin writing request"); + await request.WriteAsync(client.Stream, cancellationToken).ConfigureAwait(false); + ServerLogger.Log("End writing request"); + } + catch (Exception e) + { + ServerLogger.LogException(e, "Error writing build request."); + return new RejectedServerResponse(); + } + + // Wait for the compilation and a monitor to detect if the server disconnects + var serverCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + + ServerLogger.Log("Begin reading response"); + + var responseTask = ServerResponse.ReadAsync(client.Stream, serverCts.Token); + var monitorTask = client.WaitForDisconnectAsync(serverCts.Token); + await Task.WhenAny(responseTask, monitorTask).ConfigureAwait(false); + + ServerLogger.Log("End reading response"); + + if (responseTask.IsCompleted) + { + // await the task to log any exceptions + try + { + response = await responseTask.ConfigureAwait(false); + } + catch (Exception e) + { + ServerLogger.LogException(e, "Error reading response"); + response = new RejectedServerResponse(); + } + } + else + { + ServerLogger.Log("Server disconnect"); + response = new RejectedServerResponse(); + } + + // Cancel whatever task is still around + serverCts.Cancel(); + Debug.Assert(response != null); + return response; + } + } + + // Internal for testing. + internal static bool TryCreateServerCore(string clientDir, string pipeName, out int? processId, bool debug = false) + { + processId = null; + + // The server should be in the same directory as the client + var expectedCompilerPath = Path.Combine(clientDir, ServerName); + var expectedPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet"; + var argumentList = new string[] + { + expectedCompilerPath, + debug ? "--debug" : "", + "server", + "-p", + pipeName + }; + var processArguments = ArgumentEscaper.EscapeAndConcatenate(argumentList); + + if (!File.Exists(expectedCompilerPath)) + { + return false; + } + + if (PlatformInformation.IsWindows) + { + // Currently, there isn't a way to use the Process class to create a process without + // inheriting handles(stdin/stdout/stderr) from its parent. This might cause the parent process + // to block on those handles. So we use P/Invoke. This code was taken from MSBuild task starting code. + // The work to customize this behavior is being tracked by https://github.com/dotnet/corefx/issues/306. + + var startInfo = new STARTUPINFO(); + startInfo.cb = Marshal.SizeOf(startInfo); + startInfo.hStdError = NativeMethods.InvalidIntPtr; + startInfo.hStdInput = NativeMethods.InvalidIntPtr; + startInfo.hStdOutput = NativeMethods.InvalidIntPtr; + startInfo.dwFlags = NativeMethods.STARTF_USESTDHANDLES; + var dwCreationFlags = NativeMethods.NORMAL_PRIORITY_CLASS | NativeMethods.CREATE_NO_WINDOW; + + ServerLogger.Log("Attempting to create process '{0}'", expectedPath); + + var builder = new StringBuilder($@"""{expectedPath}"" {processArguments}"); + + var success = NativeMethods.CreateProcess( + lpApplicationName: null, + lpCommandLine: builder, + lpProcessAttributes: NativeMethods.NullPtr, + lpThreadAttributes: NativeMethods.NullPtr, + bInheritHandles: false, + dwCreationFlags: dwCreationFlags, + lpEnvironment: NativeMethods.NullPtr, // Inherit environment + lpCurrentDirectory: clientDir, + lpStartupInfo: ref startInfo, + lpProcessInformation: out var processInfo); + + if (success) + { + ServerLogger.Log("Successfully created process with process id {0}", processInfo.dwProcessId); + NativeMethods.CloseHandle(processInfo.hProcess); + NativeMethods.CloseHandle(processInfo.hThread); + processId = processInfo.dwProcessId; + } + else + { + ServerLogger.Log("Failed to create process. GetLastError={0}", Marshal.GetLastWin32Error()); + } + return success; + } + else + { + try + { + var startInfo = new ProcessStartInfo() + { + FileName = expectedPath, + Arguments = processArguments, + UseShellExecute = false, + WorkingDirectory = clientDir, + RedirectStandardInput = true, + RedirectStandardOutput = true, + RedirectStandardError = true, + CreateNoWindow = true + }; + + var process = Process.Start(startInfo); + processId = process.Id; + + return true; + } + catch + { + return false; + } + } + } + } + + /// + /// This class provides simple properties for determining whether the current platform is Windows or Unix-based. + /// We intentionally do not use System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(...) because + /// it incorrectly reports 'true' for 'Windows' in desktop builds running on Unix-based platforms via Mono. + /// + internal static class PlatformInformation + { + public static bool IsWindows => Path.DirectorySeparatorChar == '\\'; + public static bool IsUnix => Path.DirectorySeparatorChar == '/'; + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerLogger.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerLogger.cs new file mode 100644 index 0000000000..2e38fc60c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerLogger.cs @@ -0,0 +1,146 @@ +// 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.Diagnostics; +using System.IO; +using System.Text; +using System.Threading; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// Class for logging information about what happens in the server and client parts of the + /// Razor command line compiler and build tasks. Useful for debugging what is going on. + /// + /// + /// To use the logging, set the environment variable RAZORBUILDSERVER_LOG to the name + /// of a file to log to. This file is logged to by both client and server components. + /// + internal class ServerLogger + { + // Environment variable, if set, to enable logging and set the file to log to. + private const string EnvironmentVariable = "RAZORBUILDSERVER_LOG"; + + private static readonly Stream s_loggingStream; + private static string s_prefix = "---"; + + /// + /// Static class initializer that initializes logging. + /// + static ServerLogger() + { + s_loggingStream = null; + + try + { + // Check if the environment + var loggingFileName = Environment.GetEnvironmentVariable(EnvironmentVariable); + + if (loggingFileName != null) + { + IsLoggingEnabled = true; + + // If the environment variable contains the path of a currently existing directory, + // then use a process-specific name for the log file and put it in that directory. + // Otherwise, assume that the environment variable specifies the name of the log file. + if (Directory.Exists(loggingFileName)) + { + loggingFileName = Path.Combine(loggingFileName, $"razorserver.{GetCurrentProcessId()}.log"); + } + + // Open allowing sharing. We allow multiple processes to log to the same file, so we use share mode to allow that. + s_loggingStream = new FileStream(loggingFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); + } + } + catch (Exception e) + { + LogException(e, "Failed to create logging stream"); + } + } + + public static bool IsLoggingEnabled { get; } + + /// + /// Set the logging prefix that describes our role. + /// Typically a 3-letter abbreviation. If logging happens before this, it's logged with "---". + /// + public static void Initialize(string outputPrefix) + { + s_prefix = outputPrefix; + } + + /// + /// Log an exception. Also logs information about inner exceptions. + /// + public static void LogException(Exception e, string reason) + { + if (IsLoggingEnabled) + { + Log("Exception '{0}' occurred during '{1}'. Stack trace:\r\n{2}", e.Message, reason, e.StackTrace); + + var innerExceptionLevel = 0; + + e = e.InnerException; + while (e != null) + { + Log("Inner exception[{0}] '{1}'. Stack trace: \r\n{1}", innerExceptionLevel, e.Message, e.StackTrace); + e = e.InnerException; + innerExceptionLevel += 1; + } + } + } + + /// + /// Log a line of text to the logging file, with string.Format arguments. + /// + public static void Log(string format, params object[] arguments) + { + if (IsLoggingEnabled) + { + Log(string.Format(format, arguments)); + } + } + + /// + /// Log a line of text to the logging file. + /// + /// + public static void Log(string message) + { + if (IsLoggingEnabled) + { + var prefix = GetLoggingPrefix(); + + var output = prefix + message + "\r\n"; + var bytes = Encoding.UTF8.GetBytes(output); + + // Because multiple processes might be logging to the same file, we always seek to the end, + // write, and flush. + s_loggingStream.Seek(0, SeekOrigin.End); + s_loggingStream.Write(bytes, 0, bytes.Length); + s_loggingStream.Flush(); + } + } + + private static int GetCurrentProcessId() + { + var process = Process.GetCurrentProcess(); + return process.Id; + } + + private static int GetCurrentThreadId() + { + var thread = Thread.CurrentThread; + return thread.ManagedThreadId; + } + + /// + /// Get the string that prefixes all log entries. Shows the process, thread, and time. + /// + private static string GetLoggingPrefix() + { + return string.Format("{0} PID={1} TID={2} Ticks={3}: ", s_prefix, GetCurrentProcessId(), GetCurrentThreadId(), Environment.TickCount); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerPaths.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerPaths.cs new file mode 100644 index 0000000000..37cd4a58c4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerPaths.cs @@ -0,0 +1,33 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal struct ServerPaths + { + internal ServerPaths(string clientDir, string workingDir, string tempDir) + { + ClientDirectory = clientDir; + WorkingDirectory = workingDir; + TempDirectory = tempDir; + } + + /// + /// The path which contains the Razor compiler binaries and response files. + /// + internal string ClientDirectory { get; } + + /// + /// The path in which the Razor compilation takes place. + /// + internal string WorkingDirectory { get; } + + /// + /// The temporary directory a compilation should use instead of . The latter + /// relies on global state individual compilations should ignore. + /// + internal string TempDirectory { get; } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerProtocol.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerProtocol.cs new file mode 100644 index 0000000000..940dda2845 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerProtocol.cs @@ -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.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class ServerProtocol + { + /// + /// The version number for this protocol. + /// + public static readonly uint ProtocolVersion = 2; + + /// + /// Read a string from the Reader where the string is encoded + /// as a length prefix (signed 32-bit integer) followed by + /// a sequence of characters. + /// + public static string ReadLengthPrefixedString(BinaryReader reader) + { + var length = reader.ReadInt32(); + return new string(reader.ReadChars(length)); + } + + /// + /// Write a string to the Writer where the string is encoded + /// as a length prefix (signed 32-bit integer) follows by + /// a sequence of characters. + /// + public static void WriteLengthPrefixedString(BinaryWriter writer, string value) + { + writer.Write(value.Length); + writer.Write(value.ToCharArray()); + } + + /// + /// This task does not complete until we are completely done reading. + /// + internal static async Task ReadAllAsync( + Stream stream, + byte[] buffer, + int count, + CancellationToken cancellationToken) + { + var totalBytesRead = 0; + do + { + ServerLogger.Log("Attempting to read {0} bytes from the stream", count - totalBytesRead); + var bytesRead = await stream.ReadAsync( + buffer, + totalBytesRead, + count - totalBytesRead, + cancellationToken) + .ConfigureAwait(false); + + if (bytesRead == 0) + { + ServerLogger.Log("Unexpected -- read 0 bytes from the stream."); + throw new EndOfStreamException("Reached end of stream before end of read."); + } + ServerLogger.Log("Read {0} bytes", bytesRead); + totalBytesRead += bytesRead; + } while (totalBytesRead < count); + ServerLogger.Log("Finished read"); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerRequest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerRequest.cs new file mode 100644 index 0000000000..34b6a39eb9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerRequest.cs @@ -0,0 +1,216 @@ +// 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.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +// After the server pipe is connected, it forks off a thread to handle the connection, and creates +// a new instance of the pipe to listen for new clients. When it gets a request, it validates +// the security and elevation level of the client. If that fails, it disconnects the client. Otherwise, +// it handles the request, sends a response (described by Response class) back to the client, then +// disconnects the pipe and ends the thread. +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// Represents a request from the client. A request is as follows. + /// + /// Field Name Type Size (bytes) + /// ---------------------------------------------------- + /// Length Integer 4 + /// Argument Count UInteger 4 + /// Arguments Argument[] Variable + /// + /// See for the format of an + /// Argument. + /// + /// + internal class ServerRequest + { + public ServerRequest(uint protocolVersion, IEnumerable arguments) + { + ProtocolVersion = protocolVersion; + Arguments = new ReadOnlyCollection(arguments.ToList()); + + if (Arguments.Count > ushort.MaxValue) + { + throw new ArgumentOutOfRangeException( + nameof(arguments), + $"Too many arguments: maximum of {ushort.MaxValue} arguments allowed."); + } + } + + public uint ProtocolVersion { get; } + + public ReadOnlyCollection Arguments { get; } + + public TimeSpan? KeepAlive + { + get + { + TimeSpan? keepAlive = null; + foreach (var argument in Arguments) + { + if (argument.Id == RequestArgument.ArgumentId.KeepAlive) + { + // If the value is not a valid integer for any reason, ignore it and continue with the current timeout. + // The client is responsible for validating the argument. + if (int.TryParse(argument.Value, out var result)) + { + // Keep alive times are specified in seconds + keepAlive = TimeSpan.FromSeconds(result); + } + } + } + + return keepAlive; + } + } + + public bool IsShutdownRequest() + { + return Arguments.Count >= 1 && Arguments[0].Id == RequestArgument.ArgumentId.Shutdown; + } + + public static ServerRequest Create( + string workingDirectory, + string tempDirectory, + IList args, + string keepAlive = null) + { + ServerLogger.Log("Creating ServerRequest"); + ServerLogger.Log($"Working directory: {workingDirectory}"); + ServerLogger.Log($"Temp directory: {tempDirectory}"); + + var requestLength = args.Count + 1; + var requestArgs = new List(requestLength) + { + new RequestArgument(RequestArgument.ArgumentId.CurrentDirectory, 0, workingDirectory), + new RequestArgument(RequestArgument.ArgumentId.TempDirectory, 0, tempDirectory) + }; + + if (keepAlive != null) + { + requestArgs.Add(new RequestArgument(RequestArgument.ArgumentId.KeepAlive, 0, keepAlive)); + } + + for (var i = 0; i < args.Count; ++i) + { + var arg = args[i]; + ServerLogger.Log($"argument[{i}] = {arg}"); + requestArgs.Add(new RequestArgument(RequestArgument.ArgumentId.CommandLineArgument, i, arg)); + } + + return new ServerRequest(ServerProtocol.ProtocolVersion, requestArgs); + } + + public static ServerRequest CreateShutdown() + { + var requestArgs = new[] + { + new RequestArgument(RequestArgument.ArgumentId.Shutdown, argumentIndex: 0, value: ""), + new RequestArgument(RequestArgument.ArgumentId.CommandLineArgument, argumentIndex: 1, value: "shutdown"), + }; + return new ServerRequest(ServerProtocol.ProtocolVersion, requestArgs); + } + + /// + /// Read a Request from the given stream. + /// + /// The total request size must be less than 1MB. + /// + /// null if the Request was too large, the Request otherwise. + public static async Task ReadAsync(Stream inStream, CancellationToken cancellationToken) + { + // Read the length of the request + var lengthBuffer = new byte[4]; + ServerLogger.Log("Reading length of request"); + await ServerProtocol.ReadAllAsync(inStream, lengthBuffer, 4, cancellationToken).ConfigureAwait(false); + var length = BitConverter.ToInt32(lengthBuffer, 0); + + // Back out if the request is > 1MB + if (length > 0x100000) + { + ServerLogger.Log("Request is over 1MB in length, cancelling read."); + return null; + } + + cancellationToken.ThrowIfCancellationRequested(); + + // Read the full request + var requestBuffer = new byte[length]; + await ServerProtocol.ReadAllAsync(inStream, requestBuffer, length, cancellationToken).ConfigureAwait(false); + + cancellationToken.ThrowIfCancellationRequested(); + + ServerLogger.Log("Parsing request"); + // Parse the request into the Request data structure. + using (var reader = new BinaryReader(new MemoryStream(requestBuffer), Encoding.Unicode)) + { + var protocolVersion = reader.ReadUInt32(); + var argumentCount = reader.ReadUInt32(); + + var argumentsBuilder = new List((int)argumentCount); + + for (var i = 0; i < argumentCount; i++) + { + cancellationToken.ThrowIfCancellationRequested(); + argumentsBuilder.Add(RequestArgument.ReadFromBinaryReader(reader)); + } + + return new ServerRequest(protocolVersion, argumentsBuilder); + } + } + + /// + /// Write a Request to the stream. + /// + public async Task WriteAsync(Stream outStream, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var memoryStream = new MemoryStream()) + using (var writer = new BinaryWriter(memoryStream, Encoding.Unicode)) + { + // Format the request. + ServerLogger.Log("Formatting request"); + writer.Write(ProtocolVersion); + writer.Write(Arguments.Count); + foreach (var arg in Arguments) + { + cancellationToken.ThrowIfCancellationRequested(); + arg.WriteToBinaryWriter(writer); + } + writer.Flush(); + + cancellationToken.ThrowIfCancellationRequested(); + + // Write the length of the request + var length = checked((int)memoryStream.Length); + + // Back out if the request is > 1 MB + if (memoryStream.Length > 0x100000) + { + ServerLogger.Log("Request is over 1MB in length, cancelling write"); + throw new ArgumentOutOfRangeException(); + } + + // Send the request to the server + ServerLogger.Log("Writing length of request."); + await outStream + .WriteAsync(BitConverter.GetBytes(length), 0, 4, cancellationToken) + .ConfigureAwait(false); + + ServerLogger.Log("Writing request of size {0}", length); + // Write the request + memoryStream.Position = 0; + await memoryStream + .CopyToAsync(outStream, bufferSize: length, cancellationToken: cancellationToken) + .ConfigureAwait(false); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerResponse.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerResponse.cs new file mode 100644 index 0000000000..66eb1e63f3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ServerResponse.cs @@ -0,0 +1,132 @@ +// 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 System.Threading; +using System.Threading.Tasks; + +// After the server pipe is connected, it forks off a thread to handle the connection, and creates +// a new instance of the pipe to listen for new clients. When it gets a request, it validates +// the security and elevation level of the client. If that fails, it disconnects the client. Otherwise, +// it handles the request, sends a response (described by Response class) back to the client, then +// disconnects the pipe and ends the thread. +namespace Microsoft.AspNetCore.Razor.Tools +{ + /// + /// Base class for all possible responses to a request. + /// The ResponseType enum should list all possible response types + /// and ReadResponse creates the appropriate response subclass based + /// on the response type sent by the client. + /// The format of a response is: + /// + /// Field Name Field Type Size (bytes) + /// ------------------------------------------------- + /// responseLength int (positive) 4 + /// responseType enum ResponseType 4 + /// responseBody Response subclass variable + /// + internal abstract class ServerResponse + { + public enum ResponseType + { + // The client and server are using incompatible protocol versions. + MismatchedVersion, + + // The build request completed on the server and the results are contained + // in the message. + Completed, + + // The shutdown request completed and the server process information is + // contained in the message. + Shutdown, + + // The request was rejected by the server. + Rejected, + } + + public abstract ResponseType Type { get; } + + public async Task WriteAsync(Stream outStream, CancellationToken cancellationToken) + { + using (var memoryStream = new MemoryStream()) + using (var writer = new BinaryWriter(memoryStream, Encoding.Unicode)) + { + // Format the response + ServerLogger.Log("Formatting Response"); + writer.Write((int)Type); + + AddResponseBody(writer); + writer.Flush(); + + cancellationToken.ThrowIfCancellationRequested(); + + // Send the response to the client + + // Write the length of the response + var length = checked((int)memoryStream.Length); + + ServerLogger.Log("Writing response length"); + // There is no way to know the number of bytes written to + // the pipe stream. We just have to assume all of them are written. + await outStream + .WriteAsync(BitConverter.GetBytes(length), 0, 4, cancellationToken) + .ConfigureAwait(false); + + // Write the response + ServerLogger.Log("Writing response of size {0}", length); + memoryStream.Position = 0; + await memoryStream + .CopyToAsync(outStream, bufferSize: length, cancellationToken: cancellationToken) + .ConfigureAwait(false); + } + } + + protected abstract void AddResponseBody(BinaryWriter writer); + + /// + /// May throw exceptions if there are pipe problems. + /// + /// + /// + /// + public static async Task ReadAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) + { + ServerLogger.Log("Reading response length"); + // Read the response length + var lengthBuffer = new byte[4]; + await ServerProtocol.ReadAllAsync(stream, lengthBuffer, 4, cancellationToken).ConfigureAwait(false); + var length = BitConverter.ToUInt32(lengthBuffer, 0); + + // Read the response + ServerLogger.Log("Reading response of length {0}", length); + var responseBuffer = new byte[length]; + await ServerProtocol.ReadAllAsync( + stream, + responseBuffer, + responseBuffer.Length, + cancellationToken) + .ConfigureAwait(false); + + using (var reader = new BinaryReader(new MemoryStream(responseBuffer), Encoding.Unicode)) + { + var responseType = (ResponseType)reader.ReadInt32(); + + switch (responseType) + { + case ResponseType.Completed: + return CompletedServerResponse.Create(reader); + case ResponseType.MismatchedVersion: + return new MismatchedVersionServerResponse(); + case ResponseType.Shutdown: + return ShutdownServerResponse.Create(reader); + case ResponseType.Rejected: + return new RejectedServerResponse(); + default: + throw new InvalidOperationException("Received invalid response type from server."); + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ShutdownServerResponse.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ShutdownServerResponse.cs new file mode 100644 index 0000000000..dbf94e1628 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ServerProtocol/ShutdownServerResponse.cs @@ -0,0 +1,30 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal sealed class ShutdownServerResponse : ServerResponse + { + public readonly int ServerProcessId; + + public ShutdownServerResponse(int serverProcessId) + { + ServerProcessId = serverProcessId; + } + + public override ResponseType Type => ResponseType.Shutdown; + + protected override void AddResponseBody(BinaryWriter writer) + { + writer.Write(ServerProcessId); + } + + public static ShutdownServerResponse Create(BinaryReader reader) + { + var serverProcessId = reader.ReadInt32(); + return new ShutdownServerResponse(serverProcessId); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ShadowCopyManager.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ShadowCopyManager.cs new file mode 100644 index 0000000000..317dc5bd74 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ShadowCopyManager.cs @@ -0,0 +1,169 @@ +// 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.Threading; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + // Note that this class has no thread-safety guarantees. The caller should use a lock + // if concurrency is required. + internal class ShadowCopyManager : IDisposable + { + // Note that this class uses the *existance* of the Mutex to lock a directory. + // + // Nothing in this code actually ever acquires the Mutex, we just try to see if it exists + // already. + private readonly Mutex _mutex; + + private int _counter; + + public ShadowCopyManager(string baseDirectory = null) + { + BaseDirectory = baseDirectory ?? Path.Combine(Path.GetTempPath(), "Razor", "ShadowCopy"); + + var guid = Guid.NewGuid().ToString("N").ToLowerInvariant(); + UniqueDirectory = Path.Combine(BaseDirectory, guid); + + _mutex = new Mutex(initiallyOwned: false, name: guid); + + Directory.CreateDirectory(UniqueDirectory); + } + + public string BaseDirectory { get; } + + public string UniqueDirectory { get; } + + public string AddAssembly(string filePath) + { + var assemblyDirectory = CreateUniqueDirectory(); + + var destination = Path.Combine(assemblyDirectory, Path.GetFileName(filePath)); + CopyFile(filePath, destination); + + var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath); + var resourcesNameWithoutExtension = fileNameWithoutExtension + ".resources"; + var resourcesNameWithExtension = resourcesNameWithoutExtension + ".dll"; + + foreach (var directory in Directory.EnumerateDirectories(Path.GetDirectoryName(filePath))) + { + var directoryName = Path.GetFileName(directory); + + var resourcesPath = Path.Combine(directory, resourcesNameWithExtension); + if (File.Exists(resourcesPath)) + { + var resourcesShadowCopyPath = Path.Combine(assemblyDirectory, directoryName, resourcesNameWithExtension); + CopyFile(resourcesPath, resourcesShadowCopyPath); + } + + resourcesPath = Path.Combine(directory, resourcesNameWithoutExtension, resourcesNameWithExtension); + if (File.Exists(resourcesPath)) + { + var resourcesShadowCopyPath = Path.Combine(assemblyDirectory, directoryName, resourcesNameWithoutExtension, resourcesNameWithExtension); + CopyFile(resourcesPath, resourcesShadowCopyPath); + } + } + + return destination; + } + + public void Dispose() + { + _mutex.ReleaseMutex(); + } + + public Task PurgeUnusedDirectoriesAsync() + { + return Task.Run((Action)PurgeUnusedDirectories); + } + + private string CreateUniqueDirectory() + { + var id = _counter++; + + var directory = Path.Combine(UniqueDirectory, id.ToString()); + Directory.CreateDirectory(directory); + return directory; + } + + private void CopyFile(string originalPath, string shadowCopyPath) + { + var directory = Path.GetDirectoryName(shadowCopyPath); + Directory.CreateDirectory(directory); + + File.Copy(originalPath, shadowCopyPath); + + MakeWritable(new FileInfo(shadowCopyPath)); + } + + private void MakeWritable(string directoryPath) + { + var directory = new DirectoryInfo(directoryPath); + + foreach (var file in directory.EnumerateFiles(searchPattern: "*", searchOption: SearchOption.AllDirectories)) + { + MakeWritable(file); + } + } + + private void MakeWritable(FileInfo file) + { + try + { + if (file.IsReadOnly) + { + file.IsReadOnly = false; + } + } + catch + { + // There are many reasons this could fail. Ignore it and keep going. + } + } + + private void PurgeUnusedDirectories() + { + IEnumerable directories; + try + { + directories = Directory.EnumerateDirectories(BaseDirectory); + } + catch (DirectoryNotFoundException) + { + return; + } + + foreach (var directory in directories) + { + Mutex mutex = null; + try + { + // We only want to try deleting the directory if no-one else is currently using it. + // + // Note that the mutex name is the name of the directory. This is OK because we're using + // GUIDs as directory/mutex names. + if (!Mutex.TryOpenExisting(Path.GetFileName(directory).ToLowerInvariant(), out mutex)) + { + MakeWritable(directory); + Directory.Delete(directory, recursive: true); + } + } + catch + { + // If something goes wrong we will leave it to the next run to clean up. + // Just swallow the exception and move on. + } + finally + { + if (mutex != null) + { + mutex.Dispose(); + } + } + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ShutdownCommand.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ShutdownCommand.cs new file mode 100644 index 0000000000..443f454f77 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/ShutdownCommand.cs @@ -0,0 +1,97 @@ +// 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.Diagnostics; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class ShutdownCommand : CommandBase + { + public ShutdownCommand(Application parent) + : base(parent, "shutdown") + { + Pipe = Option("-p|--pipe", "name of named pipe", CommandOptionType.SingleValue); + Wait = Option("-w|--wait", "wait for shutdown", CommandOptionType.NoValue); + } + + public CommandOption Pipe { get; } + + public CommandOption Wait { get; } + + protected override bool ValidateArguments() + { + if (string.IsNullOrEmpty(Pipe.Value())) + { + Pipe.Values.Add(PipeName.ComputeDefault()); + } + + return true; + } + + protected async override Task ExecuteCoreAsync() + { + if (!IsServerRunning()) + { + // server isn't running right now + Out.Write("Server is not running."); + return 0; + } + + try + { + using (var client = await Client.ConnectAsync(Pipe.Value(), timeout: TimeSpan.FromSeconds(5), cancellationToken: Cancelled)) + { + if (client == null) + { + throw new InvalidOperationException("Couldn't connect to the server."); + } + + var request = ServerRequest.CreateShutdown(); + await request.WriteAsync(client.Stream, Cancelled).ConfigureAwait(false); + + var response = ((ShutdownServerResponse)await ServerResponse.ReadAsync(client.Stream, Cancelled)); + + if (Wait.HasValue()) + { + try + { + var process = Process.GetProcessById(response.ServerProcessId); + process.WaitForExit(); + } + catch (Exception ex) + { + // There is an inherent race here with the server process. If it has already shutdown + // by the time we try to access it then the operation has succeeded. + Error.Write(ex); + } + + Out.Write("Server pid:{0} shut down completed.", response.ServerProcessId); + } + } + } + catch (Exception ex) when (IsServerRunning()) + { + // Ignore an exception that occurred while the server was shutting down. + Error.Write(ex); + } + + return 0; + } + + private bool IsServerRunning() + { + if (Mutex.TryOpenExisting(MutexName.GetServerMutexName(Pipe.Value()), out var mutex)) + { + mutex.Dispose(); + return true; + } + + return false; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/runtimeconfig.template.json b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/runtimeconfig.template.json new file mode 100644 index 0000000000..2c73f39890 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/runtimeconfig.template.json @@ -0,0 +1,3 @@ +{ + "rollForwardOnNoCandidateFx": 2 +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/CompositeRazorProjectFileSystemTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/CompositeRazorProjectFileSystemTest.cs new file mode 100644 index 0000000000..01a3e1b6a8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/CompositeRazorProjectFileSystemTest.cs @@ -0,0 +1,81 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class CompositeRazorProjectFileSystemTest + { + [Fact] + public void EnumerateItems_ReturnsResultsFromAllFileSystems() + { + // Arrange + var basePath = "base-path"; + var file1 = new TestRazorProjectItem("file1"); + var file2 = new TestRazorProjectItem("file2"); + var file3 = new TestRazorProjectItem("file3"); + var fileSystem1 = Mock.Of( + f => f.EnumerateItems(basePath) == new[] { file1 }); + var fileSystem2 = Mock.Of( + f => f.EnumerateItems(basePath) == Enumerable.Empty()); + var fileSystem3 = Mock.Of( + f => f.EnumerateItems(basePath) == new[] { file2, file3, }); + + var compositeRazorProjectFileSystem = new CompositeRazorProjectFileSystem(new[] { fileSystem1, fileSystem2, fileSystem3 }); + + // Act + var result = compositeRazorProjectFileSystem.EnumerateItems(basePath); + + // Assert + Assert.Equal(new[] { file1, file2, file3 }, result); + } + + [Fact] + public void EnumerateItems_ReturnsEmptySequence_IfNoFileSystemReturnsResults() + { + // Arrange + var basePath = "base-path"; + var fileSystem1 = Mock.Of( + f => f.EnumerateItems(basePath) == Enumerable.Empty()); + var fileSystem2 = Mock.Of( + f => f.EnumerateItems(basePath) == Enumerable.Empty()); + + var compositeRazorProjectFileSystem = new CompositeRazorProjectFileSystem(new[] { fileSystem1, fileSystem2 }); + + // Act + var result = compositeRazorProjectFileSystem.EnumerateItems(basePath); + + // Assert + Assert.Empty(result); + } + + [Fact] + public void GetItem_ReturnsFirstInstanceThatExists() + { + // Arrange + var basePath = "base-path"; + var filePath = "file-path"; + var file1 = new NotFoundProjectItem(basePath, filePath, fileKind: null); + var file2 = new TestRazorProjectItem(filePath); + RazorProjectItem nullItem = null; + var fileSystem1 = Mock.Of( + f => f.GetItem(filePath, null) == file1); + var fileSystem2 = Mock.Of( + f => f.GetItem(filePath, null) == nullItem); + var fileSystem3 = Mock.Of( + f => f.GetItem(filePath, null) == file2); + + var compositeRazorProjectFileSystem = new CompositeRazorProjectFileSystem(new[] { fileSystem1, fileSystem2, fileSystem3 }); + + // Act + var result = compositeRazorProjectFileSystem.GetItem(filePath, fileKind: null); + + // Assert + Assert.Same(file2, result); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ConcurrentLruCacheTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ConcurrentLruCacheTest.cs new file mode 100644 index 0000000000..77ad2f0cf4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ConcurrentLruCacheTest.cs @@ -0,0 +1,120 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class ConcurrentLruCacheTest + { + [Fact] + public void ConcurrentLruCache_HoldsCapacity() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = input.Reverse(); + + // Act + var cache = new ConcurrentLruCache(input); + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Add_ThrowsIfKeyExists() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var cache = new ConcurrentLruCache(input); + + // Act & Assert + var exception = Assert.Throws(() => cache.Add(1, 1)); + Assert.StartsWith("Key already exists", exception.Message); + } + + [Fact] + public void GetOrAdd_AddsIfKeyDoesNotExist() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(Enumerable.Range(2, 3)).Reverse(); + var cache = new ConcurrentLruCache(input); + + // Act + cache.GetOrAdd(4, 4); + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Remove_RemovesEntry() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(Enumerable.Range(1, 2)).Reverse(); + var cache = new ConcurrentLruCache(input); + + // Act + var result = cache.Remove(3); + + // Assert + Assert.True(result); + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Remove_KeyNotFound_ReturnsFalse() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var cache = new ConcurrentLruCache(input); + + // Act + var result = cache.Remove(4); + + // Assert + Assert.False(result); + } + + [Fact] + public void Add_NoRead_EvictsLastNode() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(Enumerable.Range(2, 3)).Reverse(); + var cache = new ConcurrentLruCache(input); + + // Act + cache.Add(4, 4); + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + [Fact] + public void Add_ReadLastNode_EvictsSecondOldestNode() + { + // Arrange + var input = GetKeyValueArray(Enumerable.Range(1, 3)); + var expected = GetKeyValueArray(new int[] { 4, 1, 3 }); + var cache = new ConcurrentLruCache(input); + + // Act + cache.GetOrAdd(1, 1); // Read to make this MRU + cache.Add(4, 4); // Add a new node + + // Assert + Assert.Equal(expected, cache.TestingEnumerable); + } + + private KeyValuePair[] GetKeyValueArray(IEnumerable inputArray) + { + return inputArray.Select(v => new KeyValuePair(v, v)).ToArray(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultExtensionAssemblyLoaderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultExtensionAssemblyLoaderTest.cs new file mode 100644 index 0000000000..2997bd08b3 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultExtensionAssemblyLoaderTest.cs @@ -0,0 +1,128 @@ +// 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.Text; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class DefaultExtensionAssemblyLoaderTest + { + [Fact] + public void LoadFromPath_CanLoadAssembly() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + + // Act + var assembly = loader.LoadFromPath(alphaFilePath); + + // Assert + Assert.NotNull(assembly); + } + } + + [Fact] + public void LoadFromPath_DoesNotAddDuplicates_AfterLoadingByName() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var alphaFilePath2 = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha2.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + loader.AddAssemblyLocation(alphaFilePath); + + var assembly1 = loader.Load("Alpha"); + + // Act + var assembly2 = loader.LoadFromPath(alphaFilePath2); + + // Assert + Assert.Same(assembly1, assembly2); + } + } + + [Fact] + public void LoadFromPath_DoesNotAddDuplicates_AfterLoadingByPath() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var alphaFilePath2 = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha2.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var assembly1 = loader.LoadFromPath(alphaFilePath); + + // Act + var assembly2 = loader.LoadFromPath(alphaFilePath2); + + // Assert + Assert.Same(assembly1, assembly2); + } + } + + [Fact] + public void Load_CanLoadAssemblyByName_AfterLoadingByPath() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var assembly1 = loader.LoadFromPath(alphaFilePath); + + // Act + var assembly2 = loader.Load(assembly1.FullName); + + // Assert + Assert.Same(assembly1, assembly2); + } + } + + [Fact] + public void LoadFromPath_WithDependencyPathsSpecified_CanLoadAssemblyDependencies() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var betaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Beta.dll"); + var gammaFilePath = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + loader.AddAssemblyLocation(gammaFilePath); + loader.AddAssemblyLocation(deltaFilePath); + + // Act + var alpha = loader.LoadFromPath(alphaFilePath); + var beta = loader.LoadFromPath(betaFilePath); + + // Assert + var builder = new StringBuilder(); + + var a = alpha.CreateInstance("Alpha.A"); + a.GetType().GetMethod("Write").Invoke(a, new object[] { builder, "Test A" }); + + var b = beta.CreateInstance("Beta.B"); + b.GetType().GetMethod("Write").Invoke(b, new object[] { builder, "Test B" }); + var expected = @"Delta: Gamma: Alpha: Test A +Delta: Gamma: Beta: Test B +"; + + var actual = builder.ToString(); + + Assert.Equal(expected, actual, ignoreLineEndingDifferences: true); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultExtensionDependencyCheckerTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultExtensionDependencyCheckerTest.cs new file mode 100644 index 0000000000..b9b9c8ac11 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultExtensionDependencyCheckerTest.cs @@ -0,0 +1,111 @@ +// 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 Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class DefaultExtensionDependencyCheckerTest + { + [Fact] + public void Check_ReturnsFalse_WithMissingDependency() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); + + // Act + var result = checker.Check(new[] { alphaFilePath, }); + + // Assert + Assert.False(result, "Check should not have passed: " + output.ToString()); + } + } + + [Fact] + public void Check_ReturnsTrue_WithAllDependenciesProvided() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var betaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Beta.dll"); + var gammaFilePath = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); + + // Act + var result = checker.Check(new[] { alphaFilePath, betaFilePath, gammaFilePath, deltaFilePath, }); + + // Assert + Assert.True(result, "Check should have passed: " + output.ToString()); + } + } + + [Fact] + public void Check_ReturnsFalse_WhenAssemblyHasDifferentMVID() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + // Load Beta.dll from the future Alpha.dll path to prime the assembly loader + var alphaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + var betaFilePath = LoaderTestResources.Beta.WriteToFile(directory.DirectoryPath, "Beta.dll"); + var gammaFilePath = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); + + // This will cause the loader to cache some inconsistent information. + loader.LoadFromPath(alphaFilePath); + LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); + + // Act + var result = checker.Check(new[] { alphaFilePath, gammaFilePath, deltaFilePath, }); + + // Assert + Assert.False(result, "Check should not have passed: " + output.ToString()); + } + } + + [Fact] + public void Check_ReturnsFalse_WhenLoaderThrows() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var output = new StringWriter(); + + var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + var loader = new Mock(); + loader + .Setup(l => l.LoadFromPath(It.IsAny())) + .Throws(new InvalidOperationException()); + var checker = new DefaultExtensionDependencyChecker(loader.Object, output, output); + + // Act + var result = checker.Check(new[] { deltaFilePath, }); + + // Assert + Assert.False(result, "Check should not have passed: " + output.ToString()); + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultRequestDispatcherTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultRequestDispatcherTest.cs new file mode 100644 index 0000000000..c852648dc2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/DefaultRequestDispatcherTest.cs @@ -0,0 +1,572 @@ +// 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.Threading; +using System.Threading.Tasks; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class DefaultRequestDispatcherTest + { + private static ServerRequest EmptyServerRequest => new ServerRequest(1, Array.Empty()); + + private static ServerResponse EmptyServerResponse => new CompletedServerResponse( + returnCode: 0, + utf8output: false, + output: string.Empty, + error: string.Empty); + + [Fact] + public async Task AcceptConnection_ReadingRequestFails_ClosesConnection() + { + // Arrange + var stream = Mock.Of(); + var compilerHost = CreateCompilerHost(); + var connectionHost = CreateConnectionHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + var connection = CreateConnection(stream); + + // Act + var result = await dispatcher.AcceptConnection( + Task.FromResult(connection), accept: true, cancellationToken: CancellationToken.None); + + // Assert + Assert.Equal(ConnectionResult.Reason.CompilationNotStarted, result.CloseReason); + } + + /// + /// A failure to write the results to the client is considered a client disconnection. Any error + /// from when the build starts to when the write completes should be handled this way. + /// + [Fact] + public async Task AcceptConnection_WritingResultsFails_ClosesConnection() + { + // Arrange + var memoryStream = new MemoryStream(); + await EmptyServerRequest.WriteAsync(memoryStream, CancellationToken.None).ConfigureAwait(true); + memoryStream.Position = 0; + + var stream = new Mock(MockBehavior.Strict); + stream + .Setup(x => x.ReadAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((byte[] array, int start, int length, CancellationToken ct) => memoryStream.ReadAsync(array, start, length, ct)); + + var connection = CreateConnection(stream.Object); + var compilerHost = CreateCompilerHost(c => + { + c.ExecuteFunc = (req, ct) => + { + return EmptyServerResponse; + }; + }); + var connectionHost = CreateConnectionHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + + // Act + // We expect WriteAsync to fail because the mock stream doesn't have a corresponding setup. + var connectionResult = await dispatcher.AcceptConnection( + Task.FromResult(connection), accept: true, cancellationToken: CancellationToken.None); + + // Assert + Assert.Equal(ConnectionResult.Reason.ClientDisconnect, connectionResult.CloseReason); + Assert.Null(connectionResult.KeepAlive); + } + + /// + /// Ensure the Connection correctly handles the case where a client disconnects while in the + /// middle of executing a request. + /// + [Fact] + public async Task AcceptConnection_ClientDisconnectsWhenExecutingRequest_ClosesConnection() + { + // Arrange + var connectionHost = Mock.Of(); + + // Fake a long running task here that we can validate later on. + var buildTaskSource = new TaskCompletionSource(); + var buildTaskCancellationToken = default(CancellationToken); + var compilerHost = CreateCompilerHost(c => + { + c.ExecuteFunc = (req, ct) => + { + Task.WaitAll(buildTaskSource.Task); + return EmptyServerResponse; + }; + }); + + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + var readyTaskSource = new TaskCompletionSource(); + var disconnectTaskSource = new TaskCompletionSource(); + var connectionTask = CreateConnectionWithEmptyServerRequest(c => + { + c.WaitForDisconnectAsyncFunc = (ct) => + { + buildTaskCancellationToken = ct; + readyTaskSource.SetResult(true); + return disconnectTaskSource.Task; + }; + }); + + var handleTask = dispatcher.AcceptConnection( + connectionTask, accept: true, cancellationToken: CancellationToken.None); + + // Wait until WaitForDisconnectAsync task is actually created and running. + await readyTaskSource.Task.ConfigureAwait(false); + + // Act + // Now simulate a disconnect by the client. + disconnectTaskSource.SetResult(true); + var connectionResult = await handleTask; + buildTaskSource.SetResult(true); + + // Assert + Assert.Equal(ConnectionResult.Reason.ClientDisconnect, connectionResult.CloseReason); + Assert.Null(connectionResult.KeepAlive); + Assert.True(buildTaskCancellationToken.IsCancellationRequested); + } + + [Fact] + public async Task AcceptConnection_AcceptFalse_RejectsBuildRequest() + { + // Arrange + var stream = new TestableStream(); + await EmptyServerRequest.WriteAsync(stream.ReadStream, CancellationToken.None); + stream.ReadStream.Position = 0; + + var connection = CreateConnection(stream); + var connectionHost = CreateConnectionHost(); + var compilerHost = CreateCompilerHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + + // Act + var connectionResult = await dispatcher.AcceptConnection( + Task.FromResult(connection), accept: false, cancellationToken: CancellationToken.None); + + // Assert + Assert.Equal(ConnectionResult.Reason.CompilationNotStarted, connectionResult.CloseReason); + stream.WriteStream.Position = 0; + var response = await ServerResponse.ReadAsync(stream.WriteStream).ConfigureAwait(false); + Assert.Equal(ServerResponse.ResponseType.Rejected, response.Type); + } + + [Fact] + public async Task AcceptConnection_ShutdownRequest_ReturnsShutdownResponse() + { + // Arrange + var stream = new TestableStream(); + await ServerRequest.CreateShutdown().WriteAsync(stream.ReadStream, CancellationToken.None); + stream.ReadStream.Position = 0; + + var connection = CreateConnection(stream); + var connectionHost = CreateConnectionHost(); + var compilerHost = CreateCompilerHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + + // Act + var connectionResult = await dispatcher.AcceptConnection( + Task.FromResult(connection), accept: true, cancellationToken: CancellationToken.None); + + // Assert + Assert.Equal(ConnectionResult.Reason.ClientShutdownRequest, connectionResult.CloseReason); + stream.WriteStream.Position = 0; + var response = await ServerResponse.ReadAsync(stream.WriteStream).ConfigureAwait(false); + Assert.Equal(ServerResponse.ResponseType.Shutdown, response.Type); + } + + [Fact] + public async Task AcceptConnection_ConnectionHostThrowsWhenConnecting_ClosesConnection() + { + // Arrange + var connectionHost = new Mock(MockBehavior.Strict); + connectionHost.Setup(c => c.WaitForConnectionAsync(It.IsAny())).Throws(new Exception()); + var compilerHost = CreateCompilerHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost.Object, compilerHost, CancellationToken.None); + var connection = CreateConnection(Mock.Of()); + + // Act + var connectionResult = await dispatcher.AcceptConnection( + Task.FromResult(connection), accept: true, cancellationToken: CancellationToken.None); + + // Assert + Assert.Equal(ConnectionResult.Reason.CompilationNotStarted, connectionResult.CloseReason); + Assert.Null(connectionResult.KeepAlive); + } + + [Fact] + public async Task AcceptConnection_ClientConnectionThrowsWhenConnecting_ClosesConnection() + { + // Arrange + var compilerHost = CreateCompilerHost(); + var connectionHost = CreateConnectionHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + var connectionTask = Task.FromException(new Exception()); + + // Act + var connectionResult = await dispatcher.AcceptConnection( + connectionTask, accept: true, cancellationToken: CancellationToken.None); + + // Assert + Assert.Equal(ConnectionResult.Reason.CompilationNotStarted, connectionResult.CloseReason); + Assert.Null(connectionResult.KeepAlive); + } + + [Fact] + public async Task Dispatcher_ClientConnectionThrowsWhenExecutingRequest_ClosesConnection() + { + // Arrange + var called = false; + var connectionTask = CreateConnectionWithEmptyServerRequest(c => + { + c.WaitForDisconnectAsyncFunc = (ct) => + { + called = true; + throw new Exception(); + }; + }); + + var compilerHost = CreateCompilerHost(); + var connectionHost = CreateConnectionHost(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None); + + // Act + var connectionResult = await dispatcher.AcceptConnection( + connectionTask, accept: true, cancellationToken: CancellationToken.None); + + // Assert + Assert.True(called); + Assert.Equal(ConnectionResult.Reason.ClientException, connectionResult.CloseReason); + Assert.Null(connectionResult.KeepAlive); + } + + [Fact] + public void Dispatcher_NoConnections_HitsKeepAliveTimeout() + { + // Arrange + var keepAlive = TimeSpan.FromSeconds(3); + var compilerHost = CreateCompilerHost(); + var connectionHost = new Mock(); + connectionHost + .Setup(x => x.WaitForConnectionAsync(It.IsAny())) + .Returns(new TaskCompletionSource().Task); + + var eventBus = new TestableEventBus(); + var dispatcher = new DefaultRequestDispatcher(connectionHost.Object, compilerHost, CancellationToken.None, eventBus, keepAlive); + var startTime = DateTime.Now; + + // Act + dispatcher.Run(); + + // Assert + Assert.True(eventBus.HitKeepAliveTimeout); + } + + /// + /// Ensure server respects keep alive and shuts down after processing a single connection. + /// + [Fact] + public void Dispatcher_ProcessSingleConnection_HitsKeepAliveTimeout() + { + // Arrange + var connectionTask = CreateConnectionWithEmptyServerRequest(); + var keepAlive = TimeSpan.FromSeconds(1); + var compilerHost = CreateCompilerHost(c => + { + c.ExecuteFunc = (req, ct) => + { + return EmptyServerResponse; + }; + }); + var connectionHost = CreateConnectionHost(connectionTask, new TaskCompletionSource().Task); + + var eventBus = new TestableEventBus(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None, eventBus, keepAlive); + + // Act + dispatcher.Run(); + + // Assert + Assert.Equal(1, eventBus.CompletedCount); + Assert.True(eventBus.LastProcessedTime.HasValue); + Assert.True(eventBus.HitKeepAliveTimeout); + } + + /// + /// Ensure server respects keep alive and shuts down after processing multiple connections. + /// + [Fact] + public void Dispatcher_ProcessMultipleConnections_HitsKeepAliveTimeout() + { + // Arrange + var count = 5; + var list = new List>(); + for (var i = 0; i < count; i++) + { + var connectionTask = CreateConnectionWithEmptyServerRequest(); + list.Add(connectionTask); + } + + list.Add(new TaskCompletionSource().Task); + var connectionHost = CreateConnectionHost(list.ToArray()); + var compilerHost = CreateCompilerHost(c => + { + c.ExecuteFunc = (req, ct) => + { + return EmptyServerResponse; + }; + }); + + var keepAlive = TimeSpan.FromSeconds(1); + var eventBus = new TestableEventBus(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None, eventBus, keepAlive); + + // Act + dispatcher.Run(); + + // Assert + Assert.Equal(count, eventBus.CompletedCount); + Assert.True(eventBus.LastProcessedTime.HasValue); + Assert.True(eventBus.HitKeepAliveTimeout); + } + + /// + /// Ensure server respects keep alive and shuts down after processing simultaneous connections. + /// + [Fact] + public async Task Dispatcher_ProcessSimultaneousConnections_HitsKeepAliveTimeout() + { + // Arrange + var totalCount = 2; + var readySource = new TaskCompletionSource(); + var list = new List>(); + var connectionHost = new Mock(); + connectionHost + .Setup(x => x.WaitForConnectionAsync(It.IsAny())) + .Returns((CancellationToken ct) => + { + if (list.Count < totalCount) + { + var source = new TaskCompletionSource(); + var connectionTask = CreateConnectionWithEmptyServerRequest(c => + { + // Keep the connection active until we decide to end it. + c.WaitForDisconnectAsyncFunc = _ => source.Task; + }); + list.Add(source); + return connectionTask; + } + + readySource.SetResult(true); + return new TaskCompletionSource().Task; + }); + + var compilerHost = CreateCompilerHost(c => + { + c.ExecuteFunc = (req, ct) => + { + return EmptyServerResponse; + }; + }); + + var eventBus = new TestableEventBus(); + var completedCompilations = 0; + var allCompilationsComplete = new TaskCompletionSource(); + eventBus.CompilationComplete += (obj, args) => + { + if (++completedCompilations == totalCount) + { + // All compilations have completed. + allCompilationsComplete.SetResult(true); + } + }; + var keepAlive = TimeSpan.FromSeconds(1); + var dispatcherTask = Task.Run(() => + { + var dispatcher = new DefaultRequestDispatcher(connectionHost.Object, compilerHost, CancellationToken.None, eventBus, keepAlive); + dispatcher.Run(); + }); + + // Wait for all connections to be created. + await readySource.Task; + + // Wait for all compilations to complete. + await allCompilationsComplete.Task; + + // Now allow all the connections to be disconnected. + foreach (var source in list) + { + source.SetResult(true); + } + + // Act + // Now dispatcher should be in an idle state with no active connections. + await dispatcherTask; + + // Assert + Assert.False(eventBus.HasDetectedBadConnection); + Assert.Equal(totalCount, eventBus.CompletedCount); + Assert.True(eventBus.LastProcessedTime.HasValue, "LastProcessedTime should have had a value."); + Assert.True(eventBus.HitKeepAliveTimeout, "HitKeepAliveTimeout should have been hit."); + } + + [Fact] + public void Dispatcher_ClientConnectionThrows_BeginsShutdown() + { + // Arrange + var listenCancellationToken = default(CancellationToken); + var firstConnectionTask = CreateConnectionWithEmptyServerRequest(c => + { + c.WaitForDisconnectAsyncFunc = (ct) => + { + listenCancellationToken = ct; + return Task.Delay(Timeout.Infinite, ct).ContinueWith(_ => null); + }; + }); + var secondConnectionTask = CreateConnectionWithEmptyServerRequest(c => + { + c.WaitForDisconnectAsyncFunc = (ct) => throw new Exception(); + }); + + var compilerHost = CreateCompilerHost(); + var connectionHost = CreateConnectionHost( + firstConnectionTask, + secondConnectionTask, + new TaskCompletionSource().Task); + var keepAlive = TimeSpan.FromSeconds(10); + var eventBus = new TestableEventBus(); + var dispatcher = new DefaultRequestDispatcher(connectionHost, compilerHost, CancellationToken.None, eventBus, keepAlive); + + // Act + dispatcher.Run(); + + // Assert + Assert.True(eventBus.HasDetectedBadConnection); + Assert.True(listenCancellationToken.IsCancellationRequested); + } + + private static TestableConnection CreateConnection(Stream stream, string identifier = null) + { + return new TestableConnection(stream, identifier ?? "identifier"); + } + + private static async Task CreateConnectionWithEmptyServerRequest(Action configureConnection = null) + { + var memoryStream = new MemoryStream(); + await EmptyServerRequest.WriteAsync(memoryStream, CancellationToken.None); + memoryStream.Position = 0; + var connection = CreateConnection(memoryStream); + configureConnection?.Invoke(connection); + + return connection; + } + + private static ConnectionHost CreateConnectionHost(params Task[] connections) + { + var host = new Mock(); + if (connections.Length > 0) + { + var index = 0; + host + .Setup(x => x.WaitForConnectionAsync(It.IsAny())) + .Returns((CancellationToken ct) => connections[index++]); + } + + return host.Object; + } + + private static TestableCompilerHost CreateCompilerHost(Action configureCompilerHost = null) + { + var compilerHost = new TestableCompilerHost(); + configureCompilerHost?.Invoke(compilerHost); + + return compilerHost; + } + + private class TestableCompilerHost : CompilerHost + { + internal Func ExecuteFunc; + + public override ServerResponse Execute(ServerRequest request, CancellationToken cancellationToken) + { + if (ExecuteFunc != null) + { + return ExecuteFunc(request, cancellationToken); + } + + return EmptyServerResponse; + } + } + + private class TestableConnection : Connection + { + internal Func WaitForDisconnectAsyncFunc; + + public TestableConnection(Stream stream, string identifier) + { + Stream = stream; + Identifier = identifier; + WaitForDisconnectAsyncFunc = ct => Task.Delay(Timeout.Infinite, ct); + } + + public override Task WaitForDisconnectAsync(CancellationToken cancellationToken) + { + return WaitForDisconnectAsyncFunc(cancellationToken); + } + } + + private class TestableStream : Stream + { + internal readonly MemoryStream ReadStream = new MemoryStream(); + internal readonly MemoryStream WriteStream = new MemoryStream(); + + public override bool CanRead => true; + public override bool CanSeek => false; + public override bool CanWrite => true; + public override long Length { get { throw new NotImplementedException(); } } + public override long Position + { + get { throw new NotImplementedException(); } + set { throw new NotImplementedException(); } + } + + public override void Flush() + { + } + + public override int Read(byte[] buffer, int offset, int count) + { + return ReadStream.Read(buffer, offset, count); + } + + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return ReadStream.ReadAsync(buffer, offset, count, cancellationToken); + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotImplementedException(); + } + + public override void SetLength(long value) + { + throw new NotImplementedException(); + } + + public override void Write(byte[] buffer, int offset, int count) + { + WriteStream.Write(buffer, offset, count); + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return WriteStream.WriteAsync(buffer, offset, count, cancellationToken); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerData.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerData.cs new file mode 100644 index 0000000000..37a9d0180a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerData.cs @@ -0,0 +1,49 @@ +// 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.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal sealed class ServerData : IDisposable + { + internal CancellationTokenSource CancellationTokenSource { get; } + internal Task ServerTask { get; } + internal Task ListenTask { get; } + internal string PipeName { get; } + + internal ServerData(CancellationTokenSource cancellationTokenSource, string pipeName, Task serverTask, Task listenTask) + { + CancellationTokenSource = cancellationTokenSource; + PipeName = pipeName; + ServerTask = serverTask; + ListenTask = listenTask; + } + + internal async Task CancelAndCompleteAsync() + { + CancellationTokenSource.Cancel(); + return await ServerTask; + } + + internal async Task Verify(int connections, int completed) + { + var stats = await CancelAndCompleteAsync().ConfigureAwait(false); + Assert.Equal(connections, stats.Connections); + Assert.Equal(completed, stats.CompletedConnections); + } + + public void Dispose() + { + if (!CancellationTokenSource.IsCancellationRequested) + { + CancellationTokenSource.Cancel(); + } + + ServerTask.Wait(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerStats.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerStats.cs new file mode 100644 index 0000000000..ce4064528f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerStats.cs @@ -0,0 +1,17 @@ +// 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.Razor.Tools +{ + internal struct ServerStats + { + internal readonly int Connections; + internal readonly int CompletedConnections; + + internal ServerStats(int connections, int completedConnections) + { + Connections = connections; + CompletedConnections = completedConnections; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerUtilities.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerUtilities.cs new file mode 100644 index 0000000000..65e407f644 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/ServerUtilities.cs @@ -0,0 +1,156 @@ +// 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.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Moq; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class ServerUtilities + { + internal static string DefaultClientDirectory { get; } = Path.GetDirectoryName(typeof(ServerUtilities).Assembly.Location); + + internal static ServerPaths CreateBuildPaths(string workingDir, string tempDir) + { + return new ServerPaths( + clientDir: DefaultClientDirectory, + workingDir: workingDir, + tempDir: tempDir); + } + + internal static ServerData CreateServer( + string pipeName = null, + CompilerHost compilerHost = null, + ConnectionHost connectionHost = null, + Action onListening = null) + { + pipeName = pipeName ?? Guid.NewGuid().ToString(); + compilerHost = compilerHost ?? CompilerHost.Create(); + connectionHost = connectionHost ?? ConnectionHost.Create(pipeName); + + var serverStatsSource = new TaskCompletionSource(); + var serverListenSource = new TaskCompletionSource(); + var cts = new CancellationTokenSource(); + var mutexName = MutexName.GetServerMutexName(pipeName); + var thread = new Thread(_ => + { + var eventBus = new TestableEventBus(); + eventBus.Listening += (sender, e) => { serverListenSource.TrySetResult(true); }; + if (onListening != null) + { + eventBus.Listening += (sender, e) => onListening(sender, e); + } + try + { + RunServer( + pipeName, + connectionHost, + compilerHost, + cts.Token, + eventBus, + Timeout.InfiniteTimeSpan); + } + finally + { + var serverStats = new ServerStats(connections: eventBus.ConnectionCount, completedConnections: eventBus.CompletedCount); + serverStatsSource.SetResult(serverStats); + } + }); + + thread.Start(); + + // The contract of this function is that it will return once the server has started. Spin here until + // we can verify the server has started or simply failed to start. + while (ServerConnection.WasServerMutexOpen(mutexName) != true && thread.IsAlive) + { + Thread.Yield(); + } + + return new ServerData(cts, pipeName, serverStatsSource.Task, serverListenSource.Task); + } + + internal static async Task Send(string pipeName, ServerRequest request) + { + using (var client = await Client.ConnectAsync(pipeName, timeout: null, cancellationToken: default).ConfigureAwait(false)) + { + await request.WriteAsync(client.Stream).ConfigureAwait(false); + return await ServerResponse.ReadAsync(client.Stream).ConfigureAwait(false); + } + } + + internal static async Task SendShutdown(string pipeName) + { + var response = await Send(pipeName, ServerRequest.CreateShutdown()); + return ((ShutdownServerResponse)response).ServerProcessId; + } + + internal static int RunServer( + string pipeName, + ConnectionHost host, + CompilerHost compilerHost, + CancellationToken cancellationToken = default, + EventBus eventBus = null, + TimeSpan? keepAlive = null) + { + var command = new TestableServerCommand(host, compilerHost, cancellationToken, eventBus, keepAlive); + var args = new List + { + "-p", + pipeName + }; + + var result = command.Execute(args.ToArray()); + return result; + } + + private class TestableServerCommand : ServerCommand + { + private readonly ConnectionHost _host; + private readonly CompilerHost _compilerHost; + private readonly EventBus _eventBus; + private readonly CancellationToken _cancellationToken; + private readonly TimeSpan? _keepAlive; + + public TestableServerCommand( + ConnectionHost host, + CompilerHost compilerHost, + CancellationToken ct, + EventBus eventBus, + TimeSpan? keepAlive) + : base(new Application(ct, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of())) + { + _host = host; + _compilerHost = compilerHost; + _cancellationToken = ct; + _eventBus = eventBus; + _keepAlive = keepAlive; + } + + protected override void ExecuteServerCore( + ConnectionHost host, + CompilerHost compilerHost, + CancellationToken cancellationToken, + EventBus eventBus, + TimeSpan? keepAlive = null) + { + base.ExecuteServerCore( + _host ?? host, + _compilerHost ?? compilerHost, + _cancellationToken, + _eventBus ?? eventBus, + _keepAlive ?? keepAlive); + } + + protected override FileStream WritePidFile() + { + // Disable writing PID file as it is tested separately. + return null; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/TestableEventBus.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/TestableEventBus.cs new file mode 100644 index 0000000000..6430ce05df --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Infrastructure/TestableEventBus.cs @@ -0,0 +1,64 @@ +// 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.Razor.Tools +{ + internal class TestableEventBus : EventBus + { + public event EventHandler Listening; + public event EventHandler CompilationComplete; + + public int ListeningCount { get; private set; } + + public int ConnectionCount { get; private set; } + + public int CompletedCount { get; private set; } + + public DateTime? LastProcessedTime { get; private set; } + + public TimeSpan? KeepAlive { get; private set; } + + public bool HasDetectedBadConnection { get; private set; } + + public bool HitKeepAliveTimeout { get; private set; } + + public override void ConnectionListening() + { + ListeningCount++; + Listening?.Invoke(this, EventArgs.Empty); + } + + public override void ConnectionReceived() + { + ConnectionCount++; + } + + public override void ConnectionCompleted(int count) + { + CompletedCount += count; + LastProcessedTime = DateTime.Now; + } + + public override void CompilationCompleted() + { + CompilationComplete?.Invoke(this, EventArgs.Empty); + } + + public override void UpdateKeepAlive(TimeSpan timeSpan) + { + KeepAlive = timeSpan; + } + + public override void ConnectionRudelyEnded() + { + HasDetectedBadConnection = true; + } + + public override void KeepAliveReached() + { + HitKeepAliveTimeout = true; + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/LoaderTestResources.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/LoaderTestResources.cs new file mode 100644 index 0000000000..9478c46684 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/LoaderTestResources.cs @@ -0,0 +1,146 @@ +// 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.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal static class LoaderTestResources + { + static LoaderTestResources() + { + Delta = CreateAssemblyBlob("Delta", Array.Empty(), @" +using System.Text; + +namespace Delta +{ + public class D + { + public void Write(StringBuilder sb, string s) + { + sb.AppendLine(""Delta: "" + s); + } + } +} +"); + + Gamma = CreateAssemblyBlob("Gamma", new[] { Delta, }, @" +using System.Text; +using Delta; + +namespace Gamma +{ + public class G + { + public void Write(StringBuilder sb, string s) + { + D d = new D(); + + d.Write(sb, ""Gamma: "" + s); + } + } +} +"); + + Alpha = CreateAssemblyBlob("Alpha", new[] { Gamma, }, @" +using System.Text; +using Gamma; + +namespace Alpha +{ + public class A + { + public void Write(StringBuilder sb, string s) + { + G g = new G(); + + g.Write(sb, ""Alpha: "" + s); + } + } +} +"); + + Beta = CreateAssemblyBlob("Beta", new[] { Gamma, }, @" +using System.Text; +using Gamma; + +namespace Beta +{ + public class B + { + public void Write(StringBuilder sb, string s) + { + G g = new G(); + + g.Write(sb, ""Beta: "" + s); + } + } +} +"); + } + + public static AssemblyBlob Alpha { get; } + + public static AssemblyBlob Beta { get; } + + public static AssemblyBlob Delta { get; } + + public static AssemblyBlob Gamma { get; } + + private static AssemblyBlob CreateAssemblyBlob(string assemblyName, AssemblyBlob[] references, string text) + { + var defaultReferences = new[] + { + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + }; + + var compilation = CSharpCompilation.Create( + assemblyName, + new[] { CSharpSyntaxTree.ParseText(text) }, + references.Select(r => r.ToMetadataReference()).Concat(defaultReferences), + new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + using (var assemblyStream = new MemoryStream()) + using (var symbolStream = new MemoryStream()) + { + var result = compilation.Emit(assemblyStream, symbolStream); + Assert.Empty(result.Diagnostics); + + return new AssemblyBlob(assemblyName, assemblyStream.GetBuffer(), symbolStream.GetBuffer()); + } + } + + public class AssemblyBlob + { + public AssemblyBlob(string assemblyName, byte[] assemblyBytes, byte[] symbolBytes) + { + AssemblyName = assemblyName; + AssemblyBytes = assemblyBytes; + SymbolBytes = symbolBytes; + } + + public string AssemblyName { get; } + + public byte[] AssemblyBytes { get; } + + public byte[] SymbolBytes { get; } + + public MetadataReference ToMetadataReference() + { + return MetadataReference.CreateFromImage(AssemblyBytes); + } + + internal string WriteToFile(string directoryPath, string fileName) + { + var filePath = Path.Combine(directoryPath, fileName); + File.WriteAllBytes(filePath, AssemblyBytes); + return filePath; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/MetadataCacheTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/MetadataCacheTest.cs new file mode 100644 index 0000000000..fd4e54197c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/MetadataCacheTest.cs @@ -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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class MetadataCacheTest + { + [Fact] + public void GetMetadata_AddsToCache() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + // Act + var result = metadataCache.GetMetadata(assemblyFilePath); + + // Assert + Assert.NotNull(result); + Assert.Equal(1, metadataCache.Cache.Count); + } + } + + [Fact] + public void GetMetadata_UsesCache() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + // Act 1 + var result = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 1 + Assert.NotNull(result); + Assert.Equal(1, metadataCache.Cache.Count); + + // Act 2 + var cacheResult = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 2 + Assert.Same(result, cacheResult); + Assert.Equal(1, metadataCache.Cache.Count); + } + } + + [Fact] + public void GetMetadata_MultipleFiles_ReturnsDifferentResultsAndAddsToCache() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath1 = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + var assemblyFilePath2 = LoaderTestResources.Gamma.WriteToFile(directory.DirectoryPath, "Gamma.dll"); + + // Act + var result1 = metadataCache.GetMetadata(assemblyFilePath1); + var result2 = metadataCache.GetMetadata(assemblyFilePath2); + + // Assert + Assert.NotSame(result1, result2); + Assert.Equal(2, metadataCache.Cache.Count); + } + } + + [Fact] + public void GetMetadata_ReplacesCache_IfFileTimestampChanged() + { + using (var directory = TempDirectory.Create()) + { + // Arrange + var metadataCache = new MetadataCache(); + var assemblyFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); + + // Act 1 + var result = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 1 + Assert.NotNull(result); + var entry = Assert.Single(metadataCache.Cache.TestingEnumerable); + Assert.Same(result, entry.Value.Metadata); + + // Act 2 + // Update the timestamp of the file + File.SetLastWriteTimeUtc(assemblyFilePath, File.GetLastWriteTimeUtc(assemblyFilePath).AddSeconds(1)); + var cacheResult = metadataCache.GetMetadata(assemblyFilePath); + + // Assert 2 + Assert.NotSame(result, cacheResult); + entry = Assert.Single(metadataCache.Cache.TestingEnumerable); + Assert.Same(cacheResult, entry.Value.Metadata); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Microsoft.AspNetCore.Razor.Tools.Test.csproj b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Microsoft.AspNetCore.Razor.Tools.Test.csproj new file mode 100644 index 0000000000..8430edfc23 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Microsoft.AspNetCore.Razor.Tools.Test.csproj @@ -0,0 +1,18 @@ + + + + $(DefaultNetCoreTargetFramework) + $(DefaultItemExcludes);TestFiles\** + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/MvcShim.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/MvcShim.cs new file mode 100644 index 0000000000..f4fae94c35 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/MvcShim.cs @@ -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.Razor.Tools +{ + internal static class MvcShim + { + public static readonly string AssemblyName = "Microsoft.AspNetCore.Razor.Test.MvcShim"; + + 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; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f0aa552b16 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/Properties/AssemblyInfo.cs @@ -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")] diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerCommandTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerCommandTest.cs new file mode 100644 index 0000000000..cd6b2a0c57 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerCommandTest.cs @@ -0,0 +1,119 @@ +// 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.Diagnostics; +using System.IO; +using System.Text; +using System.Threading; +using Microsoft.CodeAnalysis; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class ServerCommandTest + { + [Fact] + public void WritePidFile_WorksAsExpected() + { + // Arrange + var expectedProcessId = Process.GetCurrentProcess().Id; + var expectedRzcPath = typeof(ServerCommand).Assembly.Location; + var expectedFileName = $"rzc-{expectedProcessId}"; + var directoryPath = Path.Combine(Path.GetTempPath(), "RazorTest", Guid.NewGuid().ToString()); + var path = Path.Combine(directoryPath, expectedFileName); + + var pipeName = Guid.NewGuid().ToString(); + var server = GetServerCommand(pipeName); + + // Act & Assert + try + { + using (var _ = server.WritePidFile(directoryPath)) + { + Assert.True(File.Exists(path)); + + // Make sure another stream can be opened while the write stream is still open. + using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Write | FileShare.Delete)) + using (var reader = new StreamReader(fileStream, Encoding.UTF8)) + { + var lines = reader.ReadToEnd().Split(Environment.NewLine); + Assert.Equal(new[] { expectedProcessId.ToString(), "rzc", expectedRzcPath, pipeName }, lines); + } + } + + // Make sure the file is deleted on dispose. + Assert.False(File.Exists(path)); + } + finally + { + // Cleanup after the test. + if (Directory.Exists(directoryPath)) + { + Directory.Delete(directoryPath, recursive: true); + } + } + } + + [Fact] + public void GetPidFilePath_ReturnsCorrectDefaultPath() + { + // Arrange + var expectedPath = Path.Combine("homeDir", ".dotnet", "pids", "build"); + var server = GetServerCommand(); + + // Act + var directoryPath = server.GetPidFilePath(getEnvironmentVariable: env => + { + if (env == "DOTNET_BUILD_PIDFILE_DIRECTORY") + { + return null; + } + + return "homeDir"; + }); + + // Assert + Assert.Equal(expectedPath, directoryPath); + } + + [Fact] + public void GetPidFilePath_UsesEnvironmentVariablePathIfSpecified() + { + // Arrange + var expectedPath = "/Some/directory/path/"; + var server = GetServerCommand(); + + // Act + var directoryPath = server.GetPidFilePath(getEnvironmentVariable: env => expectedPath); + + // Assert + Assert.Equal(expectedPath, directoryPath); + } + + [Fact] + public void GetPidFilePath_NullEnvironmentVariableValue_ReturnsNull() + { + // Arrange + var server = GetServerCommand(); + + // Act + var directoryPath = server.GetPidFilePath(getEnvironmentVariable: env => null); + + // Assert + Assert.Null(directoryPath); + } + + private ServerCommand GetServerCommand(string pipeName = null) + { + var application = new Application( + CancellationToken.None, + Mock.Of(), + Mock.Of(), + (path, properties) => MetadataReference.CreateFromFile(path, properties)); + + return new ServerCommand(application, pipeName); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerLifecycleTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerLifecycleTest.cs new file mode 100644 index 0000000000..c2dff43150 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerLifecycleTest.cs @@ -0,0 +1,291 @@ +// 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.Diagnostics; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class ServerLifecycleTest + { + private static ServerRequest EmptyServerRequest => new ServerRequest(1, Array.Empty()); + + private static ServerResponse EmptyServerResponse => new CompletedServerResponse( + returnCode: 0, + utf8output: false, + output: string.Empty, + error: string.Empty); + + [Fact] + public void ServerStartup_MutexAlreadyAcquired_Fails() + { + // Arrange + var pipeName = Guid.NewGuid().ToString("N"); + var mutexName = MutexName.GetServerMutexName(pipeName); + var compilerHost = new Mock(MockBehavior.Strict); + var host = new Mock(MockBehavior.Strict); + + // Act & Assert + using (var mutex = new Mutex(initiallyOwned: true, name: mutexName, createdNew: out var holdsMutex)) + { + Assert.True(holdsMutex); + try + { + var result = ServerUtilities.RunServer(pipeName, host.Object, compilerHost.Object); + + // Assert failure + Assert.Equal(1, result); + } + finally + { + mutex.ReleaseMutex(); + } + } + } + + [Fact] + public void ServerStartup_SuccessfullyAcquiredMutex() + { + // Arrange, Act & Assert + var pipeName = Guid.NewGuid().ToString("N"); + var mutexName = MutexName.GetServerMutexName(pipeName); + var compilerHost = new Mock(MockBehavior.Strict); + var host = new Mock(MockBehavior.Strict); + host + .Setup(x => x.WaitForConnectionAsync(It.IsAny())) + .Returns(() => + { + // Use a thread instead of Task to guarantee this code runs on a different + // thread and we can validate the mutex state. + var source = new TaskCompletionSource(); + var thread = new Thread(_ => + { + Mutex mutex = null; + try + { + Assert.True(Mutex.TryOpenExisting(mutexName, out mutex)); + Assert.False(mutex.WaitOne(millisecondsTimeout: 0)); + source.SetResult(true); + } + catch (Exception ex) + { + source.SetException(ex); + throw; + } + finally + { + mutex?.Dispose(); + } + }); + + // Synchronously wait here. Don't returned a Task value because we need to + // ensure the above check completes before the server hits a timeout and + // releases the mutex. + thread.Start(); + source.Task.Wait(); + + return new TaskCompletionSource().Task; + }); + + var result = ServerUtilities.RunServer(pipeName, host.Object, compilerHost.Object, keepAlive: TimeSpan.FromSeconds(1)); + Assert.Equal(0, result); + } + + [Fact] + public async Task ServerRunning_ShutdownRequest_processesSuccessfully() + { + // Arrange + using (var serverData = ServerUtilities.CreateServer()) + { + // Act + var serverProcessId = await ServerUtilities.SendShutdown(serverData.PipeName); + + // Assert + Assert.Equal(Process.GetCurrentProcess().Id, serverProcessId); + await serverData.Verify(connections: 1, completed: 1); + } + } + + /// + /// A shutdown request should not abort an existing compilation. It should be allowed to run to + /// completion. + /// + [Fact] + public async Task ServerRunning_ShutdownRequest_DoesNotAbortCompilation() + { + // Arrange + var startCompilationSource = new TaskCompletionSource(); + var finishCompilationSource = new TaskCompletionSource(); + var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => + { + // At this point, the connection has been accepted and the compilation has started. + startCompilationSource.SetResult(true); + + // We want this to keep running even after the shutdown is seen. + finishCompilationSource.Task.Wait(); + return EmptyServerResponse; + }); + + using (var serverData = ServerUtilities.CreateServer(compilerHost: host)) + { + var compileTask = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); + + // Wait for the request to go through and trigger compilation. + await startCompilationSource.Task; + + // Act + // The compilation is now in progress, send the shutdown. + await ServerUtilities.SendShutdown(serverData.PipeName); + Assert.False(compileTask.IsCompleted); + + // Now let the task complete. + finishCompilationSource.SetResult(true); + + // Assert + var response = await compileTask; + Assert.Equal(ServerResponse.ResponseType.Completed, response.Type); + Assert.Equal(0, ((CompletedServerResponse)response).ReturnCode); + + await serverData.Verify(connections: 2, completed: 2); + } + } + + /// + /// Multiple clients should be able to send shutdown requests to the server. + /// + [Fact] + public async Task ServerRunning_MultipleShutdownRequests_HandlesSuccessfully() + { + // Arrange + var startCompilationSource = new TaskCompletionSource(); + var finishCompilationSource = new TaskCompletionSource(); + var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => + { + // At this point, the connection has been accepted and the compilation has started. + startCompilationSource.SetResult(true); + + // We want this to keep running even after the shutdown is seen. + finishCompilationSource.Task.Wait(); + return EmptyServerResponse; + }); + + using (var serverData = ServerUtilities.CreateServer(compilerHost: host)) + { + var compileTask = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); + + // Wait for the request to go through and trigger compilation. + await startCompilationSource.Task; + + // Act + for (var i = 0; i < 10; i++) + { + // The compilation is now in progress, send the shutdown. + var processId = await ServerUtilities.SendShutdown(serverData.PipeName); + Assert.Equal(Process.GetCurrentProcess().Id, processId); + Assert.False(compileTask.IsCompleted); + } + + // Now let the task complete. + finishCompilationSource.SetResult(true); + + // Assert + var response = await compileTask; + Assert.Equal(ServerResponse.ResponseType.Completed, response.Type); + Assert.Equal(0, ((CompletedServerResponse)response).ReturnCode); + + await serverData.Verify(connections: 11, completed: 11); + } + } + + // https://github.com/aspnet/Razor/issues/1991 + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() + { + // Arrange + const int requestCount = 5; + var count = 0; + var completionSource = new TaskCompletionSource(); + var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => + { + if (Interlocked.Increment(ref count) == requestCount) + { + completionSource.SetResult(true); + } + + ct.WaitHandle.WaitOne(); + return new RejectedServerResponse(); + }); + + var semaphore = new SemaphoreSlim(1); + Action onListening = (s, e) => + { + semaphore.Release(); + }; + using (var serverData = ServerUtilities.CreateServer(compilerHost: host, onListening: onListening)) + { + // Send all the requests. + var clients = new List(); + for (var i = 0; i < requestCount; i++) + { + // Wait for the server to start listening. + await semaphore.WaitAsync(TimeSpan.FromMinutes(1)); + + var client = await Client.ConnectAsync(serverData.PipeName, timeout: null, cancellationToken: default); + await EmptyServerRequest.WriteAsync(client.Stream); + clients.Add(client); + } + + // Act + // Wait until all of the connections are being processed by the server. + await completionSource.Task; + + // Now cancel + var stats = await serverData.CancelAndCompleteAsync(); + + // Assert + Assert.Equal(requestCount, stats.Connections); + Assert.Equal(requestCount, count); + + // Read the server response to each client. + foreach (var client in clients) + { + var task = ServerResponse.ReadAsync(client.Stream); + // We expect this to throw because the stream is already closed. + await Assert.ThrowsAnyAsync(() => task); + client.Dispose(); + } + } + } + + private static TestableCompilerHost CreateCompilerHost(Action configureCompilerHost = null) + { + var compilerHost = new TestableCompilerHost(); + configureCompilerHost?.Invoke(compilerHost); + + return compilerHost; + } + + private class TestableCompilerHost : CompilerHost + { + internal Func ExecuteFunc; + + public override ServerResponse Execute(ServerRequest request, CancellationToken cancellationToken) + { + if (ExecuteFunc != null) + { + return ExecuteFunc(request, cancellationToken); + } + + return EmptyServerResponse; + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerProtocol/ServerProtocolTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerProtocol/ServerProtocolTest.cs new file mode 100644 index 0000000000..86a7beb8be --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/ServerProtocol/ServerProtocolTest.cs @@ -0,0 +1,128 @@ +// 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.Immutable; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + public class ServerProtocolTest + { + [Fact] + public async Task ServerResponse_WriteRead_RoundtripsProperly() + { + // Arrange + var response = new CompletedServerResponse(42, utf8output: false, output: "a string", error: "an error"); + var memoryStream = new MemoryStream(); + + // Act + await response.WriteAsync(memoryStream, CancellationToken.None); + + // Assert + Assert.True(memoryStream.Position > 0); + memoryStream.Position = 0; + var result = (CompletedServerResponse)await ServerResponse.ReadAsync(memoryStream, CancellationToken.None); + Assert.Equal(42, result.ReturnCode); + Assert.False(result.Utf8Output); + Assert.Equal("a string", result.Output); + Assert.Equal("an error", result.ErrorOutput); + } + + [Fact] + public async Task ServerRequest_WriteRead_RoundtripsProperly() + { + // Arrange + var request = new ServerRequest( + ServerProtocol.ProtocolVersion, + ImmutableArray.Create( + new RequestArgument(RequestArgument.ArgumentId.CurrentDirectory, argumentIndex: 0, value: "directory"), + new RequestArgument(RequestArgument.ArgumentId.CommandLineArgument, argumentIndex: 1, value: "file"))); + var memoryStream = new MemoryStream(); + + // Act + await request.WriteAsync(memoryStream, CancellationToken.None); + + // Assert + Assert.True(memoryStream.Position > 0); + memoryStream.Position = 0; + var read = await ServerRequest.ReadAsync(memoryStream, CancellationToken.None); + Assert.Equal(ServerProtocol.ProtocolVersion, read.ProtocolVersion); + Assert.Equal(2, read.Arguments.Count); + Assert.Equal(RequestArgument.ArgumentId.CurrentDirectory, read.Arguments[0].Id); + Assert.Equal(0, read.Arguments[0].ArgumentIndex); + Assert.Equal("directory", read.Arguments[0].Value); + Assert.Equal(RequestArgument.ArgumentId.CommandLineArgument, read.Arguments[1].Id); + Assert.Equal(1, read.Arguments[1].ArgumentIndex); + Assert.Equal("file", read.Arguments[1].Value); + } + + [Fact] + public void CreateShutdown_CreatesCorrectShutdownRequest() + { + // Arrange & Act + var request = ServerRequest.CreateShutdown(); + + // Assert + Assert.Equal(2, request.Arguments.Count); + + var argument1 = request.Arguments[0]; + Assert.Equal(RequestArgument.ArgumentId.Shutdown, argument1.Id); + Assert.Equal(0, argument1.ArgumentIndex); + Assert.Equal("", argument1.Value); + + var argument2 = request.Arguments[1]; + Assert.Equal(RequestArgument.ArgumentId.CommandLineArgument, argument2.Id); + Assert.Equal(1, argument2.ArgumentIndex); + Assert.Equal("shutdown", argument2.Value); + } + + [Fact] + public async Task ShutdownRequest_WriteRead_RoundtripsProperly() + { + // Arrange + var memoryStream = new MemoryStream(); + var request = ServerRequest.CreateShutdown(); + + // Act + await request.WriteAsync(memoryStream, CancellationToken.None); + + // Assert + memoryStream.Position = 0; + var read = await ServerRequest.ReadAsync(memoryStream, CancellationToken.None); + + var argument1 = request.Arguments[0]; + Assert.Equal(RequestArgument.ArgumentId.Shutdown, argument1.Id); + Assert.Equal(0, argument1.ArgumentIndex); + Assert.Equal("", argument1.Value); + + var argument2 = request.Arguments[1]; + Assert.Equal(RequestArgument.ArgumentId.CommandLineArgument, argument2.Id); + Assert.Equal(1, argument2.ArgumentIndex); + Assert.Equal("shutdown", argument2.Value); + } + + [Fact] + public async Task ShutdownResponse_WriteRead_RoundtripsProperly() + { + // Arrange & Act 1 + var memoryStream = new MemoryStream(); + var response = new ShutdownServerResponse(42); + + // Assert 1 + Assert.Equal(ServerResponse.ResponseType.Shutdown, response.Type); + + // Act 2 + await response.WriteAsync(memoryStream, CancellationToken.None); + + // Assert 2 + memoryStream.Position = 0; + var read = await ServerResponse.ReadAsync(memoryStream, CancellationToken.None); + Assert.Equal(ServerResponse.ResponseType.Shutdown, read.Type); + var typed = (ShutdownServerResponse)read; + Assert.Equal(42, typed.ServerProcessId); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/TempDirectory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/TempDirectory.cs new file mode 100644 index 0000000000..d491248465 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/TempDirectory.cs @@ -0,0 +1,30 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class TempDirectory : IDisposable + { + public static TempDirectory Create() + { + var directoryPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("n")); + Directory.CreateDirectory(directoryPath); + return new TempDirectory(directoryPath); + } + + private TempDirectory(string directoryPath) + { + DirectoryPath = directoryPath; + } + + public string DirectoryPath { get; } + + public void Dispose() + { + Directory.Delete(DirectoryPath, recursive: true); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/TestDefaultExtensionAssemblyLoader.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/TestDefaultExtensionAssemblyLoader.cs new file mode 100644 index 0000000000..d272e1c005 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/test/TestDefaultExtensionAssemblyLoader.cs @@ -0,0 +1,25 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Tools +{ + internal class TestDefaultExtensionAssemblyLoader : DefaultExtensionAssemblyLoader + { + public TestDefaultExtensionAssemblyLoader(string baseDirectory) + : base(baseDirectory) + { + } + + protected override Assembly LoadFromPathUnsafeCore(string filePath) + { + // Force a load from streams so we don't lock the files on disk. This way we can test + // shadow copying without leaving a mess behind. + var bytes = File.ReadAllBytes(filePath); + var stream = new MemoryStream(bytes); + return LoadContext.LoadFromStream(stream); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/AssemblyIdentityEqualityComparer.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/AssemblyIdentityEqualityComparer.cs new file mode 100644 index 0000000000..e41fc02abc --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/AssemblyIdentityEqualityComparer.cs @@ -0,0 +1,50 @@ +// 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.Extensions.Internal; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal abstract class AssemblyIdentityEqualityComparer : IEqualityComparer + { + public static readonly AssemblyIdentityEqualityComparer NameAndVersion = new NameAndVersionEqualityComparer(); + + public abstract bool Equals(AssemblyIdentity x, AssemblyIdentity y); + + public abstract int GetHashCode(AssemblyIdentity obj); + + private class NameAndVersionEqualityComparer : AssemblyIdentityEqualityComparer + { + public override bool Equals(AssemblyIdentity x, AssemblyIdentity y) + { + if (object.ReferenceEquals(x, y)) + { + return true; + } + else if (x == null ^ y == null) + { + return false; + } + else + { + return string.Equals(x.Name, y.Name, StringComparison.OrdinalIgnoreCase) && object.Equals(x.Version, y.Version); + } + } + + public override int GetHashCode(AssemblyIdentity obj) + { + if (obj == null) + { + return 0; + } + + var hash = new HashCodeCombiner(); + hash.Add(obj.Name, StringComparer.OrdinalIgnoreCase); + hash.Add(obj.Version); + return hash; + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..05dea796a6 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -0,0 +1,606 @@ +// 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.Globalization; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class BindTagHelperDescriptorProvider : ITagHelperDescriptorProvider + { + // Run after the component tag helper provider, because we need to see the results. + public int Order { get; set; } = 1000; + + public RazorEngine Engine { get; set; } + + public void Execute(TagHelperDescriptorProviderContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + // This provider returns tag helper information for 'bind' which doesn't necessarily + // map to any real component. Bind behaviors more like a macro, which can map a single LValue to + // both a 'value' attribute and a 'value changed' attribute. + // + // User types: + // + // + // We generate: + // + // + // This isn't very different from code the user could write themselves - thus the pronouncement + // that @bind is very much like a macro. + // + // A lot of the value that provide in this case is that the associations between the + // elements, and the attributes aren't straightforward. + // + // For instance on we need to listen to 'value' and 'onchange', + // but on + // and so we have a special case for input elements and their type attributes. + // + // Additionally, our mappings tell us about cases like where + // we need to treat the value as an invariant culture value. In general the HTML5 field + // types use invariant culture values when interacting with the DOM, in contrast to + // which is free-form text and is most likely to be + // culture-sensitive. + // + // 4. For components, we have a bit of a special case. We can infer a syntax that matches + // case #2 based on property names. So if a component provides both 'Value' and 'ValueChanged' + // we will turn that into an instance of bind. + // + // So case #1 here is the most general case. Case #2 and #3 are data-driven based on attribute data + // we have. Case #4 is data-driven based on component definitions. + // + // We provide a good set of attributes that map to the HTML dom. This set is user extensible. + var compilation = context.GetCompilation(); + if (compilation == null) + { + return; + } + + var bindMethods = compilation.GetTypeByMetadataName(ComponentsApi.BindConverter.FullTypeName); + if (bindMethods == null) + { + // If we can't find BindConverter, then just bail. We won't be able to compile the + // generated code anyway. + return; + } + + // Tag Helper defintion for case #1. This is the most general case. + context.Results.Add(CreateFallbackBindTagHelper()); + + // For case #2 & #3 we have a whole bunch of attribute entries on BindMethods that we can use + // to data-drive the definitions of these tag helpers. + var elementBindData = GetElementBindData(compilation); + + // Case #2 & #3 + foreach (var tagHelper in CreateElementBindTagHelpers(elementBindData)) + { + context.Results.Add(tagHelper); + } + + // For case #4 we look at the tag helpers that were already created corresponding to components + // and pattern match on properties. + foreach (var tagHelper in CreateComponentBindTagHelpers(context.Results)) + { + context.Results.Add(tagHelper); + } + } + + private TagHelperDescriptor CreateFallbackBindTagHelper() + { + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, "Bind", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; + builder.Documentation = ComponentResources.BindTagHelper_Fallback_Documentation; + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Bind.TagHelperKind); + builder.Metadata.Add(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Bind.RuntimeName; + builder.Metadata[ComponentMetadata.Bind.FallbackKey] = bool.TrueString; + + // WTE has a bug in 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + builder.SetTypeName("Microsoft.AspNetCore.Components.Bind"); + + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + rule.Attribute(attribute => + { + attribute.Name = "@bind-"; + attribute.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + builder.BindAttribute(attribute => + { + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + attribute.Documentation = ComponentResources.BindTagHelper_Fallback_Documentation; + + var attributeName = "@bind-..."; + attribute.Name = attributeName; + attribute.AsDictionary("@bind-", typeof(object).FullName); + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + attribute.SetPropertyName("Bind"); + attribute.TypeName = "System.Collections.Generic.Dictionary"; + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "format"; + parameter.TypeName = typeof(string).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Fallback_Format_Documentation; + + parameter.SetPropertyName("Format"); + }); + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "event"; + parameter.TypeName = typeof(string).FullName; + parameter.Documentation = string.Format(ComponentResources.BindTagHelper_Fallback_Event_Documentation, attributeName); + + parameter.SetPropertyName("Event"); + }); + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "culture"; + parameter.TypeName = typeof(CultureInfo).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation; + + parameter.SetPropertyName("Culture"); + }); + }); + + return builder.Build(); + } + + private List GetElementBindData(Compilation compilation) + { + var bindElement = compilation.GetTypeByMetadataName(ComponentsApi.BindElementAttribute.FullTypeName); + var bindInputElement = compilation.GetTypeByMetadataName(ComponentsApi.BindInputElementAttribute.FullTypeName); + + if (bindElement == null || bindInputElement == null) + { + // This won't likely happen, but just in case. + return new List(); + } + + var types = new List(); + var visitor = new BindElementDataVisitor(types); + + // Visit the primary output of this compilation, as well as all references. + visitor.Visit(compilation.Assembly); + foreach (var reference in compilation.References) + { + // We ignore .netmodules here - there really isn't a case where they are used by user code + // even though the Roslyn APIs all support them. + if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) + { + visitor.Visit(assembly); + } + } + + var results = new List(); + + for (var i = 0; i < types.Count; i++) + { + var type = types[i]; + var attributes = type.GetAttributes(); + + // Not handling duplicates here for now since we're the primary ones extending this. + // If we see users adding to the set of 'bind' constructs we will want to add deduplication + // and potentially diagnostics. + for (var j = 0; j < attributes.Length; j++) + { + var attribute = attributes[j]; + + // We need to check the constructor argument length here, because this can show up as 0 + // if the language service fails to initialize. This is an invalid case, so skip it. + if (SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, bindElement) && attribute.ConstructorArguments.Length == 4) + { + results.Add(new ElementBindData( + type.ContainingAssembly.Name, + type.ToDisplayString(), + (string)attribute.ConstructorArguments[0].Value, + null, + (string)attribute.ConstructorArguments[1].Value, + (string)attribute.ConstructorArguments[2].Value, + (string)attribute.ConstructorArguments[3].Value)); + } + else if (SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, bindInputElement) && attribute.ConstructorArguments.Length == 4) + { + results.Add(new ElementBindData( + type.ContainingAssembly.Name, + type.ToDisplayString(), + "input", + (string)attribute.ConstructorArguments[0].Value, + (string)attribute.ConstructorArguments[1].Value, + (string)attribute.ConstructorArguments[2].Value, + (string)attribute.ConstructorArguments[3].Value)); + } + else if (SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, bindInputElement) && attribute.ConstructorArguments.Length == 6) + { + results.Add(new ElementBindData( + type.ContainingAssembly.Name, + type.ToDisplayString(), + "input", + (string)attribute.ConstructorArguments[0].Value, + (string)attribute.ConstructorArguments[1].Value, + (string)attribute.ConstructorArguments[2].Value, + (string)attribute.ConstructorArguments[3].Value, + (bool)attribute.ConstructorArguments[4].Value, + (string)attribute.ConstructorArguments[5].Value)); + } + } + } + + return results; + } + + private List CreateElementBindTagHelpers(List data) + { + var results = new List(); + + for (var i = 0; i < data.Count; i++) + { + var entry = data[i]; + + var name = entry.Suffix == null ? "Bind" : "Bind_" + entry.Suffix; + var attributeName = entry.Suffix == null ? "@bind" : "@bind-" + entry.Suffix; + + var formatName = entry.Suffix == null ? "Format_" + entry.ValueAttribute : "Format_" + entry.Suffix; + var formatAttributeName = entry.Suffix == null ? "format-" + entry.ValueAttribute : "format-" + entry.Suffix; + + var eventName = entry.Suffix == null ? "Event_" + entry.ValueAttribute : "Event_" + entry.Suffix; + + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, name, ComponentsApi.AssemblyName); + builder.CaseSensitive = true; + builder.Documentation = string.Format( + ComponentResources.BindTagHelper_Element_Documentation, + entry.ValueAttribute, + entry.ChangeAttribute); + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Bind.TagHelperKind); + builder.Metadata.Add(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Bind.RuntimeName; + builder.Metadata[ComponentMetadata.Bind.ValueAttribute] = entry.ValueAttribute; + builder.Metadata[ComponentMetadata.Bind.ChangeAttribute] = entry.ChangeAttribute; + builder.Metadata[ComponentMetadata.Bind.IsInvariantCulture] = entry.IsInvariantCulture ? bool.TrueString : bool.FalseString; + builder.Metadata[ComponentMetadata.Bind.Format] = entry.Format; + + if (entry.TypeAttribute != null) + { + // For entries that map to the element, we need to be able to know + // the difference between and for which we + // want to use the same attributes. + // + // We provide a tag helper for that should match all input elements, + // but we only want it to be used when a more specific one is used. + // + // Therefore we use this metadata to know which one is more specific when two + // tag helpers match. + builder.Metadata[ComponentMetadata.Bind.TypeAttribute] = entry.TypeAttribute; + } + + // WTE has a bug in 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + builder.SetTypeName(entry.TypeName); + + builder.TagMatchingRule(rule => + { + rule.TagName = entry.Element; + if (entry.TypeAttribute != null) + { + rule.Attribute(a => + { + a.Name = "type"; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Value = entry.TypeAttribute; + a.ValueComparisonMode = RequiredAttributeDescriptor.ValueComparisonMode.FullMatch; + }); + } + + rule.Attribute(a => + { + a.Name = attributeName; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + builder.BindAttribute(a => + { + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + a.Documentation = string.Format( + ComponentResources.BindTagHelper_Element_Documentation, + entry.ValueAttribute, + entry.ChangeAttribute); + + a.Name = attributeName; + a.TypeName = typeof(object).FullName; + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + a.SetPropertyName(name); + + a.BindAttributeParameter(parameter => + { + parameter.Name = "format"; + parameter.TypeName = typeof(string).FullName; + parameter.Documentation = string.Format(ComponentResources.BindTagHelper_Element_Format_Documentation, attributeName); + + parameter.SetPropertyName(formatName); + }); + + a.BindAttributeParameter(parameter => + { + parameter.Name = "event"; + parameter.TypeName = typeof(string).FullName; + parameter.Documentation = string.Format(ComponentResources.BindTagHelper_Element_Event_Documentation, attributeName); + + parameter.SetPropertyName(eventName); + }); + + a.BindAttributeParameter(parameter => + { + parameter.Name = "culture"; + parameter.TypeName = typeof(CultureInfo).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation; + + parameter.SetPropertyName("Culture"); + }); + }); + + // This is no longer supported. This is just here so we can add a diagnostic later on when this matches. + builder.BindAttribute(attribute => + { + attribute.Name = formatAttributeName; + attribute.TypeName = "System.String"; + attribute.Documentation = string.Format(ComponentResources.BindTagHelper_Element_Format_Documentation, attributeName); + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + attribute.SetPropertyName(formatName); + }); + + results.Add(builder.Build()); + } + + return results; + } + + private List CreateComponentBindTagHelpers(ICollection tagHelpers) + { + var results = new List(); + + foreach (var tagHelper in tagHelpers) + { + if (!tagHelper.IsComponentTagHelper()) + { + continue; + } + + // We want to create a 'bind' tag helper everywhere we see a pair of properties like `Foo`, `FooChanged` + // where `FooChanged` is a delegate and `Foo` is not. + // + // The easiest way to figure this out without a lot of backtracking is to look for `FooChanged` and then + // try to find a matching "Foo". + // + // We also look for a corresponding FooExpression attribute, though its presence is optional. + for (var i = 0; i < tagHelper.BoundAttributes.Count; i++) + { + var changeAttribute = tagHelper.BoundAttributes[i]; + if (!changeAttribute.Name.EndsWith("Changed") || + + // Allow the ValueChanged attribute to be a delegate or EventCallback<>. + // + // We assume that the Delegate or EventCallback<> has a matching type, and the C# compiler will help + // you figure figure it out if you did it wrongly. + (!changeAttribute.IsDelegateProperty() && !changeAttribute.IsEventCallbackProperty())) + { + continue; + } + + BoundAttributeDescriptor valueAttribute = null; + BoundAttributeDescriptor expressionAttribute = null; + var valueAttributeName = changeAttribute.Name.Substring(0, changeAttribute.Name.Length - "Changed".Length); + var expressionAttributeName = valueAttributeName + "Expression"; + for (var j = 0; j < tagHelper.BoundAttributes.Count; j++) + { + if (tagHelper.BoundAttributes[j].Name == valueAttributeName) + { + valueAttribute = tagHelper.BoundAttributes[j]; + } + + if (tagHelper.BoundAttributes[j].Name == expressionAttributeName) + { + expressionAttribute = tagHelper.BoundAttributes[j]; + } + + if (valueAttribute != null && expressionAttribute != null) + { + // We found both, so we can stop looking now + break; + } + } + + if (valueAttribute == null) + { + // No matching attribute found. + continue; + } + + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, tagHelper.Name, tagHelper.AssemblyName); + builder.DisplayName = tagHelper.DisplayName; + builder.CaseSensitive = true; + builder.Documentation = string.Format( + ComponentResources.BindTagHelper_Component_Documentation, + valueAttribute.Name, + changeAttribute.Name); + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Bind.TagHelperKind); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Bind.RuntimeName; + builder.Metadata[ComponentMetadata.Bind.ValueAttribute] = valueAttribute.Name; + builder.Metadata[ComponentMetadata.Bind.ChangeAttribute] = changeAttribute.Name; + + if (expressionAttribute != null) + { + builder.Metadata[ComponentMetadata.Bind.ExpressionAttribute] = expressionAttribute.Name; + } + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + builder.SetTypeName(tagHelper.GetTypeName()); + + // Match the component and attribute name + builder.TagMatchingRule(rule => + { + rule.TagName = tagHelper.TagMatchingRules.Single().TagName; + rule.Attribute(attribute => + { + attribute.Name = "@bind-" + valueAttribute.Name; + attribute.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + builder.BindAttribute(attribute => + { + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + attribute.Documentation = string.Format( + ComponentResources.BindTagHelper_Component_Documentation, + valueAttribute.Name, + changeAttribute.Name); + + attribute.Name = "@bind-" + valueAttribute.Name; + attribute.TypeName = changeAttribute.TypeName; + attribute.IsEnum = valueAttribute.IsEnum; + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the toolips. + attribute.SetPropertyName(valueAttribute.GetPropertyName()); + }); + + if (tagHelper.IsComponentFullyQualifiedNameMatch()) + { + builder.Metadata[ComponentMetadata.Component.NameMatchKey] = ComponentMetadata.Component.FullyQualifiedNameMatch; + } + + results.Add(builder.Build()); + } + } + + return results; + } + + private struct ElementBindData + { + public ElementBindData( + string assembly, + string typeName, + string element, + string typeAttribute, + string suffix, + string valueAttribute, + string changeAttribute, + bool isInvariantCulture = false, + string format = null) + { + Assembly = assembly; + TypeName = typeName; + Element = element; + TypeAttribute = typeAttribute; + Suffix = suffix; + ValueAttribute = valueAttribute; + ChangeAttribute = changeAttribute; + IsInvariantCulture = isInvariantCulture; + Format = format; + } + + public string Assembly { get; } + public string TypeName { get; } + public string Element { get; } + public string TypeAttribute { get; } + public string Suffix { get; } + public string ValueAttribute { get; } + public string ChangeAttribute { get; } + public bool IsInvariantCulture { get; } + public string Format { get; } + } + + private class BindElementDataVisitor : SymbolVisitor + { + private List _results; + + public BindElementDataVisitor(List results) + { + _results = results; + } + + public override void VisitNamedType(INamedTypeSymbol symbol) + { + if (symbol.Name == "BindAttributes" && symbol.DeclaredAccessibility == Accessibility.Public) + { + _results.Add(symbol); + } + } + + public override void VisitNamespace(INamespaceSymbol symbol) + { + foreach (var member in symbol.GetMembers()) + { + Visit(member); + } + } + + public override void VisitAssembly(IAssemblySymbol symbol) + { + // This as a simple yet high-value optimization that excludes the vast majority of + // assemblies that (by definition) can't contain a component. + if (symbol.Name != null && !symbol.Name.StartsWith("System.", StringComparison.Ordinal)) + { + Visit(symbol.GlobalNamespace); + } + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/CompilationTagHelperFeature.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/CompilationTagHelperFeature.cs new file mode 100644 index 0000000000..2041cd9eb5 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/CompilationTagHelperFeature.cs @@ -0,0 +1,50 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.CSharp; + +namespace Microsoft.CodeAnalysis.Razor +{ + public sealed class CompilationTagHelperFeature : RazorEngineFeatureBase, ITagHelperFeature + { + private ITagHelperDescriptorProvider[] _providers; + private IMetadataReferenceFeature _referenceFeature; + + public IReadOnlyList GetDescriptors() + { + var results = new List(); + + var context = TagHelperDescriptorProviderContext.Create(results); + var compilation = CSharpCompilation.Create("__TagHelpers", references: _referenceFeature.References); + if (IsValidCompilation(compilation)) + { + context.SetCompilation(compilation); + } + + for (var i = 0; i < _providers.Length; i++) + { + _providers[i].Execute(context); + } + + return results; + } + + protected override void OnInitialized() + { + _referenceFeature = Engine.Features.OfType().FirstOrDefault(); + _providers = Engine.Features.OfType().OrderBy(f => f.Order).ToArray(); + } + + internal static bool IsValidCompilation(Compilation compilation) + { + var @string = compilation.GetSpecialType(SpecialType.System_String); + + // Do some minimal tests to verify the compilation is valid. If symbols for System.String + // is missing or errored, the compilation may be missing references. + return @string != null && @string.TypeKind != TypeKind.Error; + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/CompilerFeatures.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/CompilerFeatures.cs new file mode 100644 index 0000000000..a9ea37b7ec --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/CompilerFeatures.cs @@ -0,0 +1,38 @@ +// 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.CodeAnalysis.Razor +{ + /// + /// Provides access to built-in Razor features that require a reference to Microsoft.CodeAnalysis.CSharp. + /// + public static class CompilerFeatures + { + /// + /// Registers built-in Razor features that require a reference to Microsoft.CodeAnalysis.CSharp. + /// + /// The . + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (builder.Configuration.LanguageVersion.CompareTo(RazorLanguageVersion.Version_3_0) >= 0) + { + builder.Features.Add(new BindTagHelperDescriptorProvider()); + builder.Features.Add(new ComponentTagHelperDescriptorProvider()); + builder.Features.Add(new EventHandlerTagHelperDescriptorProvider()); + builder.Features.Add(new RefTagHelperDescriptorProvider()); + builder.Features.Add(new KeyTagHelperDescriptorProvider()); + builder.Features.Add(new SplatTagHelperDescriptorProvider()); + + builder.Features.Add(new DefaultTypeNameFeature()); + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentDetectionConventions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentDetectionConventions.cs new file mode 100644 index 0000000000..214f9e36a4 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentDetectionConventions.cs @@ -0,0 +1,28 @@ +// 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.CodeAnalysis.Razor +{ + internal static class ComponentDetectionConventions + { + public static bool IsComponent(INamedTypeSymbol symbol, INamedTypeSymbol icomponentSymbol) + { + if (symbol is null) + { + throw new ArgumentNullException(nameof(symbol)); + } + + if (icomponentSymbol is null) + { + throw new ArgumentNullException(nameof(icomponentSymbol)); + } + + return + symbol.DeclaredAccessibility == Accessibility.Public && + !symbol.IsAbstract && + symbol.AllInterfaces.Contains(icomponentSymbol); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..38fbfb6ba8 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -0,0 +1,582 @@ +// 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.Components; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class ComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, ITagHelperDescriptorProvider + { + private static readonly SymbolDisplayFormat FullNameTypeDisplayFormat = + SymbolDisplayFormat.FullyQualifiedFormat + .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted) + .WithMiscellaneousOptions(SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions & (~SymbolDisplayMiscellaneousOptions.UseSpecialTypes)); + + public bool IncludeDocumentation { get; set; } + + 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 symbols = ComponentSymbols.Create(compilation); + + var types = new List(); + var visitor = new ComponentTypeVisitor(symbols, types); + + // Visit the primary output of this compilation, as well as all references. + visitor.Visit(compilation.Assembly); + foreach (var reference in compilation.References) + { + // We ignore .netmodules here - there really isn't a case where they are used by user code + // even though the Roslyn APIs all support them. + if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) + { + visitor.Visit(assembly); + } + } + + for (var i = 0; i < types.Count; i++) + { + var type = types[i]; + + // Components have very simple matching rules. + // 1. The type name (short) matches the tag name. + // 2. The fully qualified name matches the tag name. + var shortNameMatchingDescriptor = CreateShortNameMatchingDescriptor(symbols, type); + context.Results.Add(shortNameMatchingDescriptor); + var fullyQualifiedNameMatchingDescriptor = CreateFullyQualifiedNameMatchingDescriptor(symbols, type); + context.Results.Add(fullyQualifiedNameMatchingDescriptor); + + foreach (var childContent in shortNameMatchingDescriptor.GetChildContentProperties()) + { + // Synthesize a separate tag helper for each child content property that's declared. + context.Results.Add(CreateChildContentDescriptor(symbols, shortNameMatchingDescriptor, childContent)); + context.Results.Add(CreateChildContentDescriptor(symbols, fullyQualifiedNameMatchingDescriptor, childContent)); + } + } + } + + private TagHelperDescriptor CreateShortNameMatchingDescriptor(ComponentSymbols symbols, INamedTypeSymbol type) + { + var builder = CreateDescriptorBuilder(symbols, type); + builder.TagMatchingRule(r => + { + r.TagName = type.Name; + }); + + return builder.Build(); + } + + private TagHelperDescriptor CreateFullyQualifiedNameMatchingDescriptor(ComponentSymbols symbols, INamedTypeSymbol type) + { + var builder = CreateDescriptorBuilder(symbols, type); + var containingNamespace = type.ContainingNamespace.ToDisplayString(); + var fullName = $"{containingNamespace}.{type.Name}"; + builder.TagMatchingRule(r => + { + r.TagName = fullName; + }); + builder.Metadata[ComponentMetadata.Component.NameMatchKey] = ComponentMetadata.Component.FullyQualifiedNameMatch; + + return builder.Build(); + } + + private TagHelperDescriptorBuilder CreateDescriptorBuilder(ComponentSymbols symbols, INamedTypeSymbol type) + { + var typeName = type.ToDisplayString(FullNameTypeDisplayFormat); + var assemblyName = type.ContainingAssembly.Identity.Name; + + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Component.TagHelperKind, typeName, assemblyName); + builder.SetTypeName(typeName); + builder.CaseSensitive = true; + + // This opts out this 'component' tag helper for any processing that's specific to the default + // Razor ITagHelper runtime. + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Component.RuntimeName; + + if (type.IsGenericType) + { + builder.Metadata[ComponentMetadata.Component.GenericTypedKey] = bool.TrueString; + + for (var i = 0; i < type.TypeArguments.Length; i++) + { + var typeParameter = type.TypeArguments[i] as ITypeParameterSymbol; + if (typeParameter != null) + { + CreateTypeParameterProperty(builder, typeParameter); + } + } + } + + var xml = type.GetDocumentationCommentXml(); + if (!string.IsNullOrEmpty(xml)) + { + builder.Documentation = xml; + } + + foreach (var property in GetProperties(symbols, type)) + { + if (property.kind == PropertyKind.Ignored) + { + continue; + } + + CreateProperty(builder, property.property, property.kind); + } + + if (builder.BoundAttributes.Any(a => a.IsParameterizedChildContentProperty()) && + !builder.BoundAttributes.Any(a => string.Equals(a.Name, ComponentMetadata.ChildContent.ParameterAttributeName, StringComparison.OrdinalIgnoreCase))) + { + // If we have any parameterized child content parameters, synthesize a 'Context' parameter to be + // able to set the variable name (for all child content). If the developer defined a 'Context' parameter + // already, then theirs wins. + CreateContextParameter(builder, childContentName: null); + } + + return builder; + } + + private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol property, PropertyKind kind) + { + builder.BindAttribute(pb => + { + pb.Name = property.Name; + pb.TypeName = property.Type.ToDisplayString(FullNameTypeDisplayFormat); + pb.SetPropertyName(property.Name); + + if (kind == PropertyKind.Enum) + { + pb.IsEnum = true; + } + + if (kind == PropertyKind.ChildContent) + { + pb.Metadata.Add(ComponentMetadata.Component.ChildContentKey, bool.TrueString); + } + + if (kind == PropertyKind.EventCallback) + { + pb.Metadata.Add(ComponentMetadata.Component.EventCallbackKey, bool.TrueString); + } + + if (kind == PropertyKind.Delegate) + { + pb.Metadata.Add(ComponentMetadata.Component.DelegateSignatureKey, bool.TrueString); + } + + if (HasTypeParameter(property.Type)) + { + pb.Metadata.Add(ComponentMetadata.Component.GenericTypedKey, bool.TrueString); + } + + var xml = property.GetDocumentationCommentXml(); + if (!string.IsNullOrEmpty(xml)) + { + pb.Documentation = xml; + } + }); + + bool HasTypeParameter(ITypeSymbol type) + { + if (type is ITypeParameterSymbol) + { + return true; + } + + // We need to check for cases like: + // [Parameter] public List MyProperty { get; set; } + // AND + // [Parameter] public List MyProperty { get; set; } + // + // We need to inspect the type arguments to tell the difference between a property that + // uses the containing class' type parameter(s) and a vanilla usage of generic types like + // List<> and Dictionary<,> + // + // Since we need to handle cases like RenderFragment>, this check must be recursive. + if (type is INamedTypeSymbol namedType && namedType.IsGenericType) + { + var typeArguments = namedType.TypeArguments; + for (var i = 0; i < typeArguments.Length; i++) + { + if (HasTypeParameter(typeArguments[i])) + { + return true; + } + } + + // Another case to handle - if the type being inspected is a nested type + // inside a generic containing class. The common usage for this would be a case + // where a generic templated component defines a 'context' nested class. + if (namedType.ContainingType != null && HasTypeParameter(namedType.ContainingType)) + { + return true; + } + } + + return false; + } + } + + private void CreateTypeParameterProperty(TagHelperDescriptorBuilder builder, ITypeSymbol typeParameter) + { + builder.BindAttribute(pb => + { + pb.DisplayName = typeParameter.Name; + pb.Name = typeParameter.Name; + pb.TypeName = typeof(Type).FullName; + pb.SetPropertyName(typeParameter.Name); + + pb.Metadata[ComponentMetadata.Component.TypeParameterKey] = bool.TrueString; + + pb.Documentation = string.Format(ComponentResources.ComponentTypeParameter_Documentation, typeParameter.Name, builder.Name); + }); + } + + private TagHelperDescriptor CreateChildContentDescriptor(ComponentSymbols symbols, TagHelperDescriptor component, BoundAttributeDescriptor attribute) + { + var typeName = component.GetTypeName() + "." + attribute.Name; + var assemblyName = component.AssemblyName; + + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.ChildContent.TagHelperKind, typeName, assemblyName); + builder.SetTypeName(typeName); + builder.CaseSensitive = true; + + // This opts out this 'component' tag helper for any processing that's specific to the default + // Razor ITagHelper runtime. + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.ChildContent.RuntimeName; + + // Opt out of processing as a component. We'll process this specially as part of the component's body. + builder.Metadata[ComponentMetadata.SpecialKindKey] = ComponentMetadata.ChildContent.TagHelperKind; + + var xml = attribute.Documentation; + if (!string.IsNullOrEmpty(xml)) + { + builder.Documentation = xml; + } + + // Child content matches the property name, but only as a direct child of the component. + builder.TagMatchingRule(r => + { + r.TagName = attribute.Name; + r.ParentTag = component.TagMatchingRules.First().TagName; + }); + + if (attribute.IsParameterizedChildContentProperty()) + { + // For child content attributes with a parameter, synthesize an attribute that allows you to name + // the parameter. + CreateContextParameter(builder, attribute.Name); + } + + if (component.IsComponentFullyQualifiedNameMatch()) + { + builder.Metadata[ComponentMetadata.Component.NameMatchKey] = ComponentMetadata.Component.FullyQualifiedNameMatch; + } + + var descriptor = builder.Build(); + + return descriptor; + } + + private void CreateContextParameter(TagHelperDescriptorBuilder builder, string childContentName) + { + builder.BindAttribute(b => + { + b.Name = ComponentMetadata.ChildContent.ParameterAttributeName; + b.TypeName = typeof(string).FullName; + b.Metadata.Add(ComponentMetadata.Component.ChildContentParameterNameKey, bool.TrueString); + b.Metadata.Add(TagHelperMetadata.Common.PropertyName, b.Name); + + if (childContentName == null) + { + b.Documentation = ComponentResources.ChildContentParameterName_TopLevelDocumentation; + } + else + { + b.Documentation = string.Format(ComponentResources.ChildContentParameterName_Documentation, childContentName); + } + }); + } + + // Does a walk up the inheritance chain to determine the set of parameters by using + // a dictionary keyed on property name. + // + // We consider parameters to be defined by properties satisfying all of the following: + // - are public + // - are visible (not shadowed) + // - have the [Parameter] attribute + // - have a setter, even if private + // - are not indexers + private IEnumerable<(IPropertySymbol property, PropertyKind kind)> GetProperties(ComponentSymbols symbols, INamedTypeSymbol type) + { + var properties = new Dictionary(StringComparer.Ordinal); + do + { + if (SymbolEqualityComparer.Default.Equals(type, symbols.ComponentBase)) + { + // The ComponentBase base class doesn't have any [Parameter]. + // Bail out now to avoid walking through its many members, plus the members + // of the System.Object base class. + break; + } + + var members = type.GetMembers(); + for (var i = 0; i < members.Length; i++) + { + var property = members[i] as IPropertySymbol; + if (property == null) + { + // Not a property + continue; + } + + if (properties.ContainsKey(property.Name)) + { + // Not visible + continue; + } + + var kind = PropertyKind.Default; + if (property.DeclaredAccessibility != Accessibility.Public) + { + // Not public + kind = PropertyKind.Ignored; + } + + if (property.Parameters.Length != 0) + { + // Indexer + kind = PropertyKind.Ignored; + } + + if (property.SetMethod == null) + { + // No setter + kind = PropertyKind.Ignored; + } + else if (property.SetMethod.DeclaredAccessibility != Accessibility.Public) + { + // No public setter + kind = PropertyKind.Ignored; + } + + if (property.IsStatic) + { + kind = PropertyKind.Ignored; + } + + if (!property.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, symbols.ParameterAttribute))) + { + if (property.IsOverride) + { + // This property does not contain [Parameter] attribute but it was overridden. Don't ignore it for now. + // We can ignore it if the base class does not contains a [Parameter] as well. + continue; + } + + // Does not have [Parameter] + kind = PropertyKind.Ignored; + } + + if (kind == PropertyKind.Default && property.Type.TypeKind == TypeKind.Enum) + { + kind = PropertyKind.Enum; + } + + if (kind == PropertyKind.Default && SymbolEqualityComparer.Default.Equals(property.Type, symbols.RenderFragment)) + { + kind = PropertyKind.ChildContent; + } + + if (kind == PropertyKind.Default && + property.Type is INamedTypeSymbol namedType && + namedType.IsGenericType && + SymbolEqualityComparer.Default.Equals(namedType.ConstructedFrom, symbols.RenderFragmentOfT)) + { + kind = PropertyKind.ChildContent; + } + + if (kind == PropertyKind.Default && SymbolEqualityComparer.Default.Equals(property.Type, symbols.EventCallback)) + { + kind = PropertyKind.EventCallback; + } + + if (kind == PropertyKind.Default && + property.Type is INamedTypeSymbol namedType2 && + namedType2.IsGenericType && + SymbolEqualityComparer.Default.Equals(namedType2.ConstructedFrom, symbols.EventCallbackOfT)) + { + kind = PropertyKind.EventCallback; + } + + if (kind == PropertyKind.Default && property.Type.TypeKind == TypeKind.Delegate) + { + kind = PropertyKind.Delegate; + } + + properties.Add(property.Name, (property, kind)); + } + + type = type.BaseType; + } + while (type != null); + + return properties.Values; + } + + private enum PropertyKind + { + Ignored, + Default, + Enum, + ChildContent, + Delegate, + EventCallback, + } + + private class ComponentSymbols + { + public static ComponentSymbols Create(Compilation compilation) + { + // We find a bunch of important and fundamental types here that are needed to discover + // components. If one of these isn't defined then we just bail, because the results will + // be unpredictable. + var symbols = new ComponentSymbols(); + + symbols.ComponentBase = compilation.GetTypeByMetadataName(ComponentsApi.ComponentBase.MetadataName); + if (symbols.ComponentBase == null) + { + // No definition for ComponentBase, nothing to do. + return null; + } + + symbols.IComponent = compilation.GetTypeByMetadataName(ComponentsApi.IComponent.MetadataName); + if (symbols.IComponent == null) + { + // No definition for IComponent, nothing to do. + return null; + } + + symbols.ParameterAttribute = compilation.GetTypeByMetadataName(ComponentsApi.ParameterAttribute.MetadataName); + if (symbols.ParameterAttribute == null) + { + // No definition for [Parameter], nothing to do. + return null; + } + + symbols.RenderFragment = compilation.GetTypeByMetadataName(ComponentsApi.RenderFragment.MetadataName); + if (symbols.RenderFragment == null) + { + // No definition for RenderFragment, nothing to do. + return null; + } + + symbols.RenderFragmentOfT = compilation.GetTypeByMetadataName(ComponentsApi.RenderFragmentOfT.MetadataName); + if (symbols.RenderFragmentOfT == null) + { + // No definition for RenderFragment, nothing to do. + return null; + } + + symbols.EventCallback = compilation.GetTypeByMetadataName(ComponentsApi.EventCallback.MetadataName); + if (symbols.EventCallback == null) + { + // No definition for EventCallback, nothing to do. + return null; + } + + symbols.EventCallbackOfT = compilation.GetTypeByMetadataName(ComponentsApi.EventCallbackOfT.MetadataName); + if (symbols.EventCallbackOfT == null) + { + // No definition for EventCallback, nothing to do. + return null; + } + + return symbols; + } + + private ComponentSymbols() + { + } + + public INamedTypeSymbol ComponentBase { get; private set; } + + public INamedTypeSymbol IComponent { get; private set; } + + public INamedTypeSymbol ParameterAttribute { get; private set; } + + public INamedTypeSymbol RenderFragment { get; private set; } + + public INamedTypeSymbol RenderFragmentOfT { get; private set; } + + public INamedTypeSymbol EventCallback { get; private set; } + + public INamedTypeSymbol EventCallbackOfT { get; private set; } + } + + private class ComponentTypeVisitor : SymbolVisitor + { + private readonly ComponentSymbols _symbols; + private readonly List _results; + + public ComponentTypeVisitor(ComponentSymbols symbols, List results) + { + _symbols = symbols; + _results = results; + } + + public override void VisitNamedType(INamedTypeSymbol symbol) + { + if (IsComponent(symbol)) + { + _results.Add(symbol); + } + } + + public override void VisitNamespace(INamespaceSymbol symbol) + { + foreach (var member in symbol.GetMembers()) + { + Visit(member); + } + } + + public override void VisitAssembly(IAssemblySymbol symbol) + { + // This as a simple yet high-value optimization that excludes the vast majority of + // assemblies that (by definition) can't contain a component. + if (symbol.Name != null && !symbol.Name.StartsWith("System.", StringComparison.Ordinal)) + { + Visit(symbol.GlobalNamespace); + } + } + + internal bool IsComponent(INamedTypeSymbol symbol) + { + if (_symbols == null) + { + return false; + } + + var isComponent = ComponentDetectionConventions.IsComponent(symbol, _symbols.IComponent); + return isComponent; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultMetadataReferenceFeature.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultMetadataReferenceFeature.cs new file mode 100644 index 0000000000..a8914d7513 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultMetadataReferenceFeature.cs @@ -0,0 +1,13 @@ +// 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; + +namespace Microsoft.CodeAnalysis.Razor +{ + public sealed class DefaultMetadataReferenceFeature : RazorEngineFeatureBase, IMetadataReferenceFeature + { + public IReadOnlyList References { get; set; } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs new file mode 100644 index 0000000000..4eb83b36b7 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs @@ -0,0 +1,439 @@ +// 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.ComponentModel; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class DefaultTagHelperDescriptorFactory + { + private const string DataDashPrefix = "data-"; + private const string TagHelperNameEnding = "TagHelper"; + + private readonly INamedTypeSymbol _htmlAttributeNameAttributeSymbol; + private readonly INamedTypeSymbol _htmlAttributeNotBoundAttributeSymbol; + private readonly INamedTypeSymbol _htmlTargetElementAttributeSymbol; + private readonly INamedTypeSymbol _outputElementHintAttributeSymbol; + private readonly INamedTypeSymbol _iDictionarySymbol; + private readonly INamedTypeSymbol _restrictChildrenAttributeSymbol; + private readonly INamedTypeSymbol _editorBrowsableAttributeSymbol; + + internal static readonly SymbolDisplayFormat FullNameTypeDisplayFormat = + SymbolDisplayFormat.FullyQualifiedFormat + .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted) + .WithMiscellaneousOptions(SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions & (~SymbolDisplayMiscellaneousOptions.UseSpecialTypes)); + + public DefaultTagHelperDescriptorFactory(Compilation compilation, bool includeDocumentation, bool excludeHidden) + { + IncludeDocumentation = includeDocumentation; + ExcludeHidden = excludeHidden; + + _htmlAttributeNameAttributeSymbol = compilation.GetTypeByMetadataName(TagHelperTypes.HtmlAttributeNameAttribute); + _htmlAttributeNotBoundAttributeSymbol = compilation.GetTypeByMetadataName(TagHelperTypes.HtmlAttributeNotBoundAttribute); + _htmlTargetElementAttributeSymbol = compilation.GetTypeByMetadataName(TagHelperTypes.HtmlTargetElementAttribute); + _outputElementHintAttributeSymbol = compilation.GetTypeByMetadataName(TagHelperTypes.OutputElementHintAttribute); + _restrictChildrenAttributeSymbol = compilation.GetTypeByMetadataName(TagHelperTypes.RestrictChildrenAttribute); + _editorBrowsableAttributeSymbol = compilation.GetTypeByMetadataName(typeof(EditorBrowsableAttribute).FullName); + _iDictionarySymbol = compilation.GetTypeByMetadataName(TagHelperTypes.IDictionary); + } + + protected bool ExcludeHidden { get; } + + protected bool IncludeDocumentation { get; } + + /// + public virtual TagHelperDescriptor CreateDescriptor(INamedTypeSymbol type) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (ShouldSkipDescriptorCreation(type)) + { + return null; + } + + var typeName = GetFullName(type); + var assemblyName = type.ContainingAssembly.Identity.Name; + + var descriptorBuilder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + descriptorBuilder.SetTypeName(typeName); + + AddBoundAttributes(type, descriptorBuilder); + AddTagMatchingRules(type, descriptorBuilder); + AddAllowedChildren(type, descriptorBuilder); + AddDocumentation(type, descriptorBuilder); + AddTagOutputHint(type, descriptorBuilder); + + var descriptor = descriptorBuilder.Build(); + + return descriptor; + } + + private void AddTagMatchingRules(INamedTypeSymbol type, TagHelperDescriptorBuilder descriptorBuilder) + { + var targetElementAttributes = type + .GetAttributes() + .Where(attribute => SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, _htmlTargetElementAttributeSymbol)); + + // If there isn't an attribute specifying the tag name derive it from the name + if (!targetElementAttributes.Any()) + { + var name = type.Name; + + if (name.EndsWith(TagHelperNameEnding, StringComparison.OrdinalIgnoreCase)) + { + name = name.Substring(0, name.Length - TagHelperNameEnding.Length); + } + + descriptorBuilder.TagMatchingRule(ruleBuilder => + { + var htmlCasedName = HtmlConventions.ToHtmlCase(name); + ruleBuilder.TagName = htmlCasedName; + }); + + return; + } + + foreach (var targetElementAttribute in targetElementAttributes) + { + descriptorBuilder.TagMatchingRule(ruleBuilder => + { + var tagName = HtmlTargetElementAttribute_Tag(targetElementAttribute); + ruleBuilder.TagName = tagName; + + var parentTag = HtmlTargetElementAttribute_ParentTag(targetElementAttribute); + ruleBuilder.ParentTag = parentTag; + + var tagStructure = HtmlTargetElementAttribute_TagStructure(targetElementAttribute); + ruleBuilder.TagStructure = tagStructure; + + var requiredAttributeString = HtmlTargetElementAttribute_Attributes(targetElementAttribute); + RequiredAttributeParser.AddRequiredAttributes(requiredAttributeString, ruleBuilder); + }); + } + } + + private void AddBoundAttributes(INamedTypeSymbol type, TagHelperDescriptorBuilder builder) + { + var accessibleProperties = GetAccessibleProperties(type); + foreach (var property in accessibleProperties) + { + if (ShouldSkipDescriptorCreation(property)) + { + continue; + } + + builder.BindAttribute(attributeBuilder => + { + ConfigureBoundAttribute(attributeBuilder, property, type); + }); + } + } + + private void AddAllowedChildren(INamedTypeSymbol type, TagHelperDescriptorBuilder builder) + { + var restrictChildrenAttribute = type.GetAttributes().Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _restrictChildrenAttributeSymbol)).FirstOrDefault(); + if (restrictChildrenAttribute == null) + { + return; + } + + builder.AllowChildTag(childTagBuilder => childTagBuilder.Name = (string)restrictChildrenAttribute.ConstructorArguments[0].Value); + + if (restrictChildrenAttribute.ConstructorArguments.Length == 2) + { + foreach (var value in restrictChildrenAttribute.ConstructorArguments[1].Values) + { + builder.AllowChildTag(childTagBuilder => childTagBuilder.Name = (string)value.Value); + } + } + } + + private void AddDocumentation(INamedTypeSymbol type, TagHelperDescriptorBuilder builder) + { + if (!IncludeDocumentation) + { + return; + } + + var xml = type.GetDocumentationCommentXml(); + + if (!string.IsNullOrEmpty(xml)) + { + builder.Documentation = xml; + } + } + + private void AddTagOutputHint(INamedTypeSymbol type, TagHelperDescriptorBuilder builder) + { + string outputElementHint = null; + var outputElementHintAttribute = type.GetAttributes().Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _outputElementHintAttributeSymbol)).FirstOrDefault(); + if (outputElementHintAttribute != null) + { + outputElementHint = (string)(outputElementHintAttribute.ConstructorArguments[0]).Value; + builder.TagOutputHint = outputElementHint; + } + } + + private void ConfigureBoundAttribute( + BoundAttributeDescriptorBuilder builder, + IPropertySymbol property, + INamedTypeSymbol containingType) + { + var attributeNameAttribute = property + .GetAttributes() + .Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _htmlAttributeNameAttributeSymbol)) + .FirstOrDefault(); + + bool hasExplicitName; + string attributeName; + if (attributeNameAttribute == null || + attributeNameAttribute.ConstructorArguments.Length == 0 || + string.IsNullOrEmpty((string)attributeNameAttribute.ConstructorArguments[0].Value)) + { + hasExplicitName = false; + attributeName = HtmlConventions.ToHtmlCase(property.Name); + } + else + { + hasExplicitName = true; + attributeName = (string)attributeNameAttribute.ConstructorArguments[0].Value; + } + + var hasPublicSetter = property.SetMethod != null && property.SetMethod.DeclaredAccessibility == Accessibility.Public; + var typeName = GetFullName(property.Type); + builder.TypeName = typeName; + builder.SetPropertyName(property.Name); + + if (hasPublicSetter) + { + builder.Name = attributeName; + + if (property.Type.TypeKind == TypeKind.Enum) + { + builder.IsEnum = true; + } + + if (IncludeDocumentation) + { + var xml = property.GetDocumentationCommentXml(); + + if (!string.IsNullOrEmpty(xml)) + { + builder.Documentation = xml; + } + } + } + else if (hasExplicitName && !IsPotentialDictionaryProperty(property)) + { + // Specified HtmlAttributeNameAttribute.Name though property has no public setter. + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidAttributeNameNullOrEmpty(GetFullName(containingType), property.Name); + builder.Diagnostics.Add(diagnostic); + } + + ConfigureDictionaryBoundAttribute(builder, property, containingType, attributeNameAttribute, attributeName, hasPublicSetter); + } + + private void ConfigureDictionaryBoundAttribute( + BoundAttributeDescriptorBuilder builder, + IPropertySymbol property, + INamedTypeSymbol containingType, + AttributeData attributeNameAttribute, + string attributeName, + bool hasPublicSetter) + { + string dictionaryAttributePrefix = null; + var dictionaryAttributePrefixSet = false; + + if (attributeNameAttribute != null) + { + foreach (var argument in attributeNameAttribute.NamedArguments) + { + if (argument.Key == TagHelperTypes.HtmlAttributeName.DictionaryAttributePrefix) + { + dictionaryAttributePrefix = (string)argument.Value.Value; + dictionaryAttributePrefixSet = true; + break; + } + } + } + + var dictionaryArgumentTypes = GetDictionaryArgumentTypes(property); + if (dictionaryArgumentTypes != null) + { + var prefix = dictionaryAttributePrefix; + if (attributeNameAttribute == null || !dictionaryAttributePrefixSet) + { + prefix = attributeName + "-"; + } + + if (prefix != null) + { + var dictionaryValueType = dictionaryArgumentTypes[1]; + var dictionaryValueTypeName = GetFullName(dictionaryValueType); + builder.AsDictionary(prefix, dictionaryValueTypeName); + } + } + + var dictionaryKeyType = dictionaryArgumentTypes?[0]; + + if (dictionaryKeyType?.SpecialType != SpecialType.System_String) + { + if (dictionaryAttributePrefix != null) + { + // DictionaryAttributePrefix is not supported unless associated with an + // IDictionary property. + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull(GetFullName(containingType), property.Name); + builder.Diagnostics.Add(diagnostic); + } + + return; + } + else if (!hasPublicSetter && attributeNameAttribute != null && !dictionaryAttributePrefixSet) + { + // Must set DictionaryAttributePrefix when using HtmlAttributeNameAttribute with a dictionary property + // that lacks a public setter. + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNull(GetFullName(containingType), property.Name); + builder.Diagnostics.Add(diagnostic); + + return; + } + } + + private IReadOnlyList GetDictionaryArgumentTypes(IPropertySymbol property) + { + INamedTypeSymbol dictionaryType; + if (SymbolEqualityComparer.Default.Equals((property.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol)) + { + dictionaryType = (INamedTypeSymbol)property.Type; + } + else if (property.Type.AllInterfaces.Any(s => SymbolEqualityComparer.Default.Equals(s.ConstructedFrom, _iDictionarySymbol))) + { + dictionaryType = property.Type.AllInterfaces.First(s => SymbolEqualityComparer.Default.Equals(s.ConstructedFrom, _iDictionarySymbol)); + } + else + { + dictionaryType = null; + } + + return dictionaryType?.TypeArguments; + } + + private static string HtmlTargetElementAttribute_Attributes(AttributeData attibute) + { + foreach (var kvp in attibute.NamedArguments) + { + if (kvp.Key == TagHelperTypes.HtmlTargetElement.Attributes) + { + return (string)kvp.Value.Value; + } + } + + return null; + } + + private static string HtmlTargetElementAttribute_ParentTag(AttributeData attibute) + { + foreach (var kvp in attibute.NamedArguments) + { + if (kvp.Key == TagHelperTypes.HtmlTargetElement.ParentTag) + { + return (string)kvp.Value.Value; + } + } + + return null; + } + + private static string HtmlTargetElementAttribute_Tag(AttributeData attibute) + { + if (attibute.ConstructorArguments.Length == 0) + { + return TagHelperMatchingConventions.ElementCatchAllName; + } + else + { + return (string)attibute.ConstructorArguments[0].Value; + } + } + + private static TagStructure HtmlTargetElementAttribute_TagStructure(AttributeData attibute) + { + foreach (var kvp in attibute.NamedArguments) + { + if (kvp.Key == TagHelperTypes.HtmlTargetElement.TagStructure) + { + return (TagStructure)kvp.Value.Value; + } + } + + return TagStructure.Unspecified; + } + + private bool IsPotentialDictionaryProperty(IPropertySymbol property) + { + return + (SymbolEqualityComparer.Default.Equals((property.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol) || property.Type.AllInterfaces.Any(s => SymbolEqualityComparer.Default.Equals(s.ConstructedFrom, _iDictionarySymbol))) && + GetDictionaryArgumentTypes(property)?[0].SpecialType == SpecialType.System_String; + } + + private IEnumerable GetAccessibleProperties(INamedTypeSymbol typeSymbol) + { + var accessibleProperties = new Dictionary(StringComparer.Ordinal); + do + { + var members = typeSymbol.GetMembers(); + for (var i = 0; i < members.Length; i++) + { + var property = members[i] as IPropertySymbol; + if (property != null && + property.Parameters.Length == 0 && + property.GetMethod != null && + property.GetMethod.DeclaredAccessibility == Accessibility.Public && + property.GetAttributes().Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _htmlAttributeNotBoundAttributeSymbol)).FirstOrDefault() == null && + (property.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _htmlAttributeNameAttributeSymbol)) || + property.SetMethod != null && property.SetMethod.DeclaredAccessibility == Accessibility.Public || + IsPotentialDictionaryProperty(property)) && + !accessibleProperties.ContainsKey(property.Name)) + { + accessibleProperties.Add(property.Name, property); + } + } + + typeSymbol = typeSymbol.BaseType; + } + while (typeSymbol != null); + + return accessibleProperties.Values; + } + + private bool ShouldSkipDescriptorCreation(ISymbol symbol) + { + if (ExcludeHidden) + { + var editorBrowsableAttribute = symbol.GetAttributes().Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _editorBrowsableAttributeSymbol)).FirstOrDefault(); + + if (editorBrowsableAttribute == null) + { + return false; + } + + if (editorBrowsableAttribute.ConstructorArguments.Length > 0) + { + return (EditorBrowsableState)editorBrowsableAttribute.ConstructorArguments[0].Value == EditorBrowsableState.Never; + } + } + + return false; + } + + protected static string GetFullName(ITypeSymbol type) => type.ToDisplayString(FullNameTypeDisplayFormat); + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..074ad68527 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorProvider.cs @@ -0,0 +1,69 @@ +// 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; + +namespace Microsoft.CodeAnalysis.Razor +{ + public sealed class DefaultTagHelperDescriptorProvider : 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 iTagHelper = compilation.GetTypeByMetadataName(TagHelperTypes.ITagHelper); + if (iTagHelper == null || iTagHelper.TypeKind == TypeKind.Error) + { + // Could not find attributes we care about in the compilation. Nothing to do. + return; + } + + var types = new List(); + var visitor = new TagHelperTypeVisitor(iTagHelper, 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 DefaultTagHelperDescriptorFactory(compilation, context.IncludeDocumentation, context.ExcludeHidden); + 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); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs new file mode 100644 index 0000000000..fa8bd25e27 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTypeNameFeature.cs @@ -0,0 +1,56 @@ +// 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.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class DefaultTypeNameFeature : TypeNameFeature + { + public override IReadOnlyList ParseTypeParameters(string typeName) + { + if (typeName == null) + { + throw new ArgumentNullException(nameof(typeName)); + } + + var parsed = SyntaxFactory.ParseTypeName(typeName); + if (parsed is IdentifierNameSyntax identifier) + { + return Array.Empty(); + } + else + { + return parsed.DescendantNodesAndSelf() + .OfType() + .SelectMany(arg => arg.Arguments) + .Select(a => a.ToString()).ToList(); + } + } + + public override TypeNameRewriter CreateGenericTypeRewriter(Dictionary bindings) + { + if (bindings == null) + { + throw new ArgumentNullException(nameof(bindings)); + } + + return new GenericTypeNameRewriter(bindings); + } + + public override TypeNameRewriter CreateGlobalQualifiedTypeNameRewriter(ICollection ignore) + { + if (ignore == null) + { + throw new ArgumentNullException(nameof(ignore)); + } + + return new GlobalQualifiedTypeNameRewriter(ignore); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..9f5cf0d20a --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs @@ -0,0 +1,296 @@ +// 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.AspNetCore.Razor.Language.Components; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class EventHandlerTagHelperDescriptorProvider : ITagHelperDescriptorProvider + { + public int Order { get; set; } + + public RazorEngine Engine { get; set; } + + public void Execute(TagHelperDescriptorProviderContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var compilation = context.GetCompilation(); + if (compilation == null) + { + return; + } + + var bindMethods = compilation.GetTypeByMetadataName(ComponentsApi.IComponent.FullTypeName); + if (bindMethods == null) + { + // If we can't find IComponent, then just bail. We won't be able to compile the + // generated code anyway. + return; + } + + var eventHandlerData = GetEventHandlerData(compilation); + + foreach (var tagHelper in CreateEventHandlerTagHelpers(eventHandlerData)) + { + context.Results.Add(tagHelper); + } + } + + private List GetEventHandlerData(Compilation compilation) + { + var eventHandlerAttribute = compilation.GetTypeByMetadataName(ComponentsApi.EventHandlerAttribute.FullTypeName); + if (eventHandlerAttribute == null) + { + // This won't likely happen, but just in case. + return new List(); + } + + var types = new List(); + var visitor = new EventHandlerDataVisitor(types); + + // Visit the primary output of this compilation, as well as all references. + visitor.Visit(compilation.Assembly); + foreach (var reference in compilation.References) + { + // We ignore .netmodules here - there really isn't a case where they are used by user code + // even though the Roslyn APIs all support them. + if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) + { + visitor.Visit(assembly); + } + } + + var results = new List(); + + for (var i = 0; i < types.Count; i++) + { + var type = types[i]; + var attributes = type.GetAttributes(); + + // Not handling duplicates here for now since we're the primary ones extending this. + // If we see users adding to the set of event handler constructs we will want to add deduplication + // and potentially diagnostics. + for (var j = 0; j < attributes.Length; j++) + { + var attribute = attributes[j]; + + if (SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, eventHandlerAttribute)) + { + var enablePreventDefault = false; + var enableStopPropagation = false; + if (attribute.ConstructorArguments.Length == 4) + { + enablePreventDefault = (bool)attribute.ConstructorArguments[2].Value; + enableStopPropagation = (bool)attribute.ConstructorArguments[3].Value; + } + + results.Add(new EventHandlerData( + type.ContainingAssembly.Name, + type.ToDisplayString(), + (string)attribute.ConstructorArguments[0].Value, + (INamedTypeSymbol)attribute.ConstructorArguments[1].Value, + enablePreventDefault, + enableStopPropagation)); + } + } + } + + return results; + } + + private List CreateEventHandlerTagHelpers(List data) + { + var results = new List(); + + for (var i = 0; i < data.Count; i++) + { + var entry = data[i]; + var attributeName = "@" + entry.Attribute; + var eventArgType = entry.EventArgsType.ToDisplayString(); + + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.EventHandler.TagHelperKind, entry.Attribute, ComponentsApi.AssemblyName); + builder.CaseSensitive = true; + builder.Documentation = string.Format( + ComponentResources.EventHandlerTagHelper_Documentation, + attributeName, + eventArgType); + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.EventHandler.TagHelperKind); + builder.Metadata.Add(ComponentMetadata.EventHandler.EventArgsType, eventArgType); + builder.Metadata.Add(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.EventHandler.RuntimeName; + + // WTE has a bug in 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + builder.SetTypeName(entry.TypeName); + + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + + rule.Attribute(a => + { + a.Name = attributeName; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + if (entry.EnablePreventDefault) + { + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + + rule.Attribute(a => + { + a.Name = attributeName + ":preventDefault"; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + } + + if (entry.EnableStopPropagation) + { + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + + rule.Attribute(a => + { + a.Name = attributeName + ":stopPropagation"; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + } + + builder.BindAttribute(a => + { + a.Documentation = string.Format( + ComponentResources.EventHandlerTagHelper_Documentation, + attributeName, + eventArgType); + + a.Name = attributeName; + + // We want event handler directive attributes to default to C# context. + a.TypeName = $"Microsoft.AspNetCore.Components.EventCallback<{eventArgType}>"; + + // But make this weakly typed (don't type check) - delegates have their own type-checking + // logic that we don't want to interfere with. + a.Metadata.Add(ComponentMetadata.Component.WeaklyTypedKey, bool.TrueString); + + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + a.SetPropertyName(entry.Attribute); + + if (entry.EnablePreventDefault) + { + a.BindAttributeParameter(parameter => + { + parameter.Name = "preventDefault"; + parameter.TypeName = typeof(bool).FullName; + parameter.Documentation = string.Format(ComponentResources.EventHandlerTagHelper_PreventDefault_Documentation, attributeName); + + parameter.SetPropertyName("PreventDefault"); + }); + } + + if (entry.EnableStopPropagation) + { + a.BindAttributeParameter(parameter => + { + parameter.Name = "stopPropagation"; + parameter.TypeName = typeof(bool).FullName; + parameter.Documentation = string.Format(ComponentResources.EventHandlerTagHelper_StopPropagation_Documentation, attributeName); + + parameter.SetPropertyName("StopPropagation"); + }); + } + }); + + results.Add(builder.Build()); + } + + return results; + } + + private struct EventHandlerData + { + public EventHandlerData( + string assembly, + string typeName, + string element, + INamedTypeSymbol eventArgsType, + bool enablePreventDefault, + bool enableStopPropagation) + { + Assembly = assembly; + TypeName = typeName; + Attribute = element; + EventArgsType = eventArgsType; + EnablePreventDefault = enablePreventDefault; + EnableStopPropagation = enableStopPropagation; + } + + public string Assembly { get; } + + public string TypeName { get; } + + public string Attribute { get; } + + public INamedTypeSymbol EventArgsType { get; } + + public bool EnablePreventDefault { get; } + + public bool EnableStopPropagation { get; } + } + + private class EventHandlerDataVisitor : SymbolVisitor + { + private List _results; + + public EventHandlerDataVisitor(List results) + { + _results = results; + } + + public override void VisitNamedType(INamedTypeSymbol symbol) + { + if (symbol.Name == "EventHandlers" && symbol.DeclaredAccessibility == Accessibility.Public) + { + _results.Add(symbol); + } + } + + public override void VisitNamespace(INamespaceSymbol symbol) + { + foreach (var member in symbol.GetMembers()) + { + Visit(member); + } + } + + public override void VisitAssembly(IAssemblySymbol symbol) + { + // This as a simple yet high-value optimization that excludes the vast majority of + // assemblies that (by definition) can't contain a component. + if (symbol.Name != null && !symbol.Name.StartsWith("System.", StringComparison.Ordinal)) + { + Visit(symbol.GlobalNamespace); + } + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/FilePathComparer.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/FilePathComparer.cs new file mode 100644 index 0000000000..a0ca3cb9a3 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/FilePathComparer.cs @@ -0,0 +1,30 @@ +// 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.Runtime.InteropServices; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class FilePathComparer + { + private static StringComparer _instance; + + public static StringComparer Instance + { + get + { + if (_instance == null && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + _instance = StringComparer.Ordinal; + } + else if (_instance == null) + { + _instance = StringComparer.OrdinalIgnoreCase; + } + + return _instance; + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/FilePathComparison.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/FilePathComparison.cs new file mode 100644 index 0000000000..057f71cb86 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/FilePathComparison.cs @@ -0,0 +1,30 @@ +// 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.Runtime.InteropServices; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class FilePathComparison + { + private static StringComparison? _instance; + + public static StringComparison Instance + { + get + { + if (_instance == null && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + _instance = StringComparison.Ordinal; + } + else if (_instance == null) + { + _instance = StringComparison.OrdinalIgnoreCase; + } + + return _instance.Value; + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/GenericTypeNameRewriter.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/GenericTypeNameRewriter.cs new file mode 100644 index 0000000000..f1b13b728a --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/GenericTypeNameRewriter.cs @@ -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.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class GenericTypeNameRewriter : TypeNameRewriter + { + private readonly Dictionary _bindings; + + public GenericTypeNameRewriter(Dictionary bindings) + { + _bindings = bindings; + } + + public override string Rewrite(string typeName) + { + var parsed = SyntaxFactory.ParseTypeName(typeName); + var rewritten = (TypeSyntax)new Visitor(_bindings).Visit(parsed); + return rewritten.ToFullString(); + } + + private class Visitor : CSharpSyntaxRewriter + { + private readonly Dictionary _bindings; + + public Visitor(Dictionary bindings) + { + _bindings = bindings; + } + + public override SyntaxNode Visit(SyntaxNode node) + { + // We can handle a single IdentifierNameSyntax at the top level (like 'TItem) + // OR a GenericNameSyntax recursively (like `List`) + if (node is IdentifierNameSyntax identifier && !(identifier.Parent is QualifiedNameSyntax)) + { + if (_bindings.TryGetValue(identifier.Identifier.Text, out var binding)) + { + // If we don't have a valid replacement, use object. This will make the code at least reasonable + // compared to leaving the type parameter in place. + // + // We add our own diagnostics for missing/invalid type parameters anyway. + var replacement = binding == null ? typeof(object).FullName : binding; + return identifier.Update(SyntaxFactory.Identifier(replacement)); + } + } + + return base.Visit(node); + } + + public override SyntaxNode VisitGenericName(GenericNameSyntax node) + { + var args = node.TypeArgumentList.Arguments; + for (var i = 0; i < args.Count; i++) + { + var typeArgument = args[i]; + args = args.Replace(typeArgument, (TypeSyntax)Visit(typeArgument)); + } + + return node.WithTypeArgumentList(node.TypeArgumentList.WithArguments(args)); + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/GlobalQualifiedTypeNameRewriter.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/GlobalQualifiedTypeNameRewriter.cs new file mode 100644 index 0000000000..6796f269ac --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/GlobalQualifiedTypeNameRewriter.cs @@ -0,0 +1,79 @@ +// 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.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Microsoft.CodeAnalysis.Razor +{ + // Rewrites type names to use the 'global::' prefix for identifiers. + // + // This is useful when we're generating code in a different namespace than + // what the user code lives in. When we synthesize a namespace it's easy to have + // clashes. + internal class GlobalQualifiedTypeNameRewriter : TypeNameRewriter + { + // List of names to ignore. + // + // NOTE: this is the list of type parameters defined on the component. + private readonly HashSet _ignore; + + public GlobalQualifiedTypeNameRewriter(ICollection ignore) + { + _ignore = new HashSet(ignore); + } + + public override string Rewrite(string typeName) + { + var parsed = SyntaxFactory.ParseTypeName(typeName); + var rewritten = (TypeSyntax)new Visitor(_ignore).Visit(parsed); + return rewritten.ToFullString(); + } + + private class Visitor : CSharpSyntaxRewriter + { + private readonly HashSet _ignore; + + public Visitor(HashSet ignore) + { + _ignore = ignore; + } + + public override SyntaxNode Visit(SyntaxNode node) + { + return base.Visit(node); + } + + public override SyntaxNode VisitQualifiedName(QualifiedNameSyntax node) + { + if (node.Parent is QualifiedNameSyntax) + { + return base.VisitQualifiedName(node); + } + + // Need to rewrite postorder so we can rewrite the names of generic type arguments. + node = (QualifiedNameSyntax)base.VisitQualifiedName(node); + + // Rewriting these is complicated, best to just tostring and parse again. + return SyntaxFactory.ParseTypeName("global::" + node.ToString()); + } + + public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node) + { + if (_ignore.Contains(node.ToString())) + { + return node; + } + + if (node.Parent != null) + { + return node; + } + + return SyntaxFactory.AliasQualifiedName(SyntaxFactory.IdentifierName(SyntaxFactory.Token(CSharp.SyntaxKind.GlobalKeyword)), node); + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/IMetadataReferenceFeature.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/IMetadataReferenceFeature.cs new file mode 100644 index 0000000000..319f5fa1b3 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/IMetadataReferenceFeature.cs @@ -0,0 +1,13 @@ +// 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 System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Razor +{ + public interface IMetadataReferenceFeature : IRazorEngineFeature + { + IReadOnlyList References { get; } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..789abca318 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs @@ -0,0 +1,80 @@ +// 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.Components; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class KeyTagHelperDescriptorProvider : ITagHelperDescriptorProvider + { + // Run after the component tag helper provider + public int Order { get; set; } = 1000; + + public RazorEngine Engine { get; set; } + + public void Execute(TagHelperDescriptorProviderContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var compilation = context.GetCompilation(); + if (compilation == null) + { + return; + } + + var renderTreeBuilderType = compilation.GetTypeByMetadataName(ComponentsApi.RenderTreeBuilder.FullTypeName); + if (renderTreeBuilderType == null) + { + // If we can't find RenderTreeBuilder, then just bail. We won't be able to compile the + // generated code anyway. + return; + } + + context.Results.Add(CreateKeyTagHelper()); + } + + private TagHelperDescriptor CreateKeyTagHelper() + { + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Key.TagHelperKind, "Key", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; + builder.Documentation = ComponentResources.KeyTagHelper_Documentation; + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Key.TagHelperKind); + builder.Metadata.Add(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Key.RuntimeName; + + // WTE has a bug in 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + builder.SetTypeName("Microsoft.AspNetCore.Components.Key"); + + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + rule.Attribute(attribute => + { + attribute.Name = "@key"; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + builder.BindAttribute(attribute => + { + attribute.Documentation = ComponentResources.KeyTagHelper_Documentation; + attribute.Name = "@key"; + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + attribute.SetPropertyName("Key"); + attribute.TypeName = typeof(object).FullName; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + + return builder.Build(); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/Microsoft.CodeAnalysis.Razor.csproj b/src/Razor/Microsoft.CodeAnalysis.Razor/src/Microsoft.CodeAnalysis.Razor.csproj new file mode 100644 index 0000000000..5a294ccb6c --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/Microsoft.CodeAnalysis.Razor.csproj @@ -0,0 +1,16 @@ + + + + Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure. + netstandard2.0 + + + + + + + + + + + diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/Properties/AssemblyInfo.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c83b18dbc5 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/Properties/AssemblyInfo.cs @@ -0,0 +1,25 @@ +// 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("Microsoft.AspNetCore.Razor.OmniSharpPlugin.StrongNamed, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("rzc, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Common.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorDiagnosticFactory.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorDiagnosticFactory.cs new file mode 100644 index 0000000000..55705b5eac --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorDiagnosticFactory.cs @@ -0,0 +1,175 @@ +// 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; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class RazorDiagnosticFactory + { + private const string DiagnosticPrefix = "RZ"; + + // Razor.Language starts at 0, 1000, 2000, 3000. Therefore, we should offset by 500 to ensure we can easily + // maintain this list of diagnostic descriptors in conjunction with the one in Razor.Language. + + #region General Errors + + // General Errors ID Offset = 500 + + #endregion + + #region Language Errors + + // Language Errors ID Offset = 1500 + + #endregion + + #region Semantic Errors + + // Semantic Errors ID Offset = 2500 + + #endregion + + #region TagHelper Errors + + // TagHelper Errors ID Offset = 3500 + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidAttributeNameNullOrEmpty = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3500", + () => Resources.TagHelper_InvalidAttributeNameNotNullOrEmpty, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidAttributeNameNullOrEmpty(string tagHelperDisplayName, string propertyDisplayName) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InvalidAttributeNameNullOrEmpty, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + tagHelperDisplayName, + propertyDisplayName, + TagHelperTypes.HtmlAttributeNameAttribute, + TagHelperTypes.HtmlAttributeName.Name); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidAttributePrefixNotNull = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3501", + () => Resources.TagHelper_InvalidAttributePrefixNotNull, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidAttributePrefixNotNull(string tagHelperDisplayName, string propertyDisplayName) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InvalidAttributePrefixNotNull, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + tagHelperDisplayName, + propertyDisplayName, + TagHelperTypes.HtmlAttributeNameAttribute, + TagHelperTypes.HtmlAttributeName.DictionaryAttributePrefix, + "IDictionary"); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidAttributePrefixNull = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3502", + () => Resources.TagHelper_InvalidAttributePrefixNull, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidAttributePrefixNull(string tagHelperDisplayName, string propertyDisplayName) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InvalidAttributePrefixNull, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + tagHelperDisplayName, + propertyDisplayName, + TagHelperTypes.HtmlAttributeNameAttribute, + TagHelperTypes.HtmlAttributeName.DictionaryAttributePrefix, + "IDictionary"); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidRequiredAttributeCharacter = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3503", + () => Resources.TagHelper_InvalidRequiredAttributeCharacter, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidRequiredAttributeCharacter(char invalidCharacter, string requiredAttributes) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InvalidRequiredAttributeCharacter, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + invalidCharacter, + requiredAttributes); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_PartialRequiredAttributeOperator = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3504", + () => Resources.TagHelper_PartialRequiredAttributeOperator, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_PartialRequiredAttributeOperator(char partialOperator, string requiredAttributes) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_PartialRequiredAttributeOperator, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + requiredAttributes, + partialOperator); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidRequiredAttributeOperator = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3505", + () => Resources.TagHelper_InvalidRequiredAttributeOperator, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidRequiredAttributeOperator(char invalidOperator, string requiredAttributes) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InvalidRequiredAttributeOperator, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + invalidOperator, + requiredAttributes); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_InvalidRequiredAttributeMismatchedQuotes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3506", + () => Resources.TagHelper_InvalidRequiredAttributeMismatchedQuotes, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_InvalidRequiredAttributeMismatchedQuotes(char quote, string requiredAttributes) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_InvalidRequiredAttributeMismatchedQuotes, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + requiredAttributes, + quote); + + return diagnostic; + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_CouldNotFindMatchingEndBrace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}3507", + () => Resources.TagHelper_CouldNotFindMatchingEndBrace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateTagHelper_CouldNotFindMatchingEndBrace(string requiredAttributes) + { + var diagnostic = RazorDiagnostic.Create( + TagHelper_CouldNotFindMatchingEndBrace, + new SourceSpan(SourceLocation.Undefined, contentLength: 0), + requiredAttributes); + + return diagnostic; + } + + + #endregion + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorLanguage.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorLanguage.cs new file mode 100644 index 0000000000..cd0bbb148e --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorLanguage.cs @@ -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.CodeAnalysis.Razor +{ + public static class RazorLanguage + { + public const string Name = "Razor"; + + public const string ContentType = "RazorCSharp"; + + public const string CoreContentType = "RazorCoreCSharp"; + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorProjectEngineBuilderExtensions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorProjectEngineBuilderExtensions.cs new file mode 100644 index 0000000000..e492643723 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RazorProjectEngineBuilderExtensions.cs @@ -0,0 +1,91 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.CSharp; + +namespace Microsoft.CodeAnalysis.Razor +{ + /// + /// Roslyn specific extensions. + /// + public static class RazorProjectEngineBuilderExtensions + { + /// + /// Sets the C# language version to target when generating code. + /// + /// The . + /// The C# . + /// The . + public static RazorProjectEngineBuilder SetCSharpLanguageVersion(this RazorProjectEngineBuilder builder, LanguageVersion csharpLanguageVersion) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + var existingFeature = builder.Features.OfType().FirstOrDefault(); + if (existingFeature != null) + { + builder.Features.Remove(existingFeature); + } + + // This will convert any "latest", "default" or "LatestMajor" LanguageVersions into their numerical equivalent. + var effectiveCSharpLanguageVersion = LanguageVersionFacts.MapSpecifiedToEffectiveVersion(csharpLanguageVersion); + builder.Features.Add(new ConfigureParserForCSharpVersionFeature(effectiveCSharpLanguageVersion)); + + return builder; + } + + // Internal for testing + internal class ConfigureParserForCSharpVersionFeature : IConfigureRazorCodeGenerationOptionsFeature + { + public ConfigureParserForCSharpVersionFeature(LanguageVersion csharpLanguageVersion) + { + CSharpLanguageVersion = csharpLanguageVersion; + } + + public LanguageVersion CSharpLanguageVersion { get; } + + public int Order { get; set; } + + public RazorEngine Engine { get; set; } + + public void Configure(RazorCodeGenerationOptionsBuilder options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + if (options.Configuration != null && options.Configuration.LanguageVersion.Major < 3) + { + // Prior to 3.0 there were no C# version specific controlled features. Suppress nullability enforcement. + options.SuppressNullabilityEnforcement = true; + return; + } + + if (CSharpLanguageVersion < LanguageVersion.CSharp8) + { + // Having nullable flags < C# 8.0 would cause compile errors. + options.SuppressNullabilityEnforcement = true; + } + else + { + // Given that nullability enforcement can be a compile error we only turn it on for C# >= 8.0. There are + // cases in tooling when the project isn't fully configured yet at which point the CSharpLanguageVersion + // may be Default (value 0). In those cases that C# version is equivalently "unspecified" and is up to the consumer + // to act in a safe manner to not cause unneeded errors for older compilers. Therefore if the version isn't + // >= 8.0 (Latest has a higher value) then nullability enforcement is suppressed. + // + // Once the project finishes configuration the C# language version will be updated to reflect the effective + // language version for the project by our workspace change detectors. That mechanism extracts the correlated + // Roslyn project and acquires the effective C# version at that point. + options.SuppressNullabilityEnforcement = false; + } + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..1eafca4181 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs @@ -0,0 +1,80 @@ +// 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.Components; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class RefTagHelperDescriptorProvider : ITagHelperDescriptorProvider + { + // Run after the component tag helper provider, because later we may want component-type-specific variants of this + public int Order { get; set; } = 1000; + + public RazorEngine Engine { get; set; } + + public void Execute(TagHelperDescriptorProviderContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var compilation = context.GetCompilation(); + if (compilation == null) + { + return; + } + + var elementReference = compilation.GetTypeByMetadataName(ComponentsApi.ElementReference.FullTypeName); + if (elementReference == null) + { + // If we can't find ElementRef, then just bail. We won't be able to compile the + // generated code anyway. + return; + } + + context.Results.Add(CreateRefTagHelper()); + } + + private TagHelperDescriptor CreateRefTagHelper() + { + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Ref.TagHelperKind, "Ref", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; + builder.Documentation = ComponentResources.RefTagHelper_Documentation; + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Ref.TagHelperKind); + builder.Metadata.Add(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Ref.RuntimeName; + + // WTE has a bug in 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + builder.SetTypeName("Microsoft.AspNetCore.Components.Ref"); + + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + rule.Attribute(attribute => + { + attribute.Name = "@ref"; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + builder.BindAttribute(attribute => + { + attribute.Documentation = ComponentResources.RefTagHelper_Documentation; + attribute.Name = "@ref"; + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + attribute.SetPropertyName("Ref"); + attribute.TypeName = typeof(object).FullName; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + + return builder.Build(); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RequiredAttributeParser.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RequiredAttributeParser.cs new file mode 100644 index 0000000000..898e065439 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RequiredAttributeParser.cs @@ -0,0 +1,304 @@ +// 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 Microsoft.AspNetCore.Razor.Language; + +namespace Microsoft.CodeAnalysis.Razor +{ + // Internal for testing + internal static class RequiredAttributeParser + { + public static void AddRequiredAttributes(string requiredAttributes, TagMatchingRuleDescriptorBuilder ruleBuilder) + { + var requiredAttributeParser = new DefaultRequiredAttributeParser(requiredAttributes); + requiredAttributeParser.AddRequiredAttributes(ruleBuilder); + } + + private class DefaultRequiredAttributeParser + { + private const char RequiredAttributeWildcardSuffix = '*'; + + private static readonly IReadOnlyDictionary CssValueComparisons = + new Dictionary + { + { '=', RequiredAttributeDescriptor.ValueComparisonMode.FullMatch }, + { '^', RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch }, + { '$', RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch } + }; + private static readonly char[] InvalidPlainAttributeNameCharacters = { ' ', '\t', ',', RequiredAttributeWildcardSuffix }; + private static readonly char[] InvalidCssAttributeNameCharacters = (new[] { ' ', '\t', ',', ']' }) + .Concat(CssValueComparisons.Keys) + .ToArray(); + private static readonly char[] InvalidCssQuotelessValueCharacters = { ' ', '\t', ']' }; + + private int _index; + private string _requiredAttributes; + + public DefaultRequiredAttributeParser(string requiredAttributes) + { + _requiredAttributes = requiredAttributes; + } + + private char Current => _requiredAttributes[_index]; + + private bool AtEnd => _index >= _requiredAttributes.Length; + + public void AddRequiredAttributes(TagMatchingRuleDescriptorBuilder ruleBuilder) + { + if (string.IsNullOrEmpty(_requiredAttributes)) + { + return; + } + var descriptors = new List(); + + PassOptionalWhitespace(); + + do + { + var successfulParse = true; + ruleBuilder.Attribute(attributeBuilder => + { + if (At('[')) + { + if (!TryParseCssSelector(attributeBuilder)) + { + successfulParse = false; + return; + } + } + else + { + ParsePlainSelector(attributeBuilder); + } + + PassOptionalWhitespace(); + + if (At(',')) + { + _index++; + + if (!EnsureNotAtEnd(attributeBuilder)) + { + successfulParse = false; + return; + } + } + else if (!AtEnd) + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeCharacter(Current, _requiredAttributes); + attributeBuilder.Diagnostics.Add(diagnostic); + successfulParse = false; + return; + } + + PassOptionalWhitespace(); + }); + + if (!successfulParse) + { + break; + } + } + while (!AtEnd); + } + + private void ParsePlainSelector(RequiredAttributeDescriptorBuilder attributeBuilder) + { + var nameEndIndex = _requiredAttributes.IndexOfAny(InvalidPlainAttributeNameCharacters, _index); + string attributeName; + + var nameComparison = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + if (nameEndIndex == -1) + { + attributeName = _requiredAttributes.Substring(_index); + _index = _requiredAttributes.Length; + } + else + { + attributeName = _requiredAttributes.Substring(_index, nameEndIndex - _index); + _index = nameEndIndex; + + if (_requiredAttributes[nameEndIndex] == RequiredAttributeWildcardSuffix) + { + nameComparison = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch; + + // Move past wild card + _index++; + } + } + + attributeBuilder.Name = attributeName; + attributeBuilder.NameComparisonMode = nameComparison; + } + + private void ParseCssAttributeName(RequiredAttributeDescriptorBuilder builder) + { + var nameStartIndex = _index; + var nameEndIndex = _requiredAttributes.IndexOfAny(InvalidCssAttributeNameCharacters, _index); + nameEndIndex = nameEndIndex == -1 ? _requiredAttributes.Length : nameEndIndex; + _index = nameEndIndex; + + var attributeName = _requiredAttributes.Substring(nameStartIndex, nameEndIndex - nameStartIndex); + + builder.Name = attributeName; + } + + private bool TryParseCssValueComparison(RequiredAttributeDescriptorBuilder builder, out RequiredAttributeDescriptor.ValueComparisonMode valueComparison) + { + Debug.Assert(!AtEnd); + + if (CssValueComparisons.TryGetValue(Current, out valueComparison)) + { + var op = Current; + _index++; + + if (op != '=' && At('=')) + { + // Two length operator (ex: ^=). Move past the second piece + _index++; + } + else if (op != '=') // We're at an incomplete operator (ex: [foo^] + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_PartialRequiredAttributeOperator(op, _requiredAttributes); + builder.Diagnostics.Add(diagnostic); + + return false; + } + } + else if (!At(']')) + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeOperator(Current, _requiredAttributes); + builder.Diagnostics.Add(diagnostic); + + return false; + } + + builder.ValueComparisonMode = valueComparison; + + return true; + } + + private bool TryParseCssValue(RequiredAttributeDescriptorBuilder builder) + { + int valueStart; + int valueEnd; + if (At('\'') || At('"')) + { + var quote = Current; + + // Move past the quote + _index++; + + valueStart = _index; + valueEnd = _requiredAttributes.IndexOf(quote, _index); + if (valueEnd == -1) + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeMismatchedQuotes(quote, _requiredAttributes); + builder.Diagnostics.Add(diagnostic); + + return false; + } + _index = valueEnd + 1; + } + else + { + valueStart = _index; + var valueEndIndex = _requiredAttributes.IndexOfAny(InvalidCssQuotelessValueCharacters, _index); + valueEnd = valueEndIndex == -1 ? _requiredAttributes.Length : valueEndIndex; + _index = valueEnd; + } + + var value = _requiredAttributes.Substring(valueStart, valueEnd - valueStart); + + builder.Value = value; + + return true; + } + + private bool TryParseCssSelector(RequiredAttributeDescriptorBuilder attributeBuilder) + { + Debug.Assert(At('[')); + + // Move past '['. + _index++; + PassOptionalWhitespace(); + + ParseCssAttributeName(attributeBuilder); + + PassOptionalWhitespace(); + + if (!EnsureNotAtEnd(attributeBuilder)) + { + return false; + } + + if (!TryParseCssValueComparison(attributeBuilder, out RequiredAttributeDescriptor.ValueComparisonMode valueComparison)) + { + return false; + } + + PassOptionalWhitespace(); + + if (!EnsureNotAtEnd(attributeBuilder)) + { + return false; + } + + if (valueComparison != RequiredAttributeDescriptor.ValueComparisonMode.None && !TryParseCssValue(attributeBuilder)) + { + return false; + } + + PassOptionalWhitespace(); + + if (At(']')) + { + // Move past the ending bracket. + _index++; + return true; + } + else if (AtEnd) + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace(_requiredAttributes); + attributeBuilder.Diagnostics.Add(diagnostic); + } + else + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeCharacter(Current, _requiredAttributes); + attributeBuilder.Diagnostics.Add(diagnostic); + } + + return false; + } + + private bool EnsureNotAtEnd(RequiredAttributeDescriptorBuilder builder) + { + if (AtEnd) + { + var diagnostic = RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace(_requiredAttributes); + builder.Diagnostics.Add(diagnostic); + + return false; + } + + return true; + } + + private bool At(char c) + { + return !AtEnd && Current == c; + } + + private void PassOptionalWhitespace() + { + while (!AtEnd && (Current == ' ' || Current == '\t')) + { + _index++; + } + } + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/Resources.resx b/src/Razor/Microsoft.CodeAnalysis.Razor/src/Resources.resx new file mode 100644 index 0000000000..7527a23812 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/Resources.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Could not find matching ']' for required attribute '{0}'. + + + Invalid tag helper bound property '{1}' on tag helper '{0}'. '{2}.{3}' must be null unless property type implements '{4}'. + + + Invalid tag helper bound property '{1}' on tag helper '{0}'. '{2}.{3}' must be null or empty if property has no public setter. + + + Invalid tag helper bound property '{1}' on tag helper '{0}'. '{2}.{3}' must not be null if property has no public setter and its type implements '{4}'. + + + Invalid required attribute character '{0}' in required attribute '{1}'. Separate required attributes with commas. + + + Required attribute '{0}' has mismatched quotes '{1}' around value. + + + Invalid character '{0}' in required attribute '{1}'. Expected supported CSS operator or ']'. + + + Required attribute '{0}' has a partial CSS operator. '{1}' must be followed by an equals. + + + Create a inline HTML element without tags. + + \ No newline at end of file diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/SourceSpanExtensions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/SourceSpanExtensions.cs new file mode 100644 index 0000000000..51fd517024 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/SourceSpanExtensions.cs @@ -0,0 +1,16 @@ +// 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.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class SourceSpanExtensions + { + public static TextSpan AsTextSpan(this SourceSpan sourceSpan) + { + return new TextSpan(sourceSpan.AbsoluteIndex, sourceSpan.Length); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs new file mode 100644 index 0000000000..3d64214427 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs @@ -0,0 +1,80 @@ +// 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.Components; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal class SplatTagHelperDescriptorProvider : ITagHelperDescriptorProvider + { + // Order doesn't matter + public int Order { get; set; } + + public RazorEngine Engine { get; set; } + + public void Execute(TagHelperDescriptorProviderContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var compilation = context.GetCompilation(); + if (compilation == null) + { + return; + } + + var renderTreeBuilder = compilation.GetTypeByMetadataName(ComponentsApi.RenderTreeBuilder.FullTypeName); + if (renderTreeBuilder == null) + { + // If we can't find RenderTreeBuilder, then just bail. We won't be able to compile the + // generated code anyway. + return; + } + + context.Results.Add(CreateSplatTagHelper()); + } + + private TagHelperDescriptor CreateSplatTagHelper() + { + var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Splat.TagHelperKind, "Attributes", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; + builder.Documentation = ComponentResources.SplatTagHelper_Documentation; + + builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Splat.TagHelperKind); + builder.Metadata.Add(TagHelperMetadata.Common.ClassifyAttributesOnly, bool.TrueString); + builder.Metadata[TagHelperMetadata.Runtime.Name] = ComponentMetadata.Splat.RuntimeName; + + // WTE has a bug in 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + builder.SetTypeName("Microsoft.AspNetCore.Components.Attributes"); + + builder.TagMatchingRule(rule => + { + rule.TagName = "*"; + rule.Attribute(attribute => + { + attribute.Name = "@attributes"; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + + builder.BindAttribute(attribute => + { + attribute.Documentation = ComponentResources.SplatTagHelper_Documentation; + attribute.Name = "@attributes"; + + // WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like + // a C# property will crash trying to create the tooltips. + attribute.SetPropertyName("Attributes"); + attribute.TypeName = typeof(object).FullName; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + + return builder.Build(); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperDescriptorProviderContextExtensions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperDescriptorProviderContextExtensions.cs new file mode 100644 index 0000000000..fda4aece22 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperDescriptorProviderContextExtensions.cs @@ -0,0 +1,31 @@ +// 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.CodeAnalysis.Razor +{ + public static class TagHelperDescriptorProviderContextExtensions + { + public static Compilation GetCompilation(this TagHelperDescriptorProviderContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + return (Compilation)context.Items[typeof(Compilation)]; + } + + public static void SetCompilation(this TagHelperDescriptorProviderContext context, Compilation compilation) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + context.Items[typeof(Compilation)] = compilation; + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperTypeVisitor.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperTypeVisitor.cs new file mode 100644 index 0000000000..3387cfd1e8 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperTypeVisitor.cs @@ -0,0 +1,51 @@ +// 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; + +namespace Microsoft.CodeAnalysis.Razor +{ + // Visits top-level types and finds interface implementations. + internal class TagHelperTypeVisitor : SymbolVisitor + { + private INamedTypeSymbol _interface; + private List _results; + + public TagHelperTypeVisitor(INamedTypeSymbol @interface, List results) + { + _interface = @interface; + _results = results; + } + + public override void VisitNamedType(INamedTypeSymbol symbol) + { + if (IsTagHelper(symbol)) + { + _results.Add(symbol); + } + } + + public override void VisitNamespace(INamespaceSymbol symbol) + { + foreach (var member in symbol.GetMembers()) + { + Visit(member); + } + } + + internal bool IsTagHelper(INamedTypeSymbol symbol) + { + if (_interface == null) + { + return false; + } + + return + symbol.TypeKind != TypeKind.Error && + symbol.DeclaredAccessibility == Accessibility.Public && + !symbol.IsAbstract && + !symbol.IsGenericType && + symbol.AllInterfaces.Contains(_interface); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperTypes.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperTypes.cs new file mode 100644 index 0000000000..c0989576c7 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TagHelperTypes.cs @@ -0,0 +1,39 @@ +// 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.CodeAnalysis.Razor +{ + internal static class TagHelperTypes + { + public const string ITagHelper = "Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper"; + + public const string IComponent = "Microsoft.AspNetCore.Components.IComponent"; + + public const string IDictionary = "System.Collections.Generic.IDictionary`2"; + + public const string HtmlAttributeNameAttribute = "Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute"; + + public const string HtmlAttributeNotBoundAttribute = "Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute"; + + public const string HtmlTargetElementAttribute = "Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute"; + + public const string OutputElementHintAttribute = "Microsoft.AspNetCore.Razor.TagHelpers.OutputElementHintAttribute"; + + public const string RestrictChildrenAttribute = "Microsoft.AspNetCore.Razor.TagHelpers.RestrictChildrenAttribute"; + + public static class HtmlAttributeName + { + public const string Name = "Name"; + public const string DictionaryAttributePrefix = "DictionaryAttributePrefix"; + } + + public static class HtmlTargetElement + { + public const string Attributes = "Attributes"; + + public const string ParentTag = "ParentTag"; + + public const string TagStructure = "TagStructure"; + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/TextChangeExtensions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TextChangeExtensions.cs new file mode 100644 index 0000000000..95fd6ba899 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TextChangeExtensions.cs @@ -0,0 +1,22 @@ +// 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.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class TextChangeExtensions + { + public static SourceChange AsSourceChange(this TextChange textChange) + { + if (textChange == null) + { + throw new ArgumentNullException(nameof(textChange)); + } + + return new SourceChange(textChange.Span.AsSourceSpan(), textChange.NewText); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/TextSpanExtensions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TextSpanExtensions.cs new file mode 100644 index 0000000000..32e43de450 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/TextSpanExtensions.cs @@ -0,0 +1,16 @@ +// 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.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class TextSpanExtensions + { + public static SourceSpan AsSourceSpan(this TextSpan textSpan) + { + return new SourceSpan(filePath: null, absoluteIndex: textSpan.Start, lineIndex: -1, characterIndex: -1, length: textSpan.Length); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/baseline.netcore.json b/src/Razor/Microsoft.CodeAnalysis.Razor/src/baseline.netcore.json new file mode 100644 index 0000000000..f1d4169fe5 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/baseline.netcore.json @@ -0,0 +1,360 @@ +{ + "AssemblyIdentity": "Microsoft.CodeAnalysis.Razor, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperFeature" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetDescriptors", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperFeature", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnInitialized", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.DefaultMetadataReferenceFeature", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.CodeAnalysis.Razor.IMetadataReferenceFeature" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_References", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.CodeAnalysis.Razor.IMetadataReferenceFeature", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_References", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.IReadOnlyList" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.DefaultTagHelperDescriptorProvider", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_DesignTime", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DesignTime", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Order", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.IMetadataReferenceFeature", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorEngineFeature" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_References", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.RazorLanguage", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Razor\"" + }, + { + "Kind": "Field", + "Name": "ContentType", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"RazorCSharp\"" + }, + { + "Kind": "Field", + "Name": "CoreContentType", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"RazorCoreCSharp\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.TagHelperDescriptorProviderContextExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetCompilation", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "Microsoft.CodeAnalysis.Compilation", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetCompilation", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + }, + { + "Name": "compilation", + "Type": "Microsoft.CodeAnalysis.Compilation" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.TagHelperTypes+HtmlAttributeName", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Name\"" + }, + { + "Kind": "Field", + "Name": "DictionaryAttributePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"DictionaryAttributePrefix\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.TagHelperTypes+HtmlTargetElement", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Attributes", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Attributes\"" + }, + { + "Kind": "Field", + "Name": "ParentTag", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"ParentTag\"" + }, + { + "Kind": "Field", + "Name": "TagStructure", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"TagStructure\"" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/baseline.netframework.json b/src/Razor/Microsoft.CodeAnalysis.Razor/src/baseline.netframework.json new file mode 100644 index 0000000000..ceae4b237f --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/baseline.netframework.json @@ -0,0 +1,349 @@ +{ + "AssemblyIdentity": "Microsoft.CodeAnalysis.Razor, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperFeature" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetDescriptors", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperFeature", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "OnInitialized", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.DefaultMetadataReferenceFeature", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.CodeAnalysis.Razor.IMetadataReferenceFeature" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_References", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.CodeAnalysis.Razor.IMetadataReferenceFeature", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_References", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.IReadOnlyList" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.DefaultTagHelperDescriptorProvider", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Razor.Language.RazorEngineFeatureBase", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_DesignTime", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DesignTime", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Order", + "Parameters": [], + "ReturnType": "System.Int32", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Order", + "Parameters": [ + { + "Name": "value", + "Type": "System.Int32" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Razor.Language.ITagHelperDescriptorProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.IMetadataReferenceFeature", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Razor.Language.IRazorEngineFeature" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_References", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.RazorLanguage", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Razor\"" + }, + { + "Kind": "Field", + "Name": "ContentType", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"RazorCSharp\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.TagHelperDescriptorProviderContextExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetCompilation", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + } + ], + "ReturnType": "Microsoft.CodeAnalysis.Compilation", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetCompilation", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Razor.Language.TagHelperDescriptorProviderContext" + }, + { + "Name": "compilation", + "Type": "Microsoft.CodeAnalysis.Compilation" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.TagHelperTypes+HtmlAttributeName", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Name", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Name\"" + }, + { + "Kind": "Field", + "Name": "DictionaryAttributePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"DictionaryAttributePrefix\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.CodeAnalysis.Razor.TagHelperTypes+HtmlTargetElement", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Attributes", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Attributes\"" + }, + { + "Kind": "Field", + "Name": "ParentTag", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"ParentTag\"" + }, + { + "Kind": "Field", + "Name": "TagStructure", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"TagStructure\"" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..bd19fc23cb --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs @@ -0,0 +1,69 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public abstract class TagHelperDescriptorProviderTestBase + { + static TagHelperDescriptorProviderTestBase() + { + BaseCompilation = TestCompilation.Create(typeof(ComponentTagHelperDescriptorProviderTest).Assembly); + CSharpParseOptions = new CSharpParseOptions(LanguageVersion.CSharp7_3); + } + + protected static Compilation BaseCompilation { get; } + + protected static CSharpParseOptions CSharpParseOptions { get; } + + protected static CSharpSyntaxTree Parse(string text) + { + return (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, CSharpParseOptions); + } + + // For simplicity in testing, exclude the built-in components. We'll add more and we + // don't want to update the tests when that happens. + protected static TagHelperDescriptor[] ExcludeBuiltInComponents(TagHelperDescriptorProviderContext context) + { + var results = + context.Results + .Where(c => c.AssemblyName != "Microsoft.AspNetCore.Razor.Test.ComponentShim") + .Where(c => !c.DisplayName.StartsWith("Microsoft.AspNetCore.Components.Web")) + .Where(c => c.GetTypeName() != "Microsoft.AspNetCore.Components.Bind") + .OrderBy(c => c.Name) + .ToArray(); + + return results; + } + + protected static TagHelperDescriptor[] AssertAndExcludeFullyQualifiedNameMatchComponents( + TagHelperDescriptor[] components, + int expectedCount) + { + var componentLookup = new Dictionary>(); + var fullyQualifiedNameMatchComponents = components.Where(c => c.IsComponentFullyQualifiedNameMatch()).ToArray(); + Assert.Equal(expectedCount, fullyQualifiedNameMatchComponents.Length); + + var shortNameMatchComponents = components.Where(c => !c.IsComponentFullyQualifiedNameMatch()).ToArray(); + + // For every fully qualified name component, we want to make sure we have a corresponding short name component. + foreach (var fullNameComponent in fullyQualifiedNameMatchComponents) + { + Assert.Contains(shortNameMatchComponents, component => + { + return component.Name == fullNameComponent.Name && + component.Kind == fullNameComponent.Kind && + component.BoundAttributes.SequenceEqual(fullNameComponent.BoundAttributes, BoundAttributeDescriptorComparer.Default); + }); + } + + return shortNameMatchComponents; + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..f097b079f7 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs @@ -0,0 +1,905 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class BindTagHelperDescriptorProviderTest : TagHelperDescriptorProviderTestBase + { + [Fact] + public void Execute_FindsBindTagHelperOnComponentType_Delegate_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System; +using System.Linq.Expressions; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : IComponent + { + public void Attach(RenderHandle renderHandle) { } + + public Task SetParametersAsync(ParameterView parameters) + { + return Task.CompletedTask; + } + + [Parameter] + public string MyProperty { get; set; } + + [Parameter] + public Action MyPropertyChanged { get; set; } + + [Parameter] + public Expression> MyPropertyExpression { get; set; } + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + // We run after component discovery and depend on the results. + var componentProvider = new ComponentTagHelperDescriptorProvider(); + componentProvider.Execute(context); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 1); + var bind = Assert.Single(matches); + + // These are features Bind Tags Helpers don't use. Verifying them once here and + // then ignoring them. + Assert.Empty(bind.AllowedChildTags); + Assert.Null(bind.TagOutputHint); + + // These are features that are invariants of all Bind Tag Helpers. Verifying them once + // here and then ignoring them. + Assert.Empty(bind.Diagnostics); + Assert.False(bind.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, bind.Kind); + Assert.Equal(ComponentMetadata.Bind.RuntimeName, bind.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(bind.IsDefaultKind()); + Assert.False(bind.KindUsesDefaultTagHelperRuntime()); + Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); + + Assert.Equal("MyProperty", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("MyPropertyChanged", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.Equal("MyPropertyExpression", bind.Metadata[ComponentMetadata.Bind.ExpressionAttribute]); + + Assert.Equal( + "Binds the provided expression to the 'MyProperty' property and a change event " + + "delegate to the 'MyPropertyChanged' property of the component.", + bind.Documentation); + + // These are all trivially derived from the assembly/namespace/type name + Assert.Equal("TestAssembly", bind.AssemblyName); + Assert.Equal("Test.MyComponent", bind.Name); + Assert.Equal("Test.MyComponent", bind.DisplayName); + Assert.Equal("Test.MyComponent", bind.GetTypeName()); + + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes); + + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Binds the provided expression to the 'MyProperty' property and a change event " + + "delegate to the 'MyPropertyChanged' property of the component.", + attribute.Documentation); + + Assert.Equal("@bind-MyProperty", attribute.Name); + Assert.Equal("MyProperty", attribute.GetPropertyName()); + Assert.Equal("System.Action Test.MyComponent.MyProperty", attribute.DisplayName); + + // Defined from the property type + Assert.Equal("System.Action", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + } + + [Fact] + public void Execute_FindsBindTagHelperOnComponentType_EventCallback_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : IComponent + { + public void Attach(RenderHandle renderHandle) { } + + public Task SetParametersAsync(ParameterView parameters) + { + return Task.CompletedTask; + } + + [Parameter] + public string MyProperty { get; set; } + + [Parameter] + public EventCallback MyPropertyChanged { get; set; } + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + // We run after component discovery and depend on the results. + var componentProvider = new ComponentTagHelperDescriptorProvider(); + componentProvider.Execute(context); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 1); + var bind = Assert.Single(matches); + + // These are features Bind Tags Helpers don't use. Verifying them once here and + // then ignoring them. + Assert.Empty(bind.AllowedChildTags); + Assert.Null(bind.TagOutputHint); + + // These are features that are invariants of all Bind Tag Helpers. Verifying them once + // here and then ignoring them. + Assert.Empty(bind.Diagnostics); + Assert.False(bind.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, bind.Kind); + Assert.Equal(ComponentMetadata.Bind.RuntimeName, bind.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(bind.IsDefaultKind()); + Assert.False(bind.KindUsesDefaultTagHelperRuntime()); + Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); + + Assert.Equal("MyProperty", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("MyPropertyChanged", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + + Assert.Equal( + "Binds the provided expression to the 'MyProperty' property and a change event " + + "delegate to the 'MyPropertyChanged' property of the component.", + bind.Documentation); + + // These are all trivially derived from the assembly/namespace/type name + Assert.Equal("TestAssembly", bind.AssemblyName); + Assert.Equal("Test.MyComponent", bind.Name); + Assert.Equal("Test.MyComponent", bind.DisplayName); + Assert.Equal("Test.MyComponent", bind.GetTypeName()); + + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes); + + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Binds the provided expression to the 'MyProperty' property and a change event " + + "delegate to the 'MyPropertyChanged' property of the component.", + attribute.Documentation); + + Assert.Equal("@bind-MyProperty", attribute.Name); + Assert.Equal("MyProperty", attribute.GetPropertyName()); + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback Test.MyComponent.MyProperty", attribute.DisplayName); + + // Defined from the property type + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + } + + [Fact] + public void Execute_NoMatchedPropertiesOnComponent_IgnoresComponent() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : IComponent + { + public void Attach(RenderHandle renderHandle) { } + + public Task SetParametersAsync(ParameterView parameters) + { + return Task.CompletedTask; + } + + public string MyProperty { get; set; } + + public Action MyPropertyChangedNotMatch { get; set; } + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + // We run after component discovery and depend on the results. + var componentProvider = new ComponentTagHelperDescriptorProvider(); + componentProvider.Execute(context); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + Assert.Empty(matches); + } + + [Fact] + public void Execute_BindOnElement_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myprop"", ""myevent"")] + public class BindAttributes + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + var bind = Assert.Single(matches); + + // These are features Bind Tags Helpers don't use. Verifying them once here and + // then ignoring them. + Assert.Empty(bind.AllowedChildTags); + Assert.Null(bind.TagOutputHint); + + // These are features that are invariants of all Bind Tag Helpers. Verifying them once + // here and then ignoring them. + Assert.Empty(bind.Diagnostics); + Assert.False(bind.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, bind.Kind); + Assert.Equal(bool.TrueString, bind.Metadata[TagHelperMetadata.Common.ClassifyAttributesOnly]); + Assert.Equal(ComponentMetadata.Bind.RuntimeName, bind.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(bind.IsDefaultKind()); + Assert.False(bind.KindUsesDefaultTagHelperRuntime()); + Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); + + Assert.Equal("myprop", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("myevent", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.False(bind.IsInputElementBindTagHelper()); + Assert.False(bind.IsInputElementFallbackBindTagHelper()); + + Assert.Equal( + "Binds the provided expression to the 'myprop' attribute and a change event " + + "delegate to the 'myevent' attribute.", + bind.Documentation); + + // These are all trivially derived from the assembly/namespace/type name + Assert.Equal("Microsoft.AspNetCore.Components", bind.AssemblyName); + Assert.Equal("Bind", bind.Name); + Assert.Equal("Test.BindAttributes", bind.DisplayName); + Assert.Equal("Test.BindAttributes", bind.GetTypeName()); + + // The tag matching rule for a bind-Component is always the component name + the attribute name + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("div", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind", requiredAttribute.DisplayName); + Assert.Equal("@bind", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind")); + + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Binds the provided expression to the 'myprop' attribute and a change event " + + "delegate to the 'myevent' attribute.", + attribute.Documentation); + + Assert.Equal("@bind", attribute.Name); + Assert.Equal("Bind", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind", attribute.DisplayName); + + // Defined from the property type + Assert.Equal("System.Object", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + + var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies a format to convert the value specified by the '@bind' attribute. " + + "The format string can currently only be used with expressions of type DateTime.", + parameter.Documentation); + + Assert.Equal("format", parameter.Name); + Assert.Equal("Format_myprop", parameter.GetPropertyName()); + Assert.Equal(":format", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.String", parameter.TypeName); + Assert.True(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + + parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("culture")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies the culture to use for conversions.", + parameter.Documentation); + + Assert.Equal("culture", parameter.Name); + Assert.Equal("Culture", parameter.GetPropertyName()); + Assert.Equal(":culture", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.Globalization.CultureInfo", parameter.TypeName); + Assert.False(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + } + + [Fact] + public void Execute_BindOnElementWithSuffix_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""myprop"", ""myprop"", ""myevent"")] + public class BindAttributes + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + var bind = Assert.Single(matches); + + Assert.Equal("myprop", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("myevent", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.False(bind.IsInputElementBindTagHelper()); + Assert.False(bind.IsInputElementFallbackBindTagHelper()); + + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Equal("div", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Equal("@bind-myprop", requiredAttribute.DisplayName); + Assert.Equal("@bind-myprop", requiredAttribute.Name); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind")); + Assert.Equal("@bind-myprop", attribute.Name); + Assert.Equal("Bind_myprop", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind_myprop", attribute.DisplayName); + + attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("format")); + Assert.Equal("format-myprop", attribute.Name); + Assert.Equal("Format_myprop", attribute.GetPropertyName()); + Assert.Equal("string Test.BindAttributes.Format_myprop", attribute.DisplayName); + } + + [Fact] + public void Execute_BindOnInputElementWithoutTypeAttribute_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(null, null, ""myprop"", ""myevent"", false, null)] + public class BindAttributes + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + var bind = Assert.Single(matches); + + Assert.Equal("myprop", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("myevent", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.False(bind.Metadata.ContainsKey(ComponentMetadata.Bind.TypeAttribute)); + Assert.True(bind.IsInputElementBindTagHelper()); + Assert.True(bind.IsInputElementFallbackBindTagHelper()); + + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Equal("@bind", requiredAttribute.DisplayName); + Assert.Equal("@bind", requiredAttribute.Name); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind")); + Assert.Equal("@bind", attribute.Name); + Assert.Equal("Bind", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind", attribute.DisplayName); + + var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); + Assert.Equal("format", parameter.Name); + Assert.Equal("Format_myprop", parameter.GetPropertyName()); + Assert.Equal(":format", parameter.DisplayName); + } + + [Fact] + public void Execute_BindOnInputElementWithTypeAttribute_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(""checkbox"", null, ""myprop"", ""myevent"", false, null)] + public class BindAttributes + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + var bind = Assert.Single(matches); + + Assert.Equal("myprop", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("myevent", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.Equal("checkbox", bind.Metadata[ComponentMetadata.Bind.TypeAttribute]); + Assert.True(bind.IsInputElementBindTagHelper()); + Assert.False(bind.IsInputElementFallbackBindTagHelper()); + + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection( + rule.Attributes, + a => + { + Assert.Equal("type", a.DisplayName); + Assert.Equal("type", a.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); + Assert.Equal("checkbox", a.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + }, + a => + { + Assert.Equal("@bind", a.DisplayName); + Assert.Equal("@bind", a.Name); + }); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind")); + Assert.Equal("@bind", attribute.Name); + Assert.Equal("Bind", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind", attribute.DisplayName); + + var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); + Assert.Equal("format", parameter.Name); + Assert.Equal("Format_myprop", parameter.GetPropertyName()); + Assert.Equal(":format", parameter.DisplayName); + } + + [Fact] + public void Execute_BindOnInputElementWithTypeAttributeAndSuffix_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(""checkbox"", ""somevalue"", ""myprop"", ""myevent"", false, null)] + public class BindAttributes + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + var bind = Assert.Single(matches); + + Assert.Equal("myprop", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("myevent", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.Equal("checkbox", bind.Metadata[ComponentMetadata.Bind.TypeAttribute]); + Assert.True(bind.IsInputElementBindTagHelper()); + Assert.False(bind.IsInputElementFallbackBindTagHelper()); + Assert.False(bind.IsInvariantCultureBindTagHelper()); + Assert.Null(bind.GetFormat()); + + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection( + rule.Attributes, + a => + { + Assert.Equal("type", a.DisplayName); + Assert.Equal("type", a.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); + Assert.Equal("checkbox", a.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + }, + a => + { + Assert.Equal("@bind-somevalue", a.DisplayName); + Assert.Equal("@bind-somevalue", a.Name); + }); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind")); + Assert.Equal("@bind-somevalue", attribute.Name); + Assert.Equal("Bind_somevalue", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind_somevalue", attribute.DisplayName); + + var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); + Assert.Equal("format", parameter.Name); + Assert.Equal("Format_somevalue", parameter.GetPropertyName()); + Assert.Equal(":format", parameter.DisplayName); + } + + [Fact] + public void Execute_BindOnInputElementWithTypeAttributeAndSuffixAndInvariantCultureAndFormat_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindInputElement(""number"", null, ""value"", ""onchange"", isInvariantCulture: true, format: ""0.00"")] + public class BindAttributes + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetBindTagHelpers(context); + matches = AssertAndExcludeFullyQualifiedNameMatchComponents(matches, expectedCount: 0); + var bind = Assert.Single(matches); + + Assert.Equal("value", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); + Assert.Equal("onchange", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); + Assert.Equal("number", bind.Metadata[ComponentMetadata.Bind.TypeAttribute]); + Assert.True(bind.IsInputElementBindTagHelper()); + Assert.False(bind.IsInputElementFallbackBindTagHelper()); + Assert.True(bind.IsInvariantCultureBindTagHelper()); + Assert.Equal("0.00", bind.GetFormat()); + } + + [Fact] + public void Execute_BindFallback_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation; + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new BindTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var bind = Assert.Single(context.Results, r => r.IsFallbackBindTagHelper()); + + // These are features Bind Tags Helpers don't use. Verifying them once here and + // then ignoring them. + Assert.Empty(bind.AllowedChildTags); + Assert.Null(bind.TagOutputHint); + + // These are features that are invariants of all Bind Tag Helpers. Verifying them once + // here and then ignoring them. + Assert.Empty(bind.Diagnostics); + Assert.False(bind.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, bind.Kind); + Assert.Equal(bool.TrueString, bind.Metadata[TagHelperMetadata.Common.ClassifyAttributesOnly]); + Assert.Equal(ComponentMetadata.Bind.RuntimeName, bind.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(bind.IsDefaultKind()); + Assert.False(bind.KindUsesDefaultTagHelperRuntime()); + Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); + + Assert.False(bind.Metadata.ContainsKey(ComponentMetadata.Bind.ValueAttribute)); + Assert.False(bind.Metadata.ContainsKey(ComponentMetadata.Bind.ChangeAttribute)); + Assert.True(bind.IsFallbackBindTagHelper()); + + Assert.Equal( + "Binds the provided expression to an attribute and a change event, based on the naming of " + + "the bind attribute. For example: @bind-value=\"...\" and @bind-value:event=\"onchange\" will assign the " + + "current value of the expression to the 'value' attribute, and assign a delegate that attempts " + + "to set the value to the 'onchange' attribute.", + bind.Documentation); + + // These are all trivially derived from the assembly/namespace/type name + Assert.Equal("Microsoft.AspNetCore.Components", bind.AssemblyName); + Assert.Equal("Bind", bind.Name); + Assert.Equal("Microsoft.AspNetCore.Components.Bind", bind.DisplayName); + Assert.Equal("Microsoft.AspNetCore.Components.Bind", bind.GetTypeName()); + + // The tag matching rule for a bind-Component is always the component name + the attribute name + var rule = Assert.Single(bind.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("*", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-...", requiredAttribute.DisplayName); + Assert.Equal("@bind-", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind")); + + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.True(attribute.HasIndexer); + Assert.Equal("@bind-", attribute.IndexerNamePrefix); + Assert.Equal("System.Object", attribute.IndexerTypeName); + + Assert.Equal( + "Binds the provided expression to an attribute and a change event, based on the naming of " + + "the bind attribute. For example: @bind-value=\"...\" and @bind-value:event=\"onchange\" will assign the " + + "current value of the expression to the 'value' attribute, and assign a delegate that attempts " + + "to set the value to the 'onchange' attribute.", + attribute.Documentation); + + Assert.Equal("@bind-...", attribute.Name); + Assert.Equal("Bind", attribute.GetPropertyName()); + Assert.Equal( + "System.Collections.Generic.Dictionary Microsoft.AspNetCore.Components.Bind.Bind", + attribute.DisplayName); + + // Defined from the property type + Assert.Equal("System.Collections.Generic.Dictionary", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + + var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies a format to convert the value specified by the corresponding bind attribute. " + + "For example: @bind-value:format=\"...\" will apply a format string to the value " + + "specified in @bind-value=\"...\". The format string can currently only be used with " + + "expressions of type DateTime.", + parameter.Documentation); + + Assert.Equal("format", parameter.Name); + Assert.Equal("Format", parameter.GetPropertyName()); + Assert.Equal(":format", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.String", parameter.TypeName); + Assert.True(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + + parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("culture")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies the culture to use for conversions.", + parameter.Documentation); + + Assert.Equal("culture", parameter.Name); + Assert.Equal("Culture", parameter.GetPropertyName()); + Assert.Equal(":culture", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.Globalization.CultureInfo", parameter.TypeName); + Assert.False(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + } + + private static TagHelperDescriptor[] GetBindTagHelpers(TagHelperDescriptorProviderContext context) + { + return ExcludeBuiltInComponents(context).Where(t => t.IsBindTagHelper()).ToArray(); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs new file mode 100644 index 0000000000..53aeb98031 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/CompilationTagHelperFeatureTest.cs @@ -0,0 +1,131 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.CodeAnalysis.CSharp; +using Moq; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class CompilationTagHelperFeatureTest + { + [Fact] + public void IsValidCompilation_ReturnsTrueIfTagHelperInterfaceCannotBeFound() + { + // Arrange + var references = new[] + { + MetadataReference.CreateFromFile(typeof(string).Assembly.Location), + }; + var compilation = CSharpCompilation.Create("Test", references: references); + + // Act + var result = CompilationTagHelperFeature.IsValidCompilation(compilation); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsValidCompilation_ReturnsFalseIfSystemStringCannotBeFound() + { + // Arrange + var references = new[] + { + MetadataReference.CreateFromFile(typeof(ITagHelper).Assembly.Location), + }; + var compilation = CSharpCompilation.Create("Test", references: references); + + // Act + var result = CompilationTagHelperFeature.IsValidCompilation(compilation); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsValidCompilation_ReturnsTrueIfWellKnownTypesAreFound() + { + // Arrange + var references = new[] + { + MetadataReference.CreateFromFile(typeof(string).Assembly.Location), + MetadataReference.CreateFromFile(typeof(ITagHelper).Assembly.Location), + }; + var compilation = CSharpCompilation.Create("Test", references: references); + + // Act + var result = CompilationTagHelperFeature.IsValidCompilation(compilation); + + // Assert + Assert.True(result); + } + + [Fact] + public void GetDescriptors_DoesNotSetCompilation_IfCompilationIsInvalid() + { + // Arrange + Compilation compilation = null; + var provider = new Mock(); + provider.Setup(c => c.Execute(It.IsAny())) + .Callback(c => compilation = c.GetCompilation()) + .Verifiable(); + + var engine = RazorProjectEngine.Create( + configure => + { + configure.Features.Add(new DefaultMetadataReferenceFeature()); + configure.Features.Add(provider.Object); + configure.Features.Add(new CompilationTagHelperFeature()); + }); + + var feature = engine.EngineFeatures.OfType().First(); + + // Act + var result = feature.GetDescriptors(); + + // Assert + Assert.Empty(result); + provider.Verify(); + Assert.Null(compilation); + } + + [Fact] + public void GetDescriptors_SetsCompilation_IfCompilationIsValid() + { + // Arrange + Compilation compilation = null; + var provider = new Mock(); + provider.Setup(c => c.Execute(It.IsAny())) + .Callback(c => compilation = c.GetCompilation()) + .Verifiable(); + + var references = new[] + { + MetadataReference.CreateFromFile(typeof(string).Assembly.Location), + MetadataReference.CreateFromFile(typeof(ITagHelper).Assembly.Location), + }; + + var engine = RazorProjectEngine.Create( + configure => + { + configure.Features.Add(new DefaultMetadataReferenceFeature { References = references }); + configure.Features.Add(provider.Object); + configure.Features.Add(new CompilationTagHelperFeature()); + }); + + var feature = engine.EngineFeatures.OfType().First(); + + // Act + var result = feature.GetDescriptors(); + + // Assert + Assert.Empty(result); + provider.Verify(); + Assert.NotNull(compilation); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..28d2986df6 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs @@ -0,0 +1,1588 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class ComponentTagHelperDescriptorProviderTest : TagHelperDescriptorProviderTestBase + { + [Fact] + public void Execute_FindsIComponentType_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : IComponent + { + public void Attach(RenderHandle renderHandle) { } + + public Task SetParametersAsync(ParameterView parameters) + { + return Task.CompletedTask; + } + + [Parameter] + public string MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + // These are features Components don't use. Verifying them once here and + // then ignoring them. + Assert.Empty(component.AllowedChildTags); + Assert.Null(component.TagOutputHint); + + // These are features that are invariants of all Components. Verifying them once + // here and then ignoring them. + Assert.Empty(component.Diagnostics); + Assert.False(component.HasErrors); + Assert.Equal(ComponentMetadata.Component.TagHelperKind, component.Kind); + Assert.False(component.IsDefaultKind()); + Assert.False(component.KindUsesDefaultTagHelperRuntime()); + Assert.True(component.IsComponentOrChildContentTagHelper()); + Assert.True(component.CaseSensitive); + + // No documentation in this test + Assert.Null(component.Documentation); + + // These are all trivially derived from the assembly/namespace/type name + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + Assert.Equal("Test.MyComponent", component.DisplayName); + Assert.Equal("Test.MyComponent", component.GetTypeName()); + + // Our use of matching rules is also very simple, and derived from the name. Verifying + // it once in detail here and then ignoring it. + var rule = Assert.Single(component.TagMatchingRules); + Assert.Empty(rule.Attributes); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + // Our use of metadata is also (for now) an invariant for all Components - other than the type name + // which is trivial. Verifying it once in detail and then ignoring it. + Assert.Collection( + component.Metadata.OrderBy(kvp => kvp.Key), + kvp => { Assert.Equal(TagHelperMetadata.Common.TypeName, kvp.Key); Assert.Equal("Test.MyComponent", kvp.Value); }, + kvp => { Assert.Equal(TagHelperMetadata.Runtime.Name, kvp.Key); Assert.Equal("Components.IComponent", kvp.Value); }); + + // Our use of bound attributes is what tests will focus on. As you might expect right now, this test + // is going to cover a lot of trivial stuff that will be true for all components/component-properties. + var attribute = Assert.Single(component.BoundAttributes); + + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal("Components.Component", attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + + // Related to dictionaries/indexers, not supported currently, not sure if we ever will + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + Assert.True(component.CaseSensitive); + + // No documentation in this test + Assert.Null(attribute.Documentation); + + // Names are trivially derived from the property name + Assert.Equal("MyProperty", attribute.Name); + Assert.Equal("MyProperty", attribute.GetPropertyName()); + Assert.Equal("string Test.MyComponent.MyProperty", attribute.DisplayName); + + // Defined from the property type + Assert.Equal("System.String", attribute.TypeName); + Assert.True(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + + // Our use of metadata is also (for now) an invariant for all Component properties - other than the type name + // which is trivial. Verifying it once in detail and then ignoring it. + Assert.Collection( + attribute.Metadata.OrderBy(kvp => kvp.Key), + kvp => { Assert.Equal(TagHelperMetadata.Common.PropertyName, kvp.Key); Assert.Equal("MyProperty", kvp.Value); }); + } + + [Fact] + public void Execute_FindsIComponentType_CreatesDescriptor_Generic() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : IComponent + { + public void Attach(RenderHandle renderHandle) { } + + public Task SetParametersAsync(ParameterView parameters) + { + return Task.CompletedTask; + } + + [Parameter] + public string MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + Assert.Equal("Test.MyComponent", component.DisplayName); + Assert.Equal("Test.MyComponent", component.GetTypeName()); + + Assert.True(component.IsGenericTypedComponent()); + + var rule = Assert.Single(component.TagMatchingRules); + Assert.Equal("MyComponent", rule.TagName); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("MyProperty", a.Name); + Assert.Equal("MyProperty", a.GetPropertyName()); + Assert.Equal("string Test.MyComponent.MyProperty", a.DisplayName); + Assert.Equal("System.String", a.TypeName); + + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + } + + [Fact] + public void Execute_FindsBlazorComponentType_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("MyProperty", attribute.Name); + Assert.Equal("System.String", attribute.TypeName); + } + + [Fact] + public void Execute_IgnoresPrivateParameters_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + private string MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Empty(component.BoundAttributes); + } + + [Fact] + public void Execute_IgnoresParametersWithPrivateSetters_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public string MyProperty { get; private set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Empty(component.BoundAttributes); + } + + [Fact] // bool properties support minimized attributes + public void Execute_BoolProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public bool MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("MyProperty", attribute.Name); + Assert.Equal("System.Boolean", attribute.TypeName); + + Assert.False(attribute.HasIndexer); + Assert.True(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + Assert.False(attribute.IsStringProperty); + } + + [Fact] // enum properties have some special intellisense behavior + public void Execute_EnumProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public enum MyEnum + { + One, + Two + } + + public class MyComponent : ComponentBase + { + [Parameter] + public MyEnum MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("MyProperty", attribute.Name); + Assert.Equal("Test.MyEnum", attribute.TypeName); + + Assert.False(attribute.HasIndexer); + Assert.False(attribute.IsBooleanProperty); + Assert.True(attribute.IsEnum); + Assert.False(attribute.IsStringProperty); + } + + [Fact] + public void Execute_GenericProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public T MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("MyProperty", a.Name); + Assert.Equal("MyProperty", a.GetPropertyName()); + Assert.Equal("T Test.MyComponent.MyProperty", a.DisplayName); + Assert.Equal("T", a.TypeName); + Assert.True(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + } + + [Fact] + public void Execute_MultipleGenerics_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public T MyProperty1 { get; set; } + + [Parameter] + public U MyProperty2 { get; set; } + + [Parameter] + public V MyProperty3 { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("MyProperty1", a.Name); + Assert.Equal("T", a.TypeName); + Assert.True(a.IsGenericTypedProperty()); + }, + a => + { + Assert.Equal("MyProperty2", a.Name); + Assert.Equal("U", a.TypeName); + Assert.True(a.IsGenericTypedProperty()); + }, + a => + { + Assert.Equal("MyProperty3", a.Name); + Assert.Equal("V", a.TypeName); + Assert.True(a.IsGenericTypedProperty()); + }, + a => + { + Assert.Equal("T", a.Name); + Assert.True(a.IsTypeParameterProperty()); + }, + a => + { + Assert.Equal("U", a.Name); + Assert.True(a.IsTypeParameterProperty()); + }, + a => + { + Assert.Equal("V", a.Name); + Assert.True(a.IsTypeParameterProperty()); + }); + } + + [Fact] + public void Execute_DelegateProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public Action OnClick { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("OnClick", attribute.Name); + Assert.Equal("System.Action", attribute.TypeName); + + Assert.False(attribute.HasIndexer); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + Assert.False(attribute.IsStringProperty); + Assert.True(attribute.IsDelegateProperty()); + Assert.False(attribute.IsChildContentProperty()); + } + + [Fact] + public void Execute_DelegateProperty_CreatesDescriptor_Generic() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public Action OnClick { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("OnClick", a.Name); + Assert.Equal("System.Action", a.TypeName); + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.True(a.IsDelegateProperty()); + Assert.False(a.IsChildContentProperty()); + Assert.True(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + } + + [Fact] + public void Execute_EventCallbackProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("OnClick", attribute.Name); + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback", attribute.TypeName); + + Assert.False(attribute.HasIndexer); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + Assert.False(attribute.IsStringProperty); + Assert.True(attribute.IsEventCallbackProperty()); + Assert.False(attribute.IsDelegateProperty()); + Assert.False(attribute.IsChildContentProperty()); + } + + [Fact] + public void Execute_EventCallbackProperty_CreatesDescriptor_ClosedGeneric() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("OnClick", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback", a.TypeName); + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.True(a.IsEventCallbackProperty()); + Assert.False(a.IsDelegateProperty()); + Assert.False(a.IsChildContentProperty()); + Assert.False(a.IsGenericTypedProperty()); + + }); + } + + [Fact] + public void Execute_EventCallbackProperty_CreatesDescriptor_OpenGeneric() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public EventCallback OnClick { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("OnClick", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback", a.TypeName); + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.True(a.IsEventCallbackProperty()); + Assert.False(a.IsDelegateProperty()); + Assert.False(a.IsChildContentProperty()); + Assert.True(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + } + + [Fact] + public void Execute_RenderFragmentProperty_CreatesDescriptors() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent2 { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("ChildContent2", attribute.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", attribute.TypeName); + + Assert.False(attribute.HasIndexer); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(attribute.IsChildContentProperty()); + Assert.False(attribute.IsParameterizedChildContentProperty()); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + Assert.Empty(childContent.BoundAttributes); + } + + [Fact] + public void Execute_RenderFragmentOfTProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent2 { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes, + a => + { + Assert.Equal("ChildContent2", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", a.TypeName); + + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.False(a.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(a.IsChildContentProperty()); + Assert.True(a.IsParameterizedChildContentProperty()); + Assert.False(a.IsGenericTypedProperty()); + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.True(a.IsChildContentParameterNameProperty()); + }); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + // A RenderFragment tag helper has a parameter to allow you to set the lambda parameter name. + var contextAttribute = Assert.Single(childContent.BoundAttributes); + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, contextAttribute.Name); + Assert.Equal("System.String", contextAttribute.TypeName); + Assert.Equal("Specifies the parameter name for the 'ChildContent2' child content expression.", contextAttribute.Documentation); + Assert.True(contextAttribute.IsChildContentParameterNameProperty()); + } + + [Fact] + public void Execute_RenderFragmentOfTProperty_ComponentDefinesContextParameter() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent2 { get; set; } + + [Parameter] + public string Context { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes, + a => + { + Assert.Equal("ChildContent2", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", a.TypeName); + + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.False(a.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(a.IsChildContentProperty()); + Assert.True(a.IsParameterizedChildContentProperty()); + Assert.False(a.IsGenericTypedProperty()); + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.False(a.IsChildContentParameterNameProperty()); + }); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + // A RenderFragment tag helper has a parameter to allow you to set the lambda parameter name. + var contextAttribute = Assert.Single(childContent.BoundAttributes); + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, contextAttribute.Name); + Assert.Equal("System.String", contextAttribute.TypeName); + Assert.Equal("Specifies the parameter name for the 'ChildContent2' child content expression.", contextAttribute.Documentation); + Assert.True(contextAttribute.IsChildContentParameterNameProperty()); + } + + [Fact] + public void Execute_RenderFragmentGenericProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent2 { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("ChildContent2", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", a.TypeName); + + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.False(a.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(a.IsChildContentProperty()); + Assert.True(a.IsParameterizedChildContentProperty()); + Assert.True(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.True(a.IsChildContentParameterNameProperty()); + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + // A RenderFragment tag helper has a parameter to allow you to set the lambda parameter name. + var contextAttribute = Assert.Single(childContent.BoundAttributes); + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, contextAttribute.Name); + Assert.Equal("System.String", contextAttribute.TypeName); + Assert.Equal("Specifies the parameter name for the 'ChildContent2' child content expression.", contextAttribute.Documentation); + Assert.True(contextAttribute.IsChildContentParameterNameProperty()); + } + + [Fact] + public void Execute_RenderFragmentClosedGenericListProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment> ChildContent2 { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("ChildContent2", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment>", a.TypeName); + + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.False(a.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(a.IsChildContentProperty()); + Assert.True(a.IsParameterizedChildContentProperty()); + Assert.False(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.True(a.IsChildContentParameterNameProperty()); + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + // A RenderFragment tag helper has a parameter to allow you to set the lambda parameter name. + var contextAttribute = Assert.Single(childContent.BoundAttributes); + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, contextAttribute.Name); + Assert.Equal("System.String", contextAttribute.TypeName); + Assert.Equal("Specifies the parameter name for the 'ChildContent2' child content expression.", contextAttribute.Documentation); + Assert.True(contextAttribute.IsChildContentParameterNameProperty()); + } + + [Fact] + public void Execute_RenderFragmentGenericListProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment> ChildContent2 { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("ChildContent2", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment>", a.TypeName); + + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.False(a.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(a.IsChildContentProperty()); + Assert.True(a.IsParameterizedChildContentProperty()); + Assert.True(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.True(a.IsChildContentParameterNameProperty()); + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + // A RenderFragment tag helper has a parameter to allow you to set the lambda parameter name. + var contextAttribute = Assert.Single(childContent.BoundAttributes); + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, contextAttribute.Name); + Assert.Equal("System.String", contextAttribute.TypeName); + Assert.Equal("Specifies the parameter name for the 'ChildContent2' child content expression.", contextAttribute.Documentation); + Assert.True(contextAttribute.IsChildContentParameterNameProperty()); + } + + [Fact] + public void Execute_RenderFragmentGenericContextProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent2 { get; set; } + + public class Context + { + public T Item { get; set; } + } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 2); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("ChildContent2", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment.Context>", a.TypeName); + + Assert.False(a.HasIndexer); + Assert.False(a.IsBooleanProperty); + Assert.False(a.IsEnum); + Assert.False(a.IsStringProperty); + Assert.False(a.IsDelegateProperty()); // We treat RenderFragment as separate from generalized delegates + Assert.True(a.IsChildContentProperty()); + Assert.True(a.IsParameterizedChildContentProperty()); + Assert.True(a.IsGenericTypedProperty()); + + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.True(a.IsChildContentParameterNameProperty()); + }, + a => + { + Assert.Equal("T", a.Name); + Assert.Equal("T", a.GetPropertyName()); + Assert.Equal("T", a.DisplayName); + Assert.Equal("System.Type", a.TypeName); + Assert.True(a.IsTypeParameterProperty()); + }); + + var childContent = Assert.Single(components, c => c.IsChildContentTagHelper()); + + Assert.Equal("TestAssembly", childContent.AssemblyName); + Assert.Equal("Test.MyComponent.ChildContent2", childContent.Name); + + // A RenderFragment tag helper has a parameter to allow you to set the lambda parameter name. + var contextAttribute = Assert.Single(childContent.BoundAttributes); + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, contextAttribute.Name); + Assert.Equal("System.String", contextAttribute.TypeName); + Assert.Equal("Specifies the parameter name for the 'ChildContent2' child content expression.", contextAttribute.Documentation); + } + + [Fact] + public void Execute_MultipleRenderFragmentProperties_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public RenderFragment ChildContent { get; set; } + + [Parameter] + public RenderFragment Header { get; set; } + + [Parameter] + public RenderFragment Footer { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 4); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("ChildContent", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", a.TypeName); + Assert.True(a.IsChildContentProperty()); + }, + a => + { + Assert.Equal(ComponentMetadata.ChildContent.ParameterAttributeName, a.Name); + Assert.True(a.IsChildContentParameterNameProperty()); + }, + a => + { + Assert.Equal("Footer", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", a.TypeName); + Assert.True(a.IsChildContentProperty()); + }, + a => + { + Assert.Equal("Header", a.Name); + Assert.Equal("Microsoft.AspNetCore.Components.RenderFragment", a.TypeName); + Assert.True(a.IsChildContentProperty()); + }); + + + var childContents = components.Where(c => c.IsChildContentTagHelper()).OrderBy(c => c.Name); + Assert.Collection( + childContents, + c => Assert.Equal("Test.MyComponent.ChildContent", c.Name), + c => Assert.Equal("Test.MyComponent.Footer", c.Name), + c => Assert.Equal("Test.MyComponent.Header", c.Name)); + } + + [Fact] // This component has lots of properties that don't become components. + public void Execute_IgnoredProperties_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public abstract class MyBase : ComponentBase + { + [Parameter] + public string Hidden { get; set; } + } + + public class MyComponent : MyBase + { + [Parameter] + public string NoSetter { get; } + + [Parameter] + public static string StaticProperty { get; set; } + + public string NoParameterAttribute { get; set; } + + // No attribute here, hides base-class property of the same name. + public new int Hidden { get; set; } + + public string this[int i] + { + get { throw null; } + set { throw null; } + } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + Assert.Empty(component.BoundAttributes); + } + + [Fact] // Testing multilevel overrides with the [Parameter] attribute on different levels. + public void Execute_MultiLevelOverriddenProperties_CreatesDescriptorCorrectly() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public abstract class MyBaseComponent : ComponentBase + { + [Parameter] + public virtual string Header { get; set; } + + public virtual string Footer { get; set; } + } + + public abstract class MyDerivedComponent1 : MyBaseComponent + { + public override string Header { get; set; } + + [Parameter] + public override string Footer { get; set; } + } + + public class MyDerivedComponent2 : MyDerivedComponent1 + { + public override string Header { get; set; } + + public override string Footer { get; set; } + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components, c => c.IsComponentTagHelper()); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyDerivedComponent2", component.Name); + + Assert.Collection( + component.BoundAttributes.OrderBy(a => a.Name), + a => + { + Assert.Equal("Footer", a.Name); + Assert.Equal("System.String", a.TypeName); + }, + a => + { + Assert.Equal("Header", a.Name); + Assert.Equal("System.String", a.TypeName); + }); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs new file mode 100644 index 0000000000..7465c6e903 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs @@ -0,0 +1,2384 @@ +// 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 System.Reflection; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor.Workspaces.Test; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor.Workspaces +{ + public class DefaultTagHelperDescriptorFactoryTest + { + private static readonly Assembly _assembly = typeof(DefaultTagHelperDescriptorFactoryTest).GetTypeInfo().Assembly; + + protected static readonly AssemblyName TagHelperDescriptorFactoryTestAssembly = _assembly.GetName(); + + protected static readonly string AssemblyName = TagHelperDescriptorFactoryTestAssembly.Name; + + private static Compilation Compilation { get; } = TestCompilation.Create(_assembly); + + public static TheoryData RequiredAttributeParserErrorData + { + get + { + return new TheoryData[]> + { + { + "name,", + new Action[] + { + builder => builder + .Name("name") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("name,")), + } + }, + { + " ", + new Action[] + { + builder => builder + .Name(string.Empty) + .AddDiagnostic(AspNetCore.Razor.Language.RazorDiagnosticFactory.CreateTagHelper_InvalidTargetedAttributeNameNullOrWhitespace()), + } + }, + { + "n@me", + new Action[] + { + builder => builder + .Name("n@me") + .AddDiagnostic(AspNetCore.Razor.Language.RazorDiagnosticFactory.CreateTagHelper_InvalidTargetedAttributeName("n@me", '@')), + } + }, + { + "name extra", + new Action[] + { + builder => builder + .Name("name") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeCharacter('e', "name extra")), + } + }, + { + "[[ ", + new Action[] + { + builder => builder + .Name("[") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("[[ ")), + } + }, + { + "[ ", + new Action[] + { + builder => builder + .Name("") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("[ ")), + } + }, + { + "[name='unended]", + new Action[] + { + builder => builder + .Name("name") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeMismatchedQuotes('\'', "[name='unended]")), + } + }, + { + "[name='unended", + new Action[] + { + builder => builder + .Name("name") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeMismatchedQuotes('\'', "[name='unended")), + } + }, + { + "[name", + new Action[] + { + builder => builder + .Name("name") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("[name")), + } + }, + { + "[ ]", + new Action[] + { + builder => builder + .Name(string.Empty) + .AddDiagnostic(AspNetCore.Razor.Language.RazorDiagnosticFactory.CreateTagHelper_InvalidTargetedAttributeNameNullOrWhitespace()), + } + }, + { + "[n@me]", + new Action[] + { + builder => builder + .Name("n@me") + .AddDiagnostic(AspNetCore.Razor.Language.RazorDiagnosticFactory.CreateTagHelper_InvalidTargetedAttributeName("n@me", '@')), + } + }, + { + "[name@]", + new Action[] + { + builder => builder + .Name("name@") + .AddDiagnostic(AspNetCore.Razor.Language.RazorDiagnosticFactory.CreateTagHelper_InvalidTargetedAttributeName("name@", '@')), + } + }, + { + "[name^]", + new Action[] + { + builder => builder + .Name("name") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_PartialRequiredAttributeOperator('^', "[name^]")), + } + }, + { + "[name='value'", + new Action[] + { + builder => builder + .Name("name") + .Value("value") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("[name='value'")), + } + }, + { + "[name ", + new Action[] + { + builder => builder + .Name("name") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("[name ")), + } + }, + { + "[name extra]", + new Action[] + { + builder => builder + .Name("name") + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_InvalidRequiredAttributeOperator('e', "[name extra]")), + } + }, + { + "[name=value ", + new Action[] + { + builder => builder + .Name("name") + .Value("value") + .ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_CouldNotFindMatchingEndBrace("[name=value ")), + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(RequiredAttributeParserErrorData))] + public void RequiredAttributeParser_ParsesRequiredAttributesAndLogsDiagnosticsCorrectly( + string requiredAttributes, + IEnumerable> configureBuilders) + { + // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var ruleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + + var expectedRules = new List(); + foreach (var configureBuilder in configureBuilders) + { + var builder = new DefaultRequiredAttributeDescriptorBuilder(ruleBuilder); + configureBuilder(builder); + + expectedRules.Add(builder.Build()); + } + + // Act + RequiredAttributeParser.AddRequiredAttributes(requiredAttributes, ruleBuilder); + + // Assert + var descriptors = ruleBuilder.Build().Attributes; + Assert.Equal(expectedRules, descriptors, RequiredAttributeDescriptorComparer.Default); + } + + public static TheoryData RequiredAttributeParserData + { + get + { + Func> plain = + (name, nameComparison) => (builder) => builder + .Name(name) + .NameComparisonMode(nameComparison); + + Func> css = + (name, value, valueComparison) => (builder) => builder + .Name(name) + .Value(value) + .ValueComparisonMode(valueComparison); + + return new TheoryData>> + { + { null, Enumerable.Empty>() }, + { string.Empty, Enumerable.Empty>() }, + { "name", new[] { plain("name", RequiredAttributeDescriptor.NameComparisonMode.FullMatch) } }, + { "name-*", new[] { plain("name-", RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch) } }, + { " name-* ", new[] { plain("name-", RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch) } }, + { + "asp-route-*,valid , name-* ,extra", + new[] + { + plain("asp-route-", RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + plain("valid", RequiredAttributeDescriptor.NameComparisonMode.FullMatch), + plain("name-", RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + plain("extra", RequiredAttributeDescriptor.NameComparisonMode.FullMatch), + } + }, + { "[name]", new[] { css("name", null, RequiredAttributeDescriptor.ValueComparisonMode.None) } }, + { "[ name ]", new[] { css("name", null, RequiredAttributeDescriptor.ValueComparisonMode.None) } }, + { " [ name ] ", new[] { css("name", null, RequiredAttributeDescriptor.ValueComparisonMode.None) } }, + { "[name=]", new[] { css("name", "", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } }, + { "[name='']", new[] { css("name", "", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } }, + { "[name ^=]", new[] { css("name", "", RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch) } }, + { "[name=hello]", new[] { css("name", "hello", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } }, + { "[name= hello]", new[] { css("name", "hello", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } }, + { "[name='hello']", new[] { css("name", "hello", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } }, + { "[name=\"hello\"]", new[] { css("name", "hello", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } }, + { " [ name $= \" hello\" ] ", new[] { css("name", " hello", RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch) } }, + { + "[name=\"hello\"],[other^=something ], [val = 'cool']", + new[] + { + css("name", "hello", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch), + css("other", "something", RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch), + css("val", "cool", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch) } + }, + { + "asp-route-*,[name=\"hello\"],valid ,[other^=something ], name-* ,[val = 'cool'],extra", + new[] + { + plain("asp-route-", RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + css("name", "hello", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch), + plain("valid", RequiredAttributeDescriptor.NameComparisonMode.FullMatch), + css("other", "something", RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch), + plain("name-", RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch), + css("val", "cool", RequiredAttributeDescriptor.ValueComparisonMode.FullMatch), + plain("extra", RequiredAttributeDescriptor.NameComparisonMode.FullMatch), + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(RequiredAttributeParserData))] + public void RequiredAttributeParser_ParsesRequiredAttributesCorrectly( + string requiredAttributes, + IEnumerable> configureBuilders) + { + // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var ruleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + + var expectedRules = new List(); + foreach (var configureBuilder in configureBuilders) + { + var builder = new DefaultRequiredAttributeDescriptorBuilder(ruleBuilder); + configureBuilder(builder); + + expectedRules.Add(builder.Build()); + } + + // Act + RequiredAttributeParser.AddRequiredAttributes(requiredAttributes, ruleBuilder); + + // Assert + var descriptors = ruleBuilder.Build().Attributes; + Assert.Equal(expectedRules, descriptors, RequiredAttributeDescriptorComparer.Default); + } + + public static TheoryData IsEnumData + { + get + { + // tagHelperType, expectedDescriptor + return new TheoryData + { + { + typeof(EnumTagHelper), + TagHelperDescriptorBuilder.Create(typeof(EnumTagHelper).FullName, AssemblyName) + .TypeName(typeof(EnumTagHelper).FullName) + .TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName("enum")) + .BoundAttributeDescriptor(builder => + builder + .Name("non-enum-property") + .PropertyName(nameof(EnumTagHelper.NonEnumProperty)) + .TypeName(typeof(int).FullName)) + .BoundAttributeDescriptor(builder => + builder + .Name("enum-property") + .PropertyName(nameof(EnumTagHelper.EnumProperty)) + .TypeName(typeof(CustomEnum).FullName) + .AsEnum()) + .Build() + }, + { + typeof(MultiEnumTagHelper), + TagHelperDescriptorBuilder.Create(typeof(MultiEnumTagHelper).FullName, AssemblyName) + .TypeName(typeof(MultiEnumTagHelper).FullName) + .TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName("p")) + .TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName("input")) + .BoundAttributeDescriptor(builder => + builder + .Name("non-enum-property") + .PropertyName(nameof(MultiEnumTagHelper.NonEnumProperty)) + .TypeName(typeof(int).FullName)) + .BoundAttributeDescriptor(builder => + builder + .Name("enum-property") + .PropertyName(nameof(MultiEnumTagHelper.EnumProperty)) + .TypeName(typeof(CustomEnum).FullName) + .AsEnum()) + .Build() + }, + { + typeof(NestedEnumTagHelper), + TagHelperDescriptorBuilder.Create(typeof(NestedEnumTagHelper).FullName, AssemblyName) + .TypeName(typeof(NestedEnumTagHelper).FullName) + .TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName("nested-enum")) + .BoundAttributeDescriptor(builder => + builder + .Name("non-enum-property") + .PropertyName(nameof(NestedEnumTagHelper.NonEnumProperty)) + .TypeName(typeof(int).FullName)) + .BoundAttributeDescriptor(builder => + builder + .Name("enum-property") + .PropertyName(nameof(NestedEnumTagHelper.EnumProperty)) + .TypeName(typeof(CustomEnum).FullName) + .AsEnum()) + .BoundAttributeDescriptor(builder => + builder + .Name("nested-enum-property") + .PropertyName(nameof(NestedEnumTagHelper.NestedEnumProperty)) + .TypeName($"{typeof(NestedEnumTagHelper).FullName}.{nameof(NestedEnumTagHelper.NestedEnum)}") + .AsEnum()) + .Build() + }, + }; + } + } + + [Theory] + [MemberData(nameof(IsEnumData))] + public void CreateDescriptor_IsEnumIsSetCorrectly( + Type tagHelperType, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData RequiredParentData + { + get + { + // tagHelperType, expectedDescriptor + return new TheoryData + { + { + typeof(RequiredParentTagHelper), + TagHelperDescriptorBuilder.Create(typeof(RequiredParentTagHelper).FullName, AssemblyName) + .TypeName(typeof(RequiredParentTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("input").RequireParentTag("div")) + .Build() + }, + { + typeof(MultiSpecifiedRequiredParentTagHelper), + TagHelperDescriptorBuilder.Create(typeof(MultiSpecifiedRequiredParentTagHelper).FullName, AssemblyName) + .TypeName(typeof(MultiSpecifiedRequiredParentTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("p").RequireParentTag("div")) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("input").RequireParentTag("section")) + .Build() + }, + { + typeof(MultiWithUnspecifiedRequiredParentTagHelper), + TagHelperDescriptorBuilder.Create(typeof(MultiWithUnspecifiedRequiredParentTagHelper).FullName, AssemblyName) + .TypeName(typeof(MultiWithUnspecifiedRequiredParentTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("p")) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("input").RequireParentTag("div")) + .Build() + }, + }; + } + } + + [Theory] + [MemberData(nameof(RequiredParentData))] + public void CreateDescriptor_CreatesDesignTimeDescriptorsWithRequiredParent( + Type tagHelperType, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData RestrictChildrenData + { + get + { + // tagHelperType, expectedDescriptor + return new TheoryData + { + { + typeof(RestrictChildrenTagHelper), + TagHelperDescriptorBuilder.Create(typeof(RestrictChildrenTagHelper).FullName, AssemblyName) + .TypeName(typeof(RestrictChildrenTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("restrict-children")) + .AllowChildTag("p") + .Build() + }, + { + typeof(DoubleRestrictChildrenTagHelper), + TagHelperDescriptorBuilder.Create(typeof(DoubleRestrictChildrenTagHelper).FullName, AssemblyName) + .TypeName(typeof(DoubleRestrictChildrenTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("double-restrict-children")) + .AllowChildTag("p") + .AllowChildTag("strong") + .Build() + }, + { + typeof(MultiTargetRestrictChildrenTagHelper), + TagHelperDescriptorBuilder.Create(typeof(MultiTargetRestrictChildrenTagHelper).FullName, AssemblyName) + .TypeName(typeof(MultiTargetRestrictChildrenTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("p")) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("div")) + .AllowChildTag("p") + .AllowChildTag("strong") + .Build() + }, + }; + } + } + + + [Theory] + [MemberData(nameof(RestrictChildrenData))] + public void CreateDescriptor_CreatesDescriptorsWithAllowedChildren( + Type tagHelperType, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData TagStructureData + { + get + { + // tagHelperType, expectedDescriptor + return new TheoryData + { + { + typeof(TagStructureTagHelper), + TagHelperDescriptorBuilder.Create(typeof(TagStructureTagHelper).FullName, AssemblyName) + .TypeName(typeof(TagStructureTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }, + { + typeof(MultiSpecifiedTagStructureTagHelper), + TagHelperDescriptorBuilder.Create(typeof(MultiSpecifiedTagStructureTagHelper).FullName, AssemblyName) + .TypeName(typeof(MultiSpecifiedTagStructureTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder + .RequireTagName("p") + .RequireTagStructure(TagStructure.NormalOrSelfClosing)) + .TagMatchingRuleDescriptor(builder => builder + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }, + { + typeof(MultiWithUnspecifiedTagStructureTagHelper), + TagHelperDescriptorBuilder.Create(typeof(MultiWithUnspecifiedTagStructureTagHelper).FullName, AssemblyName) + .TypeName(typeof(MultiWithUnspecifiedTagStructureTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder + .RequireTagName("p")) + .TagMatchingRuleDescriptor(builder => builder + .RequireTagName("input") + .RequireTagStructure(TagStructure.WithoutEndTag)) + .Build() + }, + }; + } + } + + [Theory] + [MemberData(nameof(TagStructureData))] + public void CreateDescriptor_CreatesDesignTimeDescriptorsWithTagStructure( + Type tagHelperType, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData EditorBrowsableData + { + get + { + // tagHelperType, designTime, expectedDescriptor + return new TheoryData + { + { + typeof(InheritedEditorBrowsableTagHelper), + true, + CreateTagHelperDescriptor( + tagName: "inherited-editor-browsable", + typeName: typeof(InheritedEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property") + .PropertyName(nameof(InheritedEditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + }) + }, + { typeof(EditorBrowsableTagHelper), true, null }, + { + typeof(EditorBrowsableTagHelper), + false, + CreateTagHelperDescriptor( + tagName: "editor-browsable", + typeName: typeof(EditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property") + .PropertyName(nameof(EditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + }) + }, + { + typeof(HiddenPropertyEditorBrowsableTagHelper), + true, + CreateTagHelperDescriptor( + tagName: "hidden-property-editor-browsable", + typeName: typeof(HiddenPropertyEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName) + }, + { + typeof(HiddenPropertyEditorBrowsableTagHelper), + false, + CreateTagHelperDescriptor( + tagName: "hidden-property-editor-browsable", + typeName: typeof(HiddenPropertyEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property") + .PropertyName(nameof(HiddenPropertyEditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + }) + }, + { + typeof(OverriddenEditorBrowsableTagHelper), + true, + CreateTagHelperDescriptor( + tagName: "overridden-editor-browsable", + typeName: typeof(OverriddenEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property") + .PropertyName(nameof(OverriddenEditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + }) + }, + { + typeof(MultiPropertyEditorBrowsableTagHelper), + true, + CreateTagHelperDescriptor( + tagName: "multi-property-editor-browsable", + typeName: typeof(MultiPropertyEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property2") + .PropertyName(nameof(MultiPropertyEditorBrowsableTagHelper.Property2)) + .TypeName(typeof(int).FullName), + }) + }, + { + typeof(MultiPropertyEditorBrowsableTagHelper), + false, + CreateTagHelperDescriptor( + tagName: "multi-property-editor-browsable", + typeName: typeof(MultiPropertyEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property") + .PropertyName(nameof(MultiPropertyEditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + builder => builder + .Name("property2") + .PropertyName(nameof(MultiPropertyEditorBrowsableTagHelper.Property2)) + .TypeName(typeof(int).FullName), + }) + }, + { + typeof(OverriddenPropertyEditorBrowsableTagHelper), + true, + CreateTagHelperDescriptor( + tagName: "overridden-property-editor-browsable", + typeName: typeof(OverriddenPropertyEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName) + }, + { + typeof(OverriddenPropertyEditorBrowsableTagHelper), + false, + CreateTagHelperDescriptor( + tagName: "overridden-property-editor-browsable", + typeName: typeof(OverriddenPropertyEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property2") + .PropertyName(nameof(OverriddenPropertyEditorBrowsableTagHelper.Property2)) + .TypeName(typeof(int).FullName), + builder => builder + .Name("property") + .PropertyName(nameof(OverriddenPropertyEditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + }) + }, + { + typeof(DefaultEditorBrowsableTagHelper), + true, + CreateTagHelperDescriptor( + tagName: "default-editor-browsable", + typeName: typeof(DefaultEditorBrowsableTagHelper).FullName, + assemblyName: AssemblyName, + attributes: new Action[] + { + builder => builder + .Name("property") + .PropertyName(nameof(DefaultEditorBrowsableTagHelper.Property)) + .TypeName(typeof(int).FullName), + }) + }, + { typeof(MultiEditorBrowsableTagHelper), true, null } + }; + } + } + + [Theory] + [MemberData(nameof(EditorBrowsableData))] + public void CreateDescriptor_UnderstandsEditorBrowsableAttribute( + Type tagHelperType, + bool designTime, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, designTime, designTime); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData AttributeTargetData + { + get + { + var attributes = Enumerable.Empty(); + + // tagHelperType, expectedDescriptor + return new TheoryData + { + { + typeof(AttributeTargetingTagHelper), + CreateTagHelperDescriptor( + TagHelperMatchingConventions.ElementCatchAllName, + typeof(AttributeTargetingTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("class")), + }) + }, + { + typeof(MultiAttributeTargetingTagHelper), + CreateTagHelperDescriptor( + TagHelperMatchingConventions.ElementCatchAllName, + typeof(MultiAttributeTargetingTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => + { + builder + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style")); + }, + }) + }, + { + typeof(MultiAttributeAttributeTargetingTagHelper), + CreateTagHelperDescriptor( + TagHelperMatchingConventions.ElementCatchAllName, + typeof(MultiAttributeAttributeTargetingTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("custom")), + builder => + { + builder + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style")); + }, + }) + }, + { + typeof(InheritedAttributeTargetingTagHelper), + CreateTagHelperDescriptor( + TagHelperMatchingConventions.ElementCatchAllName, + typeof(InheritedAttributeTargetingTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("style")), + }) + }, + { + typeof(RequiredAttributeTagHelper), + CreateTagHelperDescriptor( + "input", + typeof(RequiredAttributeTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("class")), + }) + }, + { + typeof(InheritedRequiredAttributeTagHelper), + CreateTagHelperDescriptor( + "div", + typeof(InheritedRequiredAttributeTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("class")), + }) + }, + { + typeof(MultiAttributeRequiredAttributeTagHelper), + CreateTagHelperDescriptor( + "div", + typeof(MultiAttributeRequiredAttributeTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("class")), + builder => builder + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("class")), + }) + }, + { + typeof(MultiAttributeSameTagRequiredAttributeTagHelper), + CreateTagHelperDescriptor( + "input", + typeof(MultiAttributeSameTagRequiredAttributeTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("style")), + builder => builder.RequireAttributeDescriptor(attribute => attribute.Name("class")), + }) + }, + { + typeof(MultiRequiredAttributeTagHelper), + CreateTagHelperDescriptor( + "input", + typeof(MultiRequiredAttributeTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style")), + }) + }, + { + typeof(MultiTagMultiRequiredAttributeTagHelper), + CreateTagHelperDescriptor( + "div", + typeof(MultiTagMultiRequiredAttributeTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style")), + builder => builder + .RequireTagName("input") + .RequireAttributeDescriptor(attribute => attribute.Name("class")) + .RequireAttributeDescriptor(attribute => attribute.Name("style")), + }) + }, + { + typeof(AttributeWildcardTargetingTagHelper), + CreateTagHelperDescriptor( + TagHelperMatchingConventions.ElementCatchAllName, + typeof(AttributeWildcardTargetingTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("class") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)), + }) + }, + { + typeof(MultiAttributeWildcardTargetingTagHelper), + CreateTagHelperDescriptor( + TagHelperMatchingConventions.ElementCatchAllName, + typeof(MultiAttributeWildcardTargetingTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder + .RequireAttributeDescriptor(attribute => attribute + .Name("class") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)) + .RequireAttributeDescriptor(attribute => attribute + .Name("style") + .NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)), + }) + }, + }; + } + } + + [Theory] + [MemberData(nameof(AttributeTargetData))] + public void CreateDescriptor_ReturnsExpectedDescriptors( + Type tagHelperType, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData HtmlCaseData + { + get + { + // tagHelperType, expectedTagName, expectedAttributeName + return new TheoryData + { + { typeof(SingleAttributeTagHelper), "single-attribute", "int-attribute" }, + { typeof(ALLCAPSTAGHELPER), "allcaps", "allcapsattribute" }, + { typeof(CAPSOnOUTSIDETagHelper), "caps-on-outside", "caps-on-outsideattribute" }, + { typeof(capsONInsideTagHelper), "caps-on-inside", "caps-on-insideattribute" }, + { typeof(One1Two2Three3TagHelper), "one1-two2-three3", "one1-two2-three3-attribute" }, + { typeof(ONE1TWO2THREE3TagHelper), "one1two2three3", "one1two2three3-attribute" }, + { typeof(First_Second_ThirdHiTagHelper), "first_second_third-hi", "first_second_third-attribute" }, + { typeof(UNSuffixedCLASS), "un-suffixed-class", "un-suffixed-attribute" }, + }; + } + } + + [Theory] + [MemberData(nameof(HtmlCaseData))] + public void CreateDescriptor_HtmlCasesTagNameAndAttributeName( + Type tagHelperType, + string expectedTagName, + string expectedAttributeName) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + var rule = Assert.Single(descriptor.TagMatchingRules); + Assert.Equal(expectedTagName, rule.TagName, StringComparer.Ordinal); + var attributeDescriptor = Assert.Single(descriptor.BoundAttributes); + Assert.Equal(expectedAttributeName, attributeDescriptor.Name); + } + + [Fact] + public void CreateDescriptor_OverridesAttributeNameFromAttribute() + { + // Arrange + var validProperty1 = typeof(OverriddenAttributeTagHelper).GetProperty( + nameof(OverriddenAttributeTagHelper.ValidAttribute1)); + var validProperty2 = typeof(OverriddenAttributeTagHelper).GetProperty( + nameof(OverriddenAttributeTagHelper.ValidAttribute2)); + var expectedDescriptor = + CreateTagHelperDescriptor( + "overridden-attribute", + typeof(OverriddenAttributeTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("SomethingElse") + .PropertyName(validProperty1.Name) + .TypeName(validProperty1.PropertyType.FullName), + builder => builder + .Name("Something-Else") + .PropertyName(validProperty2.Name) + .TypeName(validProperty2.PropertyType.FullName), + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(OverriddenAttributeTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_DoesNotInheritOverridenAttributeName() + { + // Arrange + var validProperty1 = typeof(InheritedOverriddenAttributeTagHelper).GetProperty( + nameof(InheritedOverriddenAttributeTagHelper.ValidAttribute1)); + var validProperty2 = typeof(InheritedOverriddenAttributeTagHelper).GetProperty( + nameof(InheritedOverriddenAttributeTagHelper.ValidAttribute2)); + var expectedDescriptor = + CreateTagHelperDescriptor( + "inherited-overridden-attribute", + typeof(InheritedOverriddenAttributeTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("valid-attribute1") + .PropertyName(validProperty1.Name) + .TypeName(validProperty1.PropertyType.FullName), + builder => builder + .Name("Something-Else") + .PropertyName(validProperty2.Name) + .TypeName(validProperty2.PropertyType.FullName), + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(InheritedOverriddenAttributeTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_AllowsOverriddenAttributeNameOnUnimplementedVirtual() + { + // Arrange + var validProperty1 = typeof(InheritedNotOverriddenAttributeTagHelper).GetProperty( + nameof(InheritedNotOverriddenAttributeTagHelper.ValidAttribute1)); + var validProperty2 = typeof(InheritedNotOverriddenAttributeTagHelper).GetProperty( + nameof(InheritedNotOverriddenAttributeTagHelper.ValidAttribute2)); + + var expectedDescriptor = CreateTagHelperDescriptor( + "inherited-not-overridden-attribute", + typeof(InheritedNotOverriddenAttributeTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("SomethingElse") + .PropertyName(validProperty1.Name) + .TypeName(validProperty1.PropertyType.FullName), + builder => builder + .Name("Something-Else") + .PropertyName(validProperty2.Name) + .TypeName(validProperty2.PropertyType.FullName), + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(InheritedNotOverriddenAttributeTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_BuildsDescriptorsWithInheritedProperties() + { + // Arrange + var expectedDescriptor = CreateTagHelperDescriptor( + "inherited-single-attribute", + typeof(InheritedSingleAttributeTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("int-attribute") + .PropertyName(nameof(InheritedSingleAttributeTagHelper.IntAttribute)) + .TypeName(typeof(int).FullName) + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(InheritedSingleAttributeTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_BuildsDescriptorsWithConventionNames() + { + // Arrange + var intProperty = typeof(SingleAttributeTagHelper).GetProperty(nameof(SingleAttributeTagHelper.IntAttribute)); + var expectedDescriptor = CreateTagHelperDescriptor( + "single-attribute", + typeof(SingleAttributeTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("int-attribute") + .PropertyName(intProperty.Name) + .TypeName(intProperty.PropertyType.FullName) + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(SingleAttributeTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_OnlyAcceptsPropertiesWithGetAndSet() + { + // Arrange + var validProperty = typeof(MissingAccessorTagHelper).GetProperty( + nameof(MissingAccessorTagHelper.ValidAttribute)); + var expectedDescriptor = CreateTagHelperDescriptor( + "missing-accessor", + typeof(MissingAccessorTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("valid-attribute") + .PropertyName(validProperty.Name) + .TypeName(validProperty.PropertyType.FullName) + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(MissingAccessorTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_OnlyAcceptsPropertiesWithPublicGetAndSet() + { + // Arrange + var validProperty = typeof(NonPublicAccessorTagHelper).GetProperty( + nameof(NonPublicAccessorTagHelper.ValidAttribute)); + var expectedDescriptor = CreateTagHelperDescriptor( + "non-public-accessor", + typeof(NonPublicAccessorTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("valid-attribute") + .PropertyName(validProperty.Name) + .TypeName(validProperty.PropertyType.FullName) + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(NonPublicAccessorTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_DoesNotIncludePropertiesWithNotBound() + { + // Arrange + var expectedDescriptor = CreateTagHelperDescriptor( + "not-bound-attribute", + typeof(NotBoundAttributeTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("bound-property") + .PropertyName(nameof(NotBoundAttributeTagHelper.BoundProperty)) + .TypeName(typeof(object).FullName) + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(NotBoundAttributeTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_ResolvesMultipleTagHelperDescriptorsFromSingleType() + { + // Arrange + var expectedDescriptor = + CreateTagHelperDescriptor( + string.Empty, + typeof(MultiTagTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("valid-attribute") + .PropertyName(nameof(MultiTagTagHelper.ValidAttribute)) + .TypeName(typeof(string).FullName), + }, + new Action[] + { + builder => builder.RequireTagName("p"), + builder => builder.RequireTagName("div"), + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(MultiTagTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_DoesNotResolveInheritedTagNames() + { + // Arrange + var validProp = typeof(InheritedMultiTagTagHelper).GetProperty(nameof(InheritedMultiTagTagHelper.ValidAttribute)); + var expectedDescriptor = CreateTagHelperDescriptor( + "inherited-multi-tag", + typeof(InheritedMultiTagTagHelper).FullName, + AssemblyName, + new Action[] + { + builder => builder + .Name("valid-attribute") + .PropertyName(validProp.Name) + .TypeName(validProp.PropertyType.FullName), + }); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(InheritedMultiTagTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_IgnoresDuplicateTagNamesFromAttribute() + { + // Arrange + var expectedDescriptor = CreateTagHelperDescriptor( + string.Empty, + typeof(DuplicateTagNameTagHelper).FullName, + AssemblyName, + ruleBuilders: new Action[] + { + builder => builder.RequireTagName("p"), + builder => builder.RequireTagName("div"), + }); + + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(DuplicateTagNameTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_OverridesTagNameFromAttribute() + { + // Arrange + var expectedDescriptor = + CreateTagHelperDescriptor( + "data-condition", + typeof(OverrideNameTagHelper).FullName, + AssemblyName); + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(OverrideNameTagHelper).FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + // name, expectedErrorMessages + public static TheoryData InvalidNameData + { + get + { + Func onNameError = + (invalidText, invalidCharacter) => $"Tag helpers cannot target tag name '{invalidText}' because it contains a '{invalidCharacter}' character."; + var whitespaceErrorString = "Targeted tag name cannot be null or whitespace."; + + var data = GetInvalidNameOrPrefixData(onNameError, whitespaceErrorString, onDataError: null); + data.Add(string.Empty, new[] { whitespaceErrorString }); + + return data; + } + } + + [Theory] + [MemberData(nameof(InvalidNameData))] + public void CreateDescriptor_CreatesErrorOnInvalidNames( + string name, string[] expectedErrorMessages) + { + // Arrange + name = name.Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\""); + var text = $@" + [{typeof(AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute).FullName}(""{name}"")] + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var attribute = tagHelperType.GetAttributes().Single(); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + var rule = Assert.Single(descriptor.TagMatchingRules); + var errorMessages = rule.GetAllDiagnostics().Select(diagnostic => diagnostic.GetMessage()).ToArray(); + Assert.Equal(expectedErrorMessages.Length, errorMessages.Length); + for (var i = 0; i < expectedErrorMessages.Length; i++) + { + Assert.Equal(expectedErrorMessages[i], errorMessages[i], StringComparer.Ordinal); + } + } + + public static TheoryData ValidNameData + { + get + { + // name, expectedNames + return new TheoryData> + { + { "p", new[] { "p" } }, + { " p", new[] { "p" } }, + { "p ", new[] { "p" } }, + { " p ", new[] { "p" } }, + { "p,div", new[] { "p", "div" } }, + { " p,div", new[] { "p", "div" } }, + { "p ,div", new[] { "p", "div" } }, + { " p ,div", new[] { "p", "div" } }, + { "p, div", new[] { "p", "div" } }, + { "p,div ", new[] { "p", "div" } }, + { "p, div ", new[] { "p", "div" } }, + { " p, div ", new[] { "p", "div" } }, + { " p , div ", new[] { "p", "div" } }, + }; + } + } + + public static TheoryData InvalidTagHelperAttributeDescriptorData + { + get + { + var invalidBoundAttributeBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, nameof(InvalidBoundAttribute), "Test"); + invalidBoundAttributeBuilder.TypeName(typeof(InvalidBoundAttribute).FullName); + + // type, expectedAttributeDescriptors + return new TheoryData> + { + { + typeof(InvalidBoundAttribute), + new[] + { + CreateAttributeFor(typeof(InvalidBoundAttribute), attribute => + { + attribute + .Name("data-something") + .PropertyName(nameof(InvalidBoundAttribute.DataSomething)) + .TypeName(typeof(string).FullName); + }), + } + }, + { + typeof(InvalidBoundAttributeWithValid), + new[] + { + CreateAttributeFor(typeof(InvalidBoundAttributeWithValid), attribute => + { + attribute + .Name("data-something") + .PropertyName(nameof(InvalidBoundAttributeWithValid.DataSomething)) + .TypeName(typeof(string).FullName); ; + }), + CreateAttributeFor(typeof(InvalidBoundAttributeWithValid), attribute => + { + attribute + .Name("int-attribute") + .PropertyName(nameof(InvalidBoundAttributeWithValid.IntAttribute)) + .TypeName(typeof(int).FullName); + }), + } + }, + { + typeof(OverriddenInvalidBoundAttributeWithValid), + new[] + { + CreateAttributeFor(typeof(OverriddenInvalidBoundAttributeWithValid), attribute => + { + attribute + .Name("valid-something") + .PropertyName(nameof(OverriddenInvalidBoundAttributeWithValid.DataSomething)) + .TypeName(typeof(string).FullName); + }), + } + }, + { + typeof(OverriddenValidBoundAttributeWithInvalid), + new[] + { + CreateAttributeFor(typeof(OverriddenValidBoundAttributeWithInvalid), attribute => + { + attribute + .Name("data-something") + .PropertyName(nameof(OverriddenValidBoundAttributeWithInvalid.ValidSomething)) + .TypeName(typeof(string).FullName); + }), + } + }, + { + typeof(OverriddenValidBoundAttributeWithInvalidUpperCase), + new[] + { + CreateAttributeFor(typeof(OverriddenValidBoundAttributeWithInvalidUpperCase), attribute => + { + attribute + .Name("DATA-SOMETHING") + .PropertyName(nameof(OverriddenValidBoundAttributeWithInvalidUpperCase.ValidSomething)) + .TypeName(typeof(string).FullName); + }), + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(InvalidTagHelperAttributeDescriptorData))] + public void CreateDescriptor_DoesNotAllowDataDashAttributes( + Type type, + IEnumerable expectedAttributeDescriptors) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(type.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal( + expectedAttributeDescriptors, + descriptor.BoundAttributes, + BoundAttributeDescriptorComparer.Default); + + var id = AspNetCore.Razor.Language.RazorDiagnosticFactory.TagHelper_InvalidBoundAttributeNameStartsWith.Id; + foreach (var attribute in descriptor.BoundAttributes.Where(a => a.Name.StartsWith("data-", StringComparison.OrdinalIgnoreCase))) + { + var diagnostic = Assert.Single(attribute.Diagnostics); + Assert.Equal(id, diagnostic.Id); + } + } + + public static TheoryData ValidAttributeNameData + { + get + { + return new TheoryData + { + "data", + "dataa-", + "ValidName", + "valid-name", + "--valid--name--", + ",,--__..oddly.valid::;;", + }; + } + } + + [Theory] + [MemberData(nameof(ValidAttributeNameData))] + public void CreateDescriptor_WithValidAttributeName_HasNoErrors(string name) + { + // Arrange + var text = $@" + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + [{typeof(AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute).FullName}(""{name}"")] + public string SomeAttribute {{ get; set; }} + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + Assert.False(descriptor.HasErrors); + } + + public static TheoryData ValidAttributePrefixData + { + get + { + return new TheoryData + { + string.Empty, + "data", + "dataa-", + "ValidName", + "valid-name", + "--valid--name--", + ",,--__..oddly.valid::;;", + }; + } + } + + [Theory] + [MemberData(nameof(ValidAttributePrefixData))] + public void CreateDescriptor_WithValidAttributePrefix_HasNoErrors(string prefix) + { + // Arrange + var text = $@" + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + [{typeof(AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute).FullName}({nameof(AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute.DictionaryAttributePrefix)} = ""{prefix}"")] + public System.Collections.Generic.IDictionary SomeAttribute {{ get; set; }} + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + Assert.False(descriptor.HasErrors); + } + + // name, expectedErrorMessages + public static TheoryData InvalidAttributeNameData + { + get + { + Func onNameError = (invalidText, invalidCharacter) => + "Invalid tag helper bound property 'string DynamicTestTagHelper.InvalidProperty' on tag helper 'DynamicTestTagHelper'. Tag helpers " + + $"cannot bind to HTML attributes with name '{invalidText}' because the name contains a '{invalidCharacter}' character."; + var whitespaceErrorString = + "Invalid tag helper bound property 'string DynamicTestTagHelper.InvalidProperty' on tag helper 'DynamicTestTagHelper'. Tag helpers cannot " + + "bind to HTML attributes with a null or empty name."; + Func onDataError = invalidText => + "Invalid tag helper bound property 'string DynamicTestTagHelper.InvalidProperty' on tag helper 'DynamicTestTagHelper'. Tag helpers cannot bind " + + $"to HTML attributes with name '{invalidText}' because the name starts with 'data-'."; + + return GetInvalidNameOrPrefixData(onNameError, whitespaceErrorString, onDataError); + } + } + + [Theory] + [MemberData(nameof(InvalidAttributeNameData))] + public void CreateDescriptor_WithInvalidAttributeName_HasErrors(string name, string[] expectedErrorMessages) + { + // Arrange + name = name.Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\""); + var text = $@" + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + [{typeof(AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute).FullName}(""{name}"")] + public string InvalidProperty {{ get; set; }} + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + var errorMessages = descriptor.GetAllDiagnostics().Select(diagnostic => diagnostic.GetMessage()); + Assert.Equal(expectedErrorMessages, errorMessages); + } + + // prefix, expectedErrorMessages + public static TheoryData InvalidAttributePrefixData + { + get + { + Func onPrefixError = (invalidText, invalidCharacter) => + "Invalid tag helper bound property 'System.Collections.Generic.IDictionary DynamicTestTagHelper.InvalidProperty' " + + "on tag helper 'DynamicTestTagHelper'. Tag helpers " + + $"cannot bind to HTML attributes with prefix '{invalidText}' because the prefix contains a '{invalidCharacter}' character."; + var whitespaceErrorString = + "Invalid tag helper bound property 'System.Collections.Generic.IDictionary DynamicTestTagHelper.InvalidProperty' " + + "on tag helper 'DynamicTestTagHelper'. Tag helpers cannot bind to HTML attributes with a null or empty name."; + Func onDataError = invalidText => + "Invalid tag helper bound property 'System.Collections.Generic.IDictionary DynamicTestTagHelper.InvalidProperty' " + + "on tag helper 'DynamicTestTagHelper'. Tag helpers cannot bind to HTML attributes " + + $"with prefix '{invalidText}' because the prefix starts with 'data-'."; + + return GetInvalidNameOrPrefixData(onPrefixError, whitespaceErrorString, onDataError); + } + } + + [Theory] + [MemberData(nameof(InvalidAttributePrefixData))] + public void CreateDescriptor_WithInvalidAttributePrefix_HasErrors(string prefix, string[] expectedErrorMessages) + { + // Arrange + prefix = prefix.Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\""); + var text = $@" + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + [{typeof(AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute).FullName}({nameof(AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute.DictionaryAttributePrefix)} = ""{prefix}"")] + public System.Collections.Generic.IDictionary InvalidProperty {{ get; set; }} + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + var errorMessages = descriptor.GetAllDiagnostics().Select(diagnostic => diagnostic.GetMessage()); + Assert.Equal(expectedErrorMessages, errorMessages); + } + + public static TheoryData InvalidRestrictChildrenNameData + { + get + { + var nullOrWhiteSpaceError = + AspNetCore.Razor.Language.Resources.FormatTagHelper_InvalidRestrictedChildNullOrWhitespace("DynamicTestTagHelper"); + + return GetInvalidNameOrPrefixData( + onNameError: (invalidInput, invalidCharacter) => + AspNetCore.Razor.Language.Resources.FormatTagHelper_InvalidRestrictedChild( + "DynamicTestTagHelper", + invalidInput, + invalidCharacter), + whitespaceErrorString: nullOrWhiteSpaceError, + onDataError: null); + } + } + + [Theory] + [MemberData(nameof(InvalidRestrictChildrenNameData))] + public void CreateDescriptor_WithInvalidAllowedChildren_HasErrors(string name, string[] expectedErrorMessages) + { + // Arrange + name = name.Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\""); + var text = $@" + [{typeof(AspNetCore.Razor.TagHelpers.RestrictChildrenAttribute).FullName}(""{name}"")] + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + var errorMessages = descriptor.GetAllDiagnostics().Select(diagnostic => diagnostic.GetMessage()); + Assert.Equal(expectedErrorMessages, errorMessages); + } + + public static TheoryData InvalidParentTagData + { + get + { + var nullOrWhiteSpaceError = + AspNetCore.Razor.Language.Resources.TagHelper_InvalidTargetedParentTagNameNullOrWhitespace; + + return GetInvalidNameOrPrefixData( + onNameError: (invalidInput, invalidCharacter) => + AspNetCore.Razor.Language.Resources.FormatTagHelper_InvalidTargetedParentTagName( + invalidInput, + invalidCharacter), + whitespaceErrorString: nullOrWhiteSpaceError, + onDataError: null); + } + } + + [Theory] + [MemberData(nameof(InvalidParentTagData))] + public void CreateDescriptor_WithInvalidParentTag_HasErrors(string name, string[] expectedErrorMessages) + { + // Arrange + name = name.Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\""); + var text = $@" + [{typeof(AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute).FullName}({nameof(AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute.ParentTag)} = ""{name}"")] + public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName} + {{ + }}"; + var syntaxTree = CSharpSyntaxTree.ParseText(text); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var tagHelperType = compilation.GetTypeByMetadataName("DynamicTestTagHelper"); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: false, excludeHidden: false); + + // Act + var descriptor = factory.CreateDescriptor(tagHelperType); + + // Assert + var errorMessages = descriptor.GetAllDiagnostics().Select(diagnostic => diagnostic.GetMessage()); + Assert.Equal(expectedErrorMessages, errorMessages); + } + + [Fact] + public void CreateDescriptor_BuildsDescriptorsFromSimpleTypes() + { + // Arrange + var objectAssemblyName = typeof(Enumerable).GetTypeInfo().Assembly.GetName().Name; + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(typeof(Enumerable).FullName); + var expectedDescriptor = + CreateTagHelperDescriptor("enumerable", "System.Linq.Enumerable", typeSymbol.ContainingAssembly.Identity.Name); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + public static TheoryData TagHelperWithPrefixData + { + get + { + var dictionaryNamespace = typeof(IDictionary<,>).FullName; + dictionaryNamespace = dictionaryNamespace.Substring(0, dictionaryNamespace.IndexOf('`')); + + // tagHelperType, expectedAttributeDescriptors, expectedDiagnostics + return new TheoryData, IEnumerable> + { + { + typeof(DefaultValidHtmlAttributePrefix), + new[] + { + CreateAttributeFor(typeof(DefaultValidHtmlAttributePrefix), attribute => + { + attribute + .Name("dictionary-property") + .PropertyName(nameof(DefaultValidHtmlAttributePrefix.DictionaryProperty)) + .TypeName($"{dictionaryNamespace}") + .AsDictionaryAttribute("dictionary-property-", typeof(string).FullName); + }), + }, + Enumerable.Empty() + }, + { + typeof(SingleValidHtmlAttributePrefix), + new[] + { + CreateAttributeFor(typeof(SingleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name") + .PropertyName(nameof(SingleValidHtmlAttributePrefix.DictionaryProperty)) + .TypeName($"{dictionaryNamespace}") + .AsDictionaryAttribute("valid-name-", typeof(string).FullName); + }), + }, + Enumerable.Empty() + }, + { + typeof(MultipleValidHtmlAttributePrefix), + new[] + { + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name1") + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.DictionaryProperty)) + .TypeName($"{typeof(Dictionary<,>).Namespace}.Dictionary") + .AsDictionaryAttribute("valid-prefix1-", typeof(object).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name2") + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.DictionarySubclassProperty)) + .TypeName(typeof(DictionarySubclass).FullName) + .AsDictionaryAttribute("valid-prefix2-", typeof(string).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name3") + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.DictionaryWithoutParameterlessConstructorProperty)) + .TypeName(typeof(DictionaryWithoutParameterlessConstructor).FullName) + .AsDictionaryAttribute("valid-prefix3-", typeof(string).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name4") + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.GenericDictionarySubclassProperty)) + .TypeName(typeof(GenericDictionarySubclass).Namespace + ".GenericDictionarySubclass") + .AsDictionaryAttribute("valid-prefix4-", typeof(object).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name5") + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.SortedDictionaryProperty)) + .TypeName(typeof(SortedDictionary).Namespace + ".SortedDictionary") + .AsDictionaryAttribute("valid-prefix5-", typeof(int).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name6") + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.StringProperty)) + .TypeName(typeof(string).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.GetOnlyDictionaryProperty)) + .TypeName($"{dictionaryNamespace}") + .AsDictionaryAttribute("get-only-dictionary-property-", typeof(int).FullName); + }), + CreateAttributeFor(typeof(MultipleValidHtmlAttributePrefix), attribute => + { + attribute + .PropertyName(nameof(MultipleValidHtmlAttributePrefix.GetOnlyDictionaryPropertyWithAttributePrefix)) + .TypeName($"{dictionaryNamespace}") + .AsDictionaryAttribute("valid-prefix6", typeof(string).FullName); + }), + }, + Enumerable.Empty() + }, + { + typeof(SingleInvalidHtmlAttributePrefix), + new[] + { + CreateAttributeFor(typeof(SingleInvalidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name") + .PropertyName(nameof(SingleInvalidHtmlAttributePrefix.StringProperty)) + .TypeName(typeof(string).FullName) + .AddDiagnostic(RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(SingleInvalidHtmlAttributePrefix).FullName, + nameof(SingleInvalidHtmlAttributePrefix.StringProperty))); + }), + }, + new[] + { + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(SingleInvalidHtmlAttributePrefix).FullName, + nameof(SingleInvalidHtmlAttributePrefix.StringProperty)) + } + }, + { + typeof(MultipleInvalidHtmlAttributePrefix), + new[] + { + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name1") + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.LongProperty)) + .TypeName(typeof(long).FullName); + }), + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name2") + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.DictionaryOfIntProperty)) + .TypeName($"{typeof(Dictionary<,>).Namespace}.Dictionary") + .AsDictionaryAttribute("valid-prefix2-", typeof(string).FullName) + .AddDiagnostic( + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.DictionaryOfIntProperty))); + }), + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name3") + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.ReadOnlyDictionaryProperty)) + .TypeName($"{typeof(IReadOnlyDictionary<,>).Namespace}.IReadOnlyDictionary") + .AddDiagnostic( + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.ReadOnlyDictionaryProperty))); + }), + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name4") + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.IntProperty)) + .TypeName(typeof(int).FullName) + .AddDiagnostic( + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.IntProperty))); + }), + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .Name("valid-name5") + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.DictionaryOfIntSubclassProperty)) + .TypeName(typeof(DictionaryOfIntSubclass).FullName) + .AsDictionaryAttribute("valid-prefix5-", typeof(string).FullName) + .AddDiagnostic( + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.DictionaryOfIntSubclassProperty))); + }), + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.GetOnlyDictionaryAttributePrefix)) + .TypeName($"{dictionaryNamespace}") + .AsDictionaryAttribute("valid-prefix6", typeof(string).FullName) + .AddDiagnostic( + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.GetOnlyDictionaryAttributePrefix))); + }), + CreateAttributeFor(typeof(MultipleInvalidHtmlAttributePrefix), attribute => + { + attribute + .PropertyName(nameof(MultipleInvalidHtmlAttributePrefix.GetOnlyDictionaryPropertyWithAttributeName)) + .TypeName($"{dictionaryNamespace}") + .AsDictionaryAttribute("invalid-name7-", typeof(object).FullName) + .AddDiagnostic( + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.GetOnlyDictionaryPropertyWithAttributeName))); + }), + }, + new[] + { + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.DictionaryOfIntProperty)), + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.ReadOnlyDictionaryProperty)), + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.IntProperty)), + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.DictionaryOfIntSubclassProperty)), + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNotNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.GetOnlyDictionaryAttributePrefix)), + RazorDiagnosticFactory.CreateTagHelper_InvalidAttributePrefixNull( + typeof(MultipleInvalidHtmlAttributePrefix).FullName, + nameof(MultipleInvalidHtmlAttributePrefix.GetOnlyDictionaryPropertyWithAttributeName)), + } + }, + }; + } + } + + [Theory] + [MemberData(nameof(TagHelperWithPrefixData))] + public void CreateDescriptor_WithPrefixes_ReturnsExpectedAttributeDescriptors( + Type tagHelperType, + IEnumerable expectedAttributeDescriptors, + IEnumerable expectedDiagnostics) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal( + expectedAttributeDescriptors, + descriptor.BoundAttributes, + BoundAttributeDescriptorComparer.Default); + Assert.Equal(expectedDiagnostics, descriptor.GetAllDiagnostics()); + } + + public static TheoryData TagOutputHintData + { + get + { + // tagHelperType, expectedDescriptor + return new TheoryData + { + { + typeof(MultipleDescriptorTagHelperWithOutputElementHint), + TagHelperDescriptorBuilder.Create(typeof(MultipleDescriptorTagHelperWithOutputElementHint).FullName, AssemblyName) + .TypeName(typeof(MultipleDescriptorTagHelperWithOutputElementHint).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("a")) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("p")) + .TagOutputHint("div") + .Build() + }, + { + typeof(InheritedOutputElementHintTagHelper), + TagHelperDescriptorBuilder.Create(typeof(InheritedOutputElementHintTagHelper).FullName, AssemblyName) + .TypeName(typeof(InheritedOutputElementHintTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("inherited-output-element-hint")) + .Build() + }, + { + typeof(OutputElementHintTagHelper), + TagHelperDescriptorBuilder.Create(typeof(OutputElementHintTagHelper).FullName, AssemblyName) + .TypeName(typeof(OutputElementHintTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("output-element-hint")) + .TagOutputHint("hinted-value") + .Build() + }, + { + typeof(OverriddenOutputElementHintTagHelper), + TagHelperDescriptorBuilder.Create(typeof(OverriddenOutputElementHintTagHelper).FullName, AssemblyName) + .TypeName(typeof(OverriddenOutputElementHintTagHelper).FullName) + .TagMatchingRuleDescriptor(builder => builder.RequireTagName("overridden-output-element-hint")) + .TagOutputHint("overridden") + .Build() + }, + }; + } + } + + [Theory] + [MemberData(nameof(TagOutputHintData))] + public void CreateDescriptor_CreatesDescriptorsWithOutputElementHint( + Type tagHelperType, + TagHelperDescriptor expectedDescriptor) + { + // Arrange + var factory = new DefaultTagHelperDescriptorFactory(Compilation, includeDocumentation: false, excludeHidden: false); + var typeSymbol = Compilation.GetTypeByMetadataName(tagHelperType.FullName); + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); + } + + [Fact] + public void CreateDescriptor_CapturesDocumentationOnTagHelperClass() + { + // Arrange + var errorSink = new ErrorSink(); + var syntaxTree = CSharpSyntaxTree.ParseText(@" + using Microsoft.AspNetCore.Razor.TagHelpers; + + /// + /// The summary for . + /// + /// + /// Inherits from . + /// + public class DocumentedTagHelper : " + typeof(AspNetCore.Razor.TagHelpers.TagHelper).Name + @" + { + }"); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: true, excludeHidden: false); + var typeSymbol = compilation.GetTypeByMetadataName("DocumentedTagHelper"); + var expectedDocumentation = +@" + + The summary for . + + + Inherits from . + + +"; + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + Assert.Equal(expectedDocumentation, descriptor.Documentation); + } + + [Fact] + public void CreateDescriptor_CapturesDocumentationOnTagHelperProperties() + { + // Arrange + var errorSink = new ErrorSink(); + var syntaxTree = CSharpSyntaxTree.ParseText(@" + using System.Collections.Generic; + + public class DocumentedTagHelper : " + typeof(AspNetCore.Razor.TagHelpers.TagHelper).FullName + @" + { + /// + /// This is of type . + /// + public string SummaryProperty { get; set; } + + /// + /// The may be null. + /// + public int RemarksProperty { get; set; } + + /// + /// This is a complex . + /// + /// + /// + /// + public List RemarksAndSummaryProperty { get; set; } + }"); + var compilation = TestCompilation.Create(_assembly, syntaxTree); + var factory = new DefaultTagHelperDescriptorFactory(compilation, includeDocumentation: true, excludeHidden: false); + var typeSymbol = compilation.GetTypeByMetadataName("DocumentedTagHelper"); + var expectedDocumentations = new[] + { + +@" + + This is of type . + + +", +@" + + The may be null. + + +", +@" + + This is a complex . + + + + + +", + }; + + // Act + var descriptor = factory.CreateDescriptor(typeSymbol); + + // Assert + var documentations = descriptor.BoundAttributes.Select(boundAttribute => boundAttribute.Documentation); + Assert.Equal(expectedDocumentations, documentations); + } + + private static TheoryData GetInvalidNameOrPrefixData( + Func onNameError, + string whitespaceErrorString, + Func onDataError) + { + // name, expectedErrorMessages + var data = new TheoryData + { + { "!", new[] { onNameError("!", "!") } }, + { "hello!", new[] { onNameError("hello!", "!") } }, + { "!hello", new[] { onNameError("!hello", "!") } }, + { "he!lo", new[] { onNameError("he!lo", "!") } }, + { "!he!lo!", new[] { onNameError("!he!lo!", "!") } }, + { "@", new[] { onNameError("@", "@") } }, + { "hello@", new[] { onNameError("hello@", "@") } }, + { "@hello", new[] { onNameError("@hello", "@") } }, + { "he@lo", new[] { onNameError("he@lo", "@") } }, + { "@he@lo@", new[] { onNameError("@he@lo@", "@") } }, + { "/", new[] { onNameError("/", "/") } }, + { "hello/", new[] { onNameError("hello/", "/") } }, + { "/hello", new[] { onNameError("/hello", "/") } }, + { "he/lo", new[] { onNameError("he/lo", "/") } }, + { "/he/lo/", new[] { onNameError("/he/lo/", "/") } }, + { "<", new[] { onNameError("<", "<") } }, + { "hello<", new[] { onNameError("hello<", "<") } }, + { "", new[] { onNameError(">", ">") } }, + { "hello>", new[] { onNameError("hello>", ">") } }, + { ">hello", new[] { onNameError(">hello", ">") } }, + { "he>lo", new[] { onNameError("he>lo", ">") } }, + { ">he>lo>", new[] { onNameError(">he>lo>", ">") } }, + { "]", new[] { onNameError("]", "]") } }, + { "hello]", new[] { onNameError("hello]", "]") } }, + { "]hello", new[] { onNameError("]hello", "]") } }, + { "he]lo", new[] { onNameError("he]lo", "]") } }, + { "]he]lo]", new[] { onNameError("]he]lo]", "]") } }, + { "=", new[] { onNameError("=", "=") } }, + { "hello=", new[] { onNameError("hello=", "=") } }, + { "=hello", new[] { onNameError("=hello", "=") } }, + { "he=lo", new[] { onNameError("he=lo", "=") } }, + { "=he=lo=", new[] { onNameError("=he=lo=", "=") } }, + { "\"", new[] { onNameError("\"", "\"") } }, + { "hello\"", new[] { onNameError("hello\"", "\"") } }, + { "\"hello", new[] { onNameError("\"hello", "\"") } }, + { "he\"lo", new[] { onNameError("he\"lo", "\"") } }, + { "\"he\"lo\"", new[] { onNameError("\"he\"lo\"", "\"") } }, + { "'", new[] { onNameError("'", "'") } }, + { "hello'", new[] { onNameError("hello'", "'") } }, + { "'hello", new[] { onNameError("'hello", "'") } }, + { "he'lo", new[] { onNameError("he'lo", "'") } }, + { "'he'lo'", new[] { onNameError("'he'lo'", "'") } }, + { "hello*", new[] { onNameError("hello*", "*") } }, + { "*hello", new[] { onNameError("*hello", "*") } }, + { "he*lo", new[] { onNameError("he*lo", "*") } }, + { "*he*lo*", new[] { onNameError("*he*lo*", "*") } }, + { Environment.NewLine, new[] { whitespaceErrorString } }, + { "\t", new[] { whitespaceErrorString } }, + { " \t ", new[] { whitespaceErrorString } }, + { " ", new[] { whitespaceErrorString } }, + { Environment.NewLine + " ", new[] { whitespaceErrorString } }, + { + "! \t\r\n@/<>?[]=\"'*", + new[] + { + onNameError("! \t\r\n@/<>?[]=\"'*", "!"), + onNameError("! \t\r\n@/<>?[]=\"'*", " "), + onNameError("! \t\r\n@/<>?[]=\"'*", "\t"), + onNameError("! \t\r\n@/<>?[]=\"'*", "\r"), + onNameError("! \t\r\n@/<>?[]=\"'*", "\n"), + onNameError("! \t\r\n@/<>?[]=\"'*", "@"), + onNameError("! \t\r\n@/<>?[]=\"'*", "/"), + onNameError("! \t\r\n@/<>?[]=\"'*", "<"), + onNameError("! \t\r\n@/<>?[]=\"'*", ">"), + onNameError("! \t\r\n@/<>?[]=\"'*", "?"), + onNameError("! \t\r\n@/<>?[]=\"'*", "["), + onNameError("! \t\r\n@/<>?[]=\"'*", "]"), + onNameError("! \t\r\n@/<>?[]=\"'*", "="), + onNameError("! \t\r\n@/<>?[]=\"'*", "\""), + onNameError("! \t\r\n@/<>?[]=\"'*", "'"), + onNameError("! \t\r\n@/<>?[]=\"'*", "*"), + } + }, + { + "! \tv\ra\nl@i/d<>?[]=\"'*", + new[] + { + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "!"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", " "), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "\t"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "\r"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "\n"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "@"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "/"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "<"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", ">"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "?"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "["), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "]"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "="), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "\""), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "'"), + onNameError("! \tv\ra\nl@i/d<>?[]=\"'*", "*"), + } + }, + }; + + if (onDataError != null) + { + data.Add("data-", new[] { onDataError("data-") }); + data.Add("data-something", new[] { onDataError("data-something") }); + data.Add("Data-Something", new[] { onDataError("Data-Something") }); + data.Add("DATA-SOMETHING", new[] { onDataError("DATA-SOMETHING") }); + } + + return data; + } + + protected static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null, + IEnumerable> ruleBuilders = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + builder.TypeName(typeName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BoundAttributeDescriptor(attributeBuilder); + } + } + + if (ruleBuilders != null) + { + foreach (var ruleBuilder in ruleBuilders) + { + builder.TagMatchingRuleDescriptor(innerRuleBuilder => + { + innerRuleBuilder.RequireTagName(tagName); + ruleBuilder(innerRuleBuilder); + }); + } + } + else + { + builder.TagMatchingRuleDescriptor(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + } + + var descriptor = builder.Build(); + + return descriptor; + } + + private static BoundAttributeDescriptor CreateAttributeFor(Type tagHelperType, Action configure) + { + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, tagHelperType.Name, "Test"); + tagHelperBuilder.TypeName(tagHelperType.FullName); + + var attributeBuilder = new DefaultBoundAttributeDescriptorBuilder(tagHelperBuilder, TagHelperConventions.DefaultKind); + configure(attributeBuilder); + return attributeBuilder.Build(); + } + } + + [AspNetCore.Razor.TagHelpers.OutputElementHint("hinted-value")] + public class OutputElementHintTagHelper : AspNetCore.Razor.TagHelpers.TagHelper + { + } + + public class InheritedOutputElementHintTagHelper : OutputElementHintTagHelper + { + } + + [AspNetCore.Razor.TagHelpers.OutputElementHint("overridden")] + public class OverriddenOutputElementHintTagHelper : OutputElementHintTagHelper + { + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..0a933ed34f --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorProviderTest.cs @@ -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.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class DefaultTagHelperDescriptorProviderTest + { + private static readonly Assembly _assembly = typeof(DefaultTagHelperDescriptorProviderTest).GetTypeInfo().Assembly; + + [Fact] + public void Execute_DoesNotAddEditorBrowsableNeverDescriptorsAtDesignTime() + { + // Arrange + var editorBrowsableTypeName = "Microsoft.CodeAnalysis.Razor.Workspaces.Test.EditorBrowsableTagHelper"; + var compilation = TestCompilation.Create(_assembly); + var descriptorProvider = new DefaultTagHelperDescriptorProvider(); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + context.ExcludeHidden = true; + + // Act + descriptorProvider.Execute(context); + + // Assert + Assert.NotNull(compilation.GetTypeByMetadataName(editorBrowsableTypeName)); + var nullDescriptors = context.Results.Where(descriptor => descriptor == null); + Assert.Empty(nullDescriptors); + var editorBrowsableDescriptor = context.Results.Where(descriptor => descriptor.GetTypeName() == editorBrowsableTypeName); + Assert.Empty(editorBrowsableDescriptor); + } + + [Fact] + public void Execute_NoOpsIfCompilationIsNotSet() + { + // Arrange + var descriptorProvider = new DefaultTagHelperDescriptorProvider(); + + var context = TagHelperDescriptorProviderContext.Create(); + + // Act + descriptorProvider.Execute(context); + + // Assert + Assert.Empty(context.Results); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..f242f4995d --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs @@ -0,0 +1,130 @@ +// 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 Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class EventHandlerTagHelperDescriptorProviderTest : TagHelperDescriptorProviderTestBase + { + [Fact] + public void Execute_EventHandler_CreatesDescriptor() + { + // Arrange + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; + +namespace Test +{ + [EventHandler(""onclick"", typeof(Action))] + public class EventHandlers + { + } +} +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new EventHandlerTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = GetEventHandlerTagHelpers(context); + var item = Assert.Single(matches); + + // These are features Event Handler Tag Helpers don't use. Verifying them once here and + // then ignoring them. + Assert.Empty(item.AllowedChildTags); + Assert.Null(item.TagOutputHint); + + // These are features that are invariants of all Event Handler Helpers. Verifying them once + // here and then ignoring them. + Assert.Empty(item.Diagnostics); + Assert.False(item.HasErrors); + Assert.Equal(ComponentMetadata.EventHandler.TagHelperKind, item.Kind); + Assert.Equal(bool.TrueString, item.Metadata[TagHelperMetadata.Common.ClassifyAttributesOnly]); + Assert.Equal(ComponentMetadata.EventHandler.RuntimeName, item.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(item.IsDefaultKind()); + Assert.False(item.KindUsesDefaultTagHelperRuntime()); + Assert.False(item.IsComponentOrChildContentTagHelper()); + Assert.True(item.CaseSensitive); + + Assert.Equal( + "Sets the '@onclick' attribute to the provided string or delegate value. " + + "A delegate value should be of type 'System.Action'.", + item.Documentation); + + // These are all trivially derived from the assembly/namespace/type name + Assert.Equal("Microsoft.AspNetCore.Components", item.AssemblyName); + Assert.Equal("onclick", item.Name); + Assert.Equal("Test.EventHandlers", item.DisplayName); + Assert.Equal("Test.EventHandlers", item.GetTypeName()); + + // The tag matching rule for an event handler is just the attribute name + var rule = Assert.Single(item.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("*", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@onclick", requiredAttribute.DisplayName); + Assert.Equal("@onclick", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(item.BoundAttributes); + + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.EventHandler.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Collection( + attribute.Metadata.OrderBy(kvp => kvp.Key), + kvp => Assert.Equal(kvp, new KeyValuePair(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString)), + kvp => Assert.Equal(kvp, new KeyValuePair("Common.PropertyName", "onclick")), + kvp => Assert.Equal(kvp, new KeyValuePair(ComponentMetadata.Component.WeaklyTypedKey, bool.TrueString))); + + Assert.Equal( + "Sets the '@onclick' attribute to the provided string or delegate value. " + + "A delegate value should be of type 'System.Action'.", + attribute.Documentation); + + Assert.Equal("@onclick", attribute.Name); + Assert.Equal("onclick", attribute.GetPropertyName()); + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback> Test.EventHandlers.onclick", attribute.DisplayName); + + // Defined from the property type + Assert.Equal("Microsoft.AspNetCore.Components.EventCallback>", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + } + + private static TagHelperDescriptor[] GetEventHandlerTagHelpers(TagHelperDescriptorProviderContext context) + { + return ExcludeBuiltInComponents(context).Where(t => t.IsEventHandlerTagHelper()).ToArray(); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/GenericTypeNameRewriterTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/GenericTypeNameRewriterTest.cs new file mode 100644 index 0000000000..9dfd35dbc5 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/GenericTypeNameRewriterTest.cs @@ -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.Collections.Generic; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class GenericTypeNameRewriterTest + { + [Theory] + [InlineData("TItem2", "Type2")] + + // Unspecified argument -> System.Object + [InlineData("TItem3", "System.Object")] + + // Not a type parameter + [InlineData("TItem4", "TItem4")] + + // In a qualified name, not a type parameter + [InlineData("TItem1.TItem2", "TItem1.TItem2")] + + // Type parameters can't have type parameters + [InlineData("TItem1.TItem2", "TItem1.TItem2")] + [InlineData("TItem2, System.TItem2, RenderFragment>", "TItem2, System.TItem2, RenderFragment>")] + public void GenericTypeNameRewriter_CanReplaceTypeParametersWithTypeArguments(string original, string expected) + { + // Arrange + var visitor = new GenericTypeNameRewriter(new Dictionary() + { + { "TItem1", "Type1" }, + { "TItem2", "Type2" }, + { "TItem3", null }, + }); + + // Act + var actual = visitor.Rewrite(original); + + // Assert + Assert.Equal(expected, actual.ToString()); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/GlobalQualifiedTypeNameRewriterTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/GlobalQualifiedTypeNameRewriterTest.cs new file mode 100644 index 0000000000..26ed2e94b6 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/GlobalQualifiedTypeNameRewriterTest.cs @@ -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 Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class GlobalQualifiedTypeNameRewriterTest + { + [Theory] + [InlineData("String", "global::String")] + [InlineData("System.String", "global::System.String")] + [InlineData("TItem2", "TItem2")] + [InlineData("System.Collections.Generic.List", "global::System.Collections.Generic.List")] + [InlineData("System.Collections.Generic.Dictionary", "global::System.Collections.Generic.Dictionary")] + [InlineData("System.Collections.TItem3.Dictionary", "global::System.Collections.TItem3.Dictionary")] + [InlineData("System.Collections.TItem3.TItem1", "global::System.Collections.TItem3.TItem1")] + + // This case is interesting because we know TITem2 to be a generic type parameter, + // and we know that this will never be valid, which is why we don't bother rewriting. + [InlineData("TItem2", "TItem2")] + public void GlobalQualifiedTypeNameRewriter_CanQualifyNames(string original, string expected) + { + // Arrange + var visitor = new GlobalQualifiedTypeNameRewriter(new[] { "TItem1", "TItem2", "TItem3" }); + + // Act + var actual = visitor.Rewrite(original); + + // Assert + Assert.Equal(expected, actual.ToString()); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..3018afea55 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs @@ -0,0 +1,90 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class KeyTagHelperDescriptorProviderTest : TagHelperDescriptorProviderTestBase + { + [Fact] + public void Execute_CreatesDescriptor() + { + // Arrange + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(BaseCompilation); + + var provider = new KeyTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = context.Results.Where(result => result.IsKeyTagHelper()); + var item = Assert.Single(matches); + + Assert.Empty(item.AllowedChildTags); + Assert.Null(item.TagOutputHint); + Assert.Empty(item.Diagnostics); + Assert.False(item.HasErrors); + Assert.Equal(ComponentMetadata.Key.TagHelperKind, item.Kind); + Assert.Equal(bool.TrueString, item.Metadata[TagHelperMetadata.Common.ClassifyAttributesOnly]); + Assert.Equal(ComponentMetadata.Key.RuntimeName, item.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(item.IsDefaultKind()); + Assert.False(item.KindUsesDefaultTagHelperRuntime()); + Assert.False(item.IsComponentOrChildContentTagHelper()); + Assert.True(item.CaseSensitive); + + Assert.Equal( + "Ensures that the component or element will be preserved across renders if (and only if) the supplied key value matches.", + item.Documentation); + + Assert.Equal("Microsoft.AspNetCore.Components", item.AssemblyName); + Assert.Equal("Key", item.Name); + Assert.Equal("Microsoft.AspNetCore.Components.Key", item.DisplayName); + Assert.Equal("Microsoft.AspNetCore.Components.Key", item.GetTypeName()); + + // The tag matching rule for a key is just the attribute name "key" + var rule = Assert.Single(item.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("*", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@key", requiredAttribute.DisplayName); + Assert.Equal("@key", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(item.BoundAttributes); + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Key.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Ensures that the component or element will be preserved across renders if (and only if) the supplied key value matches.", + attribute.Documentation); + + Assert.Equal("@key", attribute.Name); + Assert.Equal("Key", attribute.GetPropertyName()); + Assert.Equal("object Microsoft.AspNetCore.Components.Key.Key", attribute.DisplayName); + Assert.Equal("System.Object", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj b/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj new file mode 100644 index 0000000000..44fb5d161b --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/Microsoft.CodeAnalysis.Razor.Test.csproj @@ -0,0 +1,29 @@ + + + + $(StandardTestTfms) + $(DefaultItemExcludes);TestFiles\**\* + true + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs new file mode 100644 index 0000000000..fd31ccc33d --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RazorProjectEngineBuilderExtensionsTest.cs @@ -0,0 +1,31 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Xunit; +using static Microsoft.CodeAnalysis.Razor.RazorProjectEngineBuilderExtensions; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class RazorProjectEngineBuilderExtensionsTest + { + [Fact] + public void SetCSharpLanguageVersion_ResolvesNonNumericCSharpLangVersions() + { + // Arrange + var csharpLanguageVersion = CSharp.LanguageVersion.Latest; + + // Act + var projectEngine = RazorProjectEngine.Create(builder => + { + builder.SetCSharpLanguageVersion(csharpLanguageVersion); + }); + + // Assert + var feature = projectEngine.EngineFeatures.OfType().FirstOrDefault(); + Assert.NotNull(feature); + Assert.NotEqual(csharpLanguageVersion, feature.CSharpLanguageVersion); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..140520153e --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs @@ -0,0 +1,90 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class RefTagHelperDescriptorProviderTest : TagHelperDescriptorProviderTestBase + { + [Fact] + public void Execute_CreatesDescriptor() + { + // Arrange + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(BaseCompilation); + + var provider = new RefTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = context.Results.Where(result => result.IsRefTagHelper()); + var item = Assert.Single(matches); + + Assert.Empty(item.AllowedChildTags); + Assert.Null(item.TagOutputHint); + Assert.Empty(item.Diagnostics); + Assert.False(item.HasErrors); + Assert.Equal(ComponentMetadata.Ref.TagHelperKind, item.Kind); + Assert.Equal(bool.TrueString, item.Metadata[TagHelperMetadata.Common.ClassifyAttributesOnly]); + Assert.Equal(ComponentMetadata.Ref.RuntimeName, item.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(item.IsDefaultKind()); + Assert.False(item.KindUsesDefaultTagHelperRuntime()); + Assert.False(item.IsComponentOrChildContentTagHelper()); + Assert.True(item.CaseSensitive); + + Assert.Equal( + "Populates the specified field or property with a reference to the element or component.", + item.Documentation); + + Assert.Equal("Microsoft.AspNetCore.Components", item.AssemblyName); + Assert.Equal("Ref", item.Name); + Assert.Equal("Microsoft.AspNetCore.Components.Ref", item.DisplayName); + Assert.Equal("Microsoft.AspNetCore.Components.Ref", item.GetTypeName()); + + // The tag matching rule for a ref is just the attribute name "ref" + var rule = Assert.Single(item.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("*", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@ref", requiredAttribute.DisplayName); + Assert.Equal("@ref", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(item.BoundAttributes); + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Ref.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Populates the specified field or property with a reference to the element or component.", + attribute.Documentation); + + Assert.Equal("@ref", attribute.Name); + Assert.Equal("Ref", attribute.GetPropertyName()); + Assert.Equal("object Microsoft.AspNetCore.Components.Ref.Ref", attribute.DisplayName); + Assert.Equal("System.Object", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs new file mode 100644 index 0000000000..7832da05ac --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs @@ -0,0 +1,88 @@ +// 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.Linq; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.Components; +using Xunit; + +namespace Microsoft.CodeAnalysis.Razor +{ + public class SplatTagHelperDescriptorProviderTest : TagHelperDescriptorProviderTestBase + { + [Fact] + public void Execute_CreatesDescriptor() + { + // Arrange + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(BaseCompilation); + + var provider = new SplatTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var matches = context.Results.Where(result => result.IsSplatTagHelper()); + var item = Assert.Single(matches); + + Assert.Empty(item.AllowedChildTags); + Assert.Null(item.TagOutputHint); + Assert.Empty(item.Diagnostics); + Assert.False(item.HasErrors); + Assert.Equal(ComponentMetadata.Splat.TagHelperKind, item.Kind); + Assert.Equal(bool.TrueString, item.Metadata[TagHelperMetadata.Common.ClassifyAttributesOnly]); + Assert.Equal(ComponentMetadata.Splat.RuntimeName, item.Metadata[TagHelperMetadata.Runtime.Name]); + Assert.False(item.IsDefaultKind()); + Assert.False(item.KindUsesDefaultTagHelperRuntime()); + Assert.True(item.CaseSensitive); + + Assert.Equal( + "Merges a collection of attributes into the current element or component.", + item.Documentation); + + Assert.Equal("Microsoft.AspNetCore.Components", item.AssemblyName); + Assert.Equal("Attributes", item.Name); + Assert.Equal("Microsoft.AspNetCore.Components.Attributes", item.DisplayName); + Assert.Equal("Microsoft.AspNetCore.Components.Attributes", item.GetTypeName()); + + var rule = Assert.Single(item.TagMatchingRules); + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("*", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@attributes", requiredAttribute.DisplayName); + Assert.Equal("@attributes", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(item.BoundAttributes); + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Splat.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Merges a collection of attributes into the current element or component.", + attribute.Documentation); + + Assert.Equal("@attributes", attribute.Name); + Assert.Equal("Attributes", attribute.GetPropertyName()); + Assert.Equal("object Microsoft.AspNetCore.Components.Attributes.Attributes", attribute.DisplayName); + Assert.Equal("System.Object", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/TagHelperDescriptorFactoryTagHelpers.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/TagHelperDescriptorFactoryTagHelpers.cs new file mode 100644 index 0000000000..658fca5d94 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/TagHelperDescriptorFactoryTagHelpers.cs @@ -0,0 +1,463 @@ +// 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.ComponentModel; +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Microsoft.CodeAnalysis.Razor.Workspaces.Test +{ + public enum CustomEnum + { + FirstValue, + SecondValue + } + + public class EnumTagHelper : TagHelper + { + public int NonEnumProperty { get; set; } + + public CustomEnum EnumProperty { get; set; } + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("input")] + public class MultiEnumTagHelper : EnumTagHelper + { + } + + public class NestedEnumTagHelper : EnumTagHelper + { + public NestedEnum NestedEnumProperty { get; set; } + + public enum NestedEnum + { + NestedOne, + NestedTwo + } + } + + [HtmlTargetElement("input", ParentTag = "div")] + public class RequiredParentTagHelper : TagHelper + { + } + + [HtmlTargetElement("p", ParentTag = "div")] + [HtmlTargetElement("input", ParentTag = "section")] + public class MultiSpecifiedRequiredParentTagHelper : TagHelper + { + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("input", ParentTag = "div")] + public class MultiWithUnspecifiedRequiredParentTagHelper : TagHelper + { + } + + + [RestrictChildren("p")] + public class RestrictChildrenTagHelper + { + } + + [RestrictChildren("p", "strong")] + public class DoubleRestrictChildrenTagHelper + { + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("div")] + [RestrictChildren("p", "strong")] + public class MultiTargetRestrictChildrenTagHelper + { + } + + [HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)] + public class TagStructureTagHelper : TagHelper + { + } + + [HtmlTargetElement("p", TagStructure = TagStructure.NormalOrSelfClosing)] + [HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)] + public class MultiSpecifiedTagStructureTagHelper : TagHelper + { + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)] + public class MultiWithUnspecifiedTagStructureTagHelper : TagHelper + { + } + + [EditorBrowsable(EditorBrowsableState.Always)] + public class DefaultEditorBrowsableTagHelper : TagHelper + { + [EditorBrowsable(EditorBrowsableState.Always)] + public int Property { get; set; } + } + + public class HiddenPropertyEditorBrowsableTagHelper : TagHelper + { + [EditorBrowsable(EditorBrowsableState.Never)] + public int Property { get; set; } + } + + public class MultiPropertyEditorBrowsableTagHelper : TagHelper + { + [EditorBrowsable(EditorBrowsableState.Never)] + public int Property { get; set; } + + public virtual int Property2 { get; set; } + } + + public class OverriddenPropertyEditorBrowsableTagHelper : MultiPropertyEditorBrowsableTagHelper + { + [EditorBrowsable(EditorBrowsableState.Never)] + public override int Property2 { get; set; } + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public class EditorBrowsableTagHelper : TagHelper + { + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual int Property { get; set; } + } + + public class InheritedEditorBrowsableTagHelper : EditorBrowsableTagHelper + { + public override int Property { get; set; } + } + + [EditorBrowsable(EditorBrowsableState.Advanced)] + public class OverriddenEditorBrowsableTagHelper : EditorBrowsableTagHelper + { + [EditorBrowsable(EditorBrowsableState.Advanced)] + public override int Property { get; set; } + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("div")] + [EditorBrowsable(EditorBrowsableState.Never)] + public class MultiEditorBrowsableTagHelper : TagHelper + { + } + + [HtmlTargetElement(Attributes = "class*")] + public class AttributeWildcardTargetingTagHelper : TagHelper + { + } + + [HtmlTargetElement(Attributes = "class*,style*")] + public class MultiAttributeWildcardTargetingTagHelper : TagHelper + { + } + + [HtmlTargetElement(Attributes = "class")] + public class AttributeTargetingTagHelper : TagHelper + { + } + + [HtmlTargetElement(Attributes = "class,style")] + public class MultiAttributeTargetingTagHelper : TagHelper + { + } + + [HtmlTargetElement(Attributes = "custom")] + [HtmlTargetElement(Attributes = "class,style")] + public class MultiAttributeAttributeTargetingTagHelper : TagHelper + { + } + + [HtmlTargetElement(Attributes = "style")] + public class InheritedAttributeTargetingTagHelper : AttributeTargetingTagHelper + { + } + + [HtmlTargetElement("input", Attributes = "class")] + public class RequiredAttributeTagHelper : TagHelper + { + } + + [HtmlTargetElement("div", Attributes = "class")] + public class InheritedRequiredAttributeTagHelper : RequiredAttributeTagHelper + { + } + + [HtmlTargetElement("div", Attributes = "class")] + [HtmlTargetElement("input", Attributes = "class")] + public class MultiAttributeRequiredAttributeTagHelper : TagHelper + { + } + + [HtmlTargetElement("input", Attributes = "style")] + [HtmlTargetElement("input", Attributes = "class")] + public class MultiAttributeSameTagRequiredAttributeTagHelper : TagHelper + { + } + + [HtmlTargetElement("input", Attributes = "class,style")] + public class MultiRequiredAttributeTagHelper : TagHelper + { + } + + [HtmlTargetElement("div", Attributes = "style")] + public class InheritedMultiRequiredAttributeTagHelper : MultiRequiredAttributeTagHelper + { + } + + [HtmlTargetElement("div", Attributes = "class,style")] + [HtmlTargetElement("input", Attributes = "class,style")] + public class MultiTagMultiRequiredAttributeTagHelper : TagHelper + { + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("div")] + public class MultiTagTagHelper + { + public string ValidAttribute { get; set; } + } + + public class InheritedMultiTagTagHelper : MultiTagTagHelper + { + } + + [HtmlTargetElement("p")] + [HtmlTargetElement("p")] + [HtmlTargetElement("div")] + [HtmlTargetElement("div")] + public class DuplicateTagNameTagHelper + { + } + + [HtmlTargetElement("data-condition")] + public class OverrideNameTagHelper + { + } + + public class InheritedSingleAttributeTagHelper : SingleAttributeTagHelper + { + } + + public class DuplicateAttributeNameTagHelper + { + public string MyNameIsLegion { get; set; } + + [HtmlAttributeName("my-name-is-legion")] + public string Fred { get; set; } + } + + public class NotBoundAttributeTagHelper + { + public object BoundProperty { get; set; } + + [HtmlAttributeNotBound] + public string NotBoundProperty { get; set; } + + [HtmlAttributeName("unused")] + [HtmlAttributeNotBound] + public string NamedNotBoundProperty { get; set; } + } + + public class OverriddenAttributeTagHelper + { + [HtmlAttributeName("SomethingElse")] + public virtual string ValidAttribute1 { get; set; } + + [HtmlAttributeName("Something-Else")] + public string ValidAttribute2 { get; set; } + } + + public class InheritedOverriddenAttributeTagHelper : OverriddenAttributeTagHelper + { + public override string ValidAttribute1 { get; set; } + } + + public class InheritedNotOverriddenAttributeTagHelper : OverriddenAttributeTagHelper + { + } + + public class ALLCAPSTAGHELPER : TagHelper + { + public int ALLCAPSATTRIBUTE { get; set; } + } + + public class CAPSOnOUTSIDETagHelper : TagHelper + { + public int CAPSOnOUTSIDEATTRIBUTE { get; set; } + } + + public class capsONInsideTagHelper : TagHelper + { + public int capsONInsideattribute { get; set; } + } + + public class One1Two2Three3TagHelper : TagHelper + { + public int One1Two2Three3Attribute { get; set; } + } + + public class ONE1TWO2THREE3TagHelper : TagHelper + { + public int ONE1TWO2THREE3Attribute { get; set; } + } + + public class First_Second_ThirdHiTagHelper : TagHelper + { + public int First_Second_ThirdAttribute { get; set; } + } + + public class UNSuffixedCLASS : TagHelper + { + public int UNSuffixedATTRIBUTE { get; set; } + } + + public class InvalidBoundAttribute : TagHelper + { + public string DataSomething { get; set; } + } + + public class InvalidBoundAttributeWithValid : SingleAttributeTagHelper + { + public string DataSomething { get; set; } + } + + public class OverriddenInvalidBoundAttributeWithValid : TagHelper + { + [HtmlAttributeName("valid-something")] + public string DataSomething { get; set; } + } + + public class OverriddenValidBoundAttributeWithInvalid : TagHelper + { + [HtmlAttributeName("data-something")] + public string ValidSomething { get; set; } + } + + public class OverriddenValidBoundAttributeWithInvalidUpperCase : TagHelper + { + [HtmlAttributeName("DATA-SOMETHING")] + public string ValidSomething { get; set; } + } + + public class DefaultValidHtmlAttributePrefix : TagHelper + { + public IDictionary DictionaryProperty { get; set; } + } + + public class SingleValidHtmlAttributePrefix : TagHelper + { + [HtmlAttributeName("valid-name")] + public IDictionary DictionaryProperty { get; set; } + } + + public class MultipleValidHtmlAttributePrefix : TagHelper + { + [HtmlAttributeName("valid-name1", DictionaryAttributePrefix = "valid-prefix1-")] + public Dictionary DictionaryProperty { get; set; } + + [HtmlAttributeName("valid-name2", DictionaryAttributePrefix = "valid-prefix2-")] + public DictionarySubclass DictionarySubclassProperty { get; set; } + + [HtmlAttributeName("valid-name3", DictionaryAttributePrefix = "valid-prefix3-")] + public DictionaryWithoutParameterlessConstructor DictionaryWithoutParameterlessConstructorProperty { get; set; } + + [HtmlAttributeName("valid-name4", DictionaryAttributePrefix = "valid-prefix4-")] + public GenericDictionarySubclass GenericDictionarySubclassProperty { get; set; } + + [HtmlAttributeName("valid-name5", DictionaryAttributePrefix = "valid-prefix5-")] + public SortedDictionary SortedDictionaryProperty { get; set; } + + [HtmlAttributeName("valid-name6")] + public string StringProperty { get; set; } + + public IDictionary GetOnlyDictionaryProperty { get; } + + [HtmlAttributeName(DictionaryAttributePrefix = "valid-prefix6")] + public IDictionary GetOnlyDictionaryPropertyWithAttributePrefix { get; } + } + + public class SingleInvalidHtmlAttributePrefix : TagHelper + { + [HtmlAttributeName("valid-name", DictionaryAttributePrefix = "valid-prefix")] + public string StringProperty { get; set; } + } + + public class MultipleInvalidHtmlAttributePrefix : TagHelper + { + [HtmlAttributeName("valid-name1")] + public long LongProperty { get; set; } + + [HtmlAttributeName("valid-name2", DictionaryAttributePrefix = "valid-prefix2-")] + public Dictionary DictionaryOfIntProperty { get; set; } + + [HtmlAttributeName("valid-name3", DictionaryAttributePrefix = "valid-prefix3-")] + public IReadOnlyDictionary ReadOnlyDictionaryProperty { get; set; } + + [HtmlAttributeName("valid-name4", DictionaryAttributePrefix = "valid-prefix4-")] + public int IntProperty { get; set; } + + [HtmlAttributeName("valid-name5", DictionaryAttributePrefix = "valid-prefix5-")] + public DictionaryOfIntSubclass DictionaryOfIntSubclassProperty { get; set; } + + [HtmlAttributeName(DictionaryAttributePrefix = "valid-prefix6")] + public IDictionary GetOnlyDictionaryAttributePrefix { get; } + + [HtmlAttributeName("invalid-name7")] + public IDictionary GetOnlyDictionaryPropertyWithAttributeName { get; } + } + + public class DictionarySubclass : Dictionary + { + } + + public class DictionaryWithoutParameterlessConstructor : Dictionary + { + public DictionaryWithoutParameterlessConstructor(int count) + : base() + { + } + } + + public class DictionaryOfIntSubclass : Dictionary + { + } + + public class GenericDictionarySubclass : Dictionary + { + } + + [OutputElementHint("strong")] + public class OutputElementHintTagHelper : TagHelper + { + } + + [HtmlTargetElement("a")] + [HtmlTargetElement("p")] + [OutputElementHint("div")] + public class MultipleDescriptorTagHelperWithOutputElementHint : TagHelper + { + } + + public class NonPublicAccessorTagHelper : TagHelper + { + public string ValidAttribute { get; set; } + public string InvalidPrivateSetAttribute { get; private set; } + public string InvalidPrivateGetAttribute { private get; set; } + protected string InvalidProtectedAttribute { get; set; } + internal string InvalidInternalAttribute { get; set; } + protected internal string InvalidProtectedInternalAttribute { get; set; } + } + + public class SingleAttributeTagHelper : TagHelper + { + public int IntAttribute { get; set; } + } + + public class MissingAccessorTagHelper : TagHelper + { + public string ValidAttribute { get; set; } + public string InvalidNoGetAttribute { set { } } + public string InvalidNoSetAttribute { get { return string.Empty; } } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/TagHelperTypeVisitorTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/TagHelperTypeVisitorTest.cs new file mode 100644 index 0000000000..77a85be01a --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/TagHelperTypeVisitorTest.cs @@ -0,0 +1,118 @@ +// 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.TagHelpers; +using System.Collections.Generic; +using Xunit; +using System.Reflection; + +namespace Microsoft.CodeAnalysis.Razor.Workspaces +{ + public class TagHelperTypeVisitorTest + { + private static readonly Assembly _assembly = typeof(TagHelperTypeVisitorTest).GetTypeInfo().Assembly; + + private static Compilation Compilation { get; } = TestCompilation.Create(_assembly); + + private static INamedTypeSymbol ITagHelperSymbol { get; } = Compilation.GetTypeByMetadataName(TagHelperTypes.ITagHelper); + + [Fact] + public void IsTagHelper_PlainTagHelper_ReturnsTrue() + { + // Arrange + var testVisitor = new TagHelperTypeVisitor(ITagHelperSymbol, new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_PlainTagHelper).FullName); + + // Act + var isTagHelper = testVisitor.IsTagHelper(tagHelperSymbol); + + // Assert + Assert.True(isTagHelper); + } + + [Fact] + public void IsTagHelper_InheritedTagHelper_ReturnsTrue() + { + // Arrange + var testVisitor = new TagHelperTypeVisitor(ITagHelperSymbol, new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Valid_InheritedTagHelper).FullName); + + // Act + var isTagHelper = testVisitor.IsTagHelper(tagHelperSymbol); + + // Assert + Assert.True(isTagHelper); + } + + [Fact] + public void IsTagHelper_AbstractTagHelper_ReturnsFalse() + { + // Arrange + var testVisitor = new TagHelperTypeVisitor(ITagHelperSymbol, new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_AbstractTagHelper).FullName); + + // Act + var isTagHelper = testVisitor.IsTagHelper(tagHelperSymbol); + + // Assert + Assert.False(isTagHelper); + } + + [Fact] + public void IsTagHelper_GenericTagHelper_ReturnsFalse() + { + // Arrange + var testVisitor = new TagHelperTypeVisitor(ITagHelperSymbol, new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_GenericTagHelper<>).FullName); + + // Act + var isTagHelper = testVisitor.IsTagHelper(tagHelperSymbol); + + // Assert + Assert.False(isTagHelper); + } + + [Fact] + public void IsTagHelper_InternalTagHelper_ReturnsFalse() + { + // Arrange + var testVisitor = new TagHelperTypeVisitor(ITagHelperSymbol, new List()); + var tagHelperSymbol = Compilation.GetTypeByMetadataName(typeof(Invalid_InternalTagHelper).FullName); + + // Act + var isTagHelper = testVisitor.IsTagHelper(tagHelperSymbol); + + // Assert + Assert.False(isTagHelper); + } + + public class Invalid_NestedPublicTagHelper : TagHelper + { + } + + public class Valid_NestedPublicViewComponent + { + public string Invoke(string foo) => null; + } + } + + public abstract class Invalid_AbstractTagHelper : TagHelper + { + } + + public class Invalid_GenericTagHelper : TagHelper + { + } + + internal class Invalid_InternalTagHelper : TagHelper + { + } + + public class Valid_PlainTagHelper : TagHelper + { + } + + public class Valid_InheritedTagHelper : Valid_PlainTagHelper + { + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/xunit.runner.json b/src/Razor/Microsoft.CodeAnalysis.Razor/test/xunit.runner.json new file mode 100644 index 0000000000..c04bb61fe6 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "methodDisplay": "method", + "shadowCopy": false +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/AssemblyItem.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/AssemblyItem.cs new file mode 100644 index 0000000000..74b3f43d77 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/AssemblyItem.cs @@ -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.Razor.Tasks +{ + public class AssemblyItem + { + public string Path { get; set; } + + public bool IsFrameworkReference { get; set; } + + public string AssemblyName { get; set; } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs new file mode 100644 index 0000000000..9a660fb1bf --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs @@ -0,0 +1,285 @@ +// 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.Diagnostics; +using System.IO; +using System.IO.Pipes; +using System.Threading; +using Microsoft.AspNetCore.Razor.Tools; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public abstract class DotNetToolTask : ToolTask + { + // From https://github.com/dotnet/corefx/blob/29cd6a0b0ac2993cee23ebaf36ca3d4bce6dd75f/src/System.IO.Pipes/ref/System.IO.Pipes.cs#L93. + // Using the enum value directly as this option is not available in netstandard. + private const PipeOptions PipeOptionCurrentUserOnly = (PipeOptions)536870912; + + private CancellationTokenSource _razorServerCts; + + public bool Debug { get; set; } + + public bool DebugTool { get; set; } + + [Required] + public string ToolAssembly { get; set; } + + public bool UseServer { get; set; } + + // Specifies whether we should fallback to in-process execution if server execution fails. + public bool ForceServer { get; set; } + + // Specifies whether server execution is allowed when PipeOptions.CurrentUserOnly is not available. + // For testing purposes only. + public bool SuppressCurrentUserOnlyPipeOptions { get; set; } + + public string PipeName { get; set; } + + protected override string ToolName => "dotnet"; + + // If we're debugging then make all of the stdout gets logged in MSBuild + protected override MessageImportance StandardOutputLoggingImportance => DebugTool ? MessageImportance.High : base.StandardOutputLoggingImportance; + + protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High; + + internal abstract string Command { get; } + + protected override string GenerateFullPathToTool() + { +#if NETSTANDARD2_0 + if (!string.IsNullOrEmpty(DotNetMuxer.MuxerPath)) + { + return DotNetMuxer.MuxerPath; + } +#endif + + // use PATH to find dotnet + return ToolExe; + } + + protected override string GenerateCommandLineCommands() + { + return $"exec \"{ToolAssembly}\"" + (DebugTool ? " --debug" : ""); + } + + protected override string GetResponseFileSwitch(string responseFilePath) + { + return "@\"" + responseFilePath + "\""; + } + + protected abstract override string GenerateResponseFileCommands(); + + public override bool Execute() + { + if (Debug) + { + Log.LogMessage(MessageImportance.High, "Waiting for debugger in pid: {0}", Process.GetCurrentProcess().Id); + while (!Debugger.IsAttached) + { + Thread.Sleep(TimeSpan.FromSeconds(3)); + } + } + + return base.Execute(); + } + + protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) + { + if (UseServer && + TryExecuteOnServer(pathToTool, responseFileCommands, commandLineCommands, out var result)) + { + return result; + } + + return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); + } + + protected override void LogToolCommand(string message) + { + if (Debug) + { + Log.LogMessage(MessageImportance.High, message); + } + else + { + base.LogToolCommand(message); + } + } + + public override void Cancel() + { + base.Cancel(); + + _razorServerCts?.Cancel(); + } + + protected virtual bool TryExecuteOnServer( + string pathToTool, + string responseFileCommands, + string commandLineCommands, + out int result) + { +#if !NETFRAMEWORK + if (!SuppressCurrentUserOnlyPipeOptions && !Enum.IsDefined(typeof(PipeOptions), PipeOptionCurrentUserOnly)) + { + // For security reasons, we don't want to spin up a server that doesn't + // restrict requests only to the current user. + result = -1; + + return ForceServer; + } +#endif + + Log.LogMessage(StandardOutputLoggingImportance, "Server execution started."); + using (_razorServerCts = new CancellationTokenSource()) + { + Log.LogMessage(StandardOutputLoggingImportance, $"CommandLine = '{commandLineCommands}'"); + Log.LogMessage(StandardOutputLoggingImportance, $"ServerResponseFile = '{responseFileCommands}'"); + + // The server contains the tools for discovering tag helpers and generating Razor code. + var clientDir = Path.GetFullPath(Path.GetDirectoryName(ToolAssembly)); + var workingDir = CurrentDirectoryToUse(); + var tempDir = ServerConnection.GetTempPath(workingDir); + var serverPaths = new ServerPaths( + clientDir, + workingDir: workingDir, + tempDir: tempDir); + + var arguments = GetArguments(responseFileCommands); + + var responseTask = ServerConnection.RunOnServer(PipeName, arguments, serverPaths, _razorServerCts.Token, debug: DebugTool); + responseTask.Wait(_razorServerCts.Token); + + var response = responseTask.Result; + if (response.Type == ServerResponse.ResponseType.Completed && + response is CompletedServerResponse completedResponse) + { + result = completedResponse.ReturnCode; + + if (result == 0) + { + // Server execution succeeded. + Log.LogMessage(StandardOutputLoggingImportance, $"Server execution completed with return code {result}."); + + // There might still be warnings in the error output. + if (LogStandardErrorAsError) + { + LogErrors(completedResponse.ErrorOutput); + } + else + { + LogMessages(completedResponse.ErrorOutput, StandardErrorLoggingImportance); + } + + return true; + } + else if (result == 2) + { + // Server execution completed with a legit error. No need to fallback to cli execution. + Log.LogMessage(StandardOutputLoggingImportance, $"Server execution completed with return code {result}. For more info, check the server log file in the location specified by the RAZORBUILDSERVER_LOG environment variable."); + + if (LogStandardErrorAsError) + { + LogErrors(completedResponse.ErrorOutput); + } + else + { + LogMessages(completedResponse.ErrorOutput, StandardErrorLoggingImportance); + } + + return true; + } + else + { + // Server execution completed with an error but we still want to fallback to cli execution. + Log.LogMessage(StandardOutputLoggingImportance, $"Server execution completed with return code {result}. For more info, check the server log file in the location specified by the RAZORBUILDSERVER_LOG environment variable."); + } + } + else + { + // Server execution failed. Fallback to cli execution. + Log.LogMessage( + StandardOutputLoggingImportance, + $"Server execution failed with response {response.Type}. For more info, check the server log file in the location specified by the RAZORBUILDSERVER_LOG environment variable."); + + result = -1; + } + + if (ForceServer) + { + // We don't want to fallback to in-process execution. + return true; + } + + Log.LogMessage(StandardOutputLoggingImportance, "Fallback to in-process execution."); + } + + return false; + } + + private void LogMessages(string output, MessageImportance messageImportance) + { + var lines = output.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + foreach (var line in lines) + { + if (!string.IsNullOrWhiteSpace(line)) + { + var trimmedMessage = line.Trim(); + Log.LogMessageFromText(trimmedMessage, messageImportance); + } + } + } + + private void LogErrors(string output) + { + var lines = output.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + foreach (var line in lines) + { + if (!string.IsNullOrWhiteSpace(line)) + { + var trimmedMessage = line.Trim(); + Log.LogError(trimmedMessage); + } + } + } + + /// + /// Get the current directory that the compiler should run in. + /// + private string CurrentDirectoryToUse() + { + // ToolTask has a method for this. But it may return null. Use the process directory + // if ToolTask didn't override. MSBuild uses the process directory. + var workingDirectory = GetWorkingDirectory(); + if (string.IsNullOrEmpty(workingDirectory)) + { + workingDirectory = Directory.GetCurrentDirectory(); + } + return workingDirectory; + } + + private IList GetArguments(string responseFileCommands) + { + var list = responseFileCommands.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + return list; + } + + protected override bool HandleTaskExecutionErrors() + { + if (!HasLoggedErrors) + { + var toolCommand = Path.GetFileNameWithoutExtension(ToolAssembly) + " " + Command; + // Show a slightly better error than the standard ToolTask message that says "dotnet" failed. + Log.LogError($"{toolCommand} exited with code {ExitCode}."); + return false; + } + + return base.HandleTaskExecutionErrors(); + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/FindAssembliesWithReferencesTo.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/FindAssembliesWithReferencesTo.cs new file mode 100644 index 0000000000..cb1d2359e8 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/FindAssembliesWithReferencesTo.cs @@ -0,0 +1,69 @@ +// 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 System.Reflection; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class FindAssembliesWithReferencesTo : Task + { + [Required] + public ITaskItem[] TargetAssemblyNames { get; set; } + + [Required] + public ITaskItem[] Assemblies { get; set; } + + [Output] + public string[] ResolvedAssemblies { get; set; } + + public override bool Execute() + { + var referenceItems = new List(); + foreach (var item in Assemblies) + { + const string FusionNameKey = "FusionName"; + var fusionName = item.GetMetadata(FusionNameKey); + if (string.IsNullOrEmpty(fusionName)) + { + Log.LogError($"Missing required metadata '{FusionNameKey}' for '{item.ItemSpec}."); + return false; + } + + var assemblyName = new AssemblyName(fusionName).Name; + referenceItems.Add(new AssemblyItem + { + AssemblyName = assemblyName, + IsFrameworkReference = item.GetMetadata("IsFrameworkReference") == "true", + Path = item.ItemSpec, + }); + } + + var targetAssemblyNames = TargetAssemblyNames.Select(s => s.ItemSpec).ToList(); + + var provider = new ReferenceResolver(targetAssemblyNames, referenceItems); + try + { + var assemblyNames = provider.ResolveAssemblies(); + ResolvedAssemblies = assemblyNames.ToArray(); + } + catch (ReferenceAssemblyNotFoundException ex) + { + // Print a warning and return. We cannot produce a correct document at this point. + var warning = "Reference assembly {0} could not be found. This is typically caused by build errors in referenced projects."; + Log.LogWarning(null, "RAZORSDK1007", null, null, 0, 0, 0, 0, warning, ex.FileName); + return true; + } + catch (Exception ex) + { + Log.LogErrorFromException(ex); + } + + return !Log.HasLoggedErrors; + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/GenerateStaticWebAssetsManifest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/GenerateStaticWebAssetsManifest.cs new file mode 100644 index 0000000000..b8d5d717df --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/GenerateStaticWebAssetsManifest.cs @@ -0,0 +1,206 @@ +// 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 System.Xml; +using System.Xml.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class GenerateStaticWebAssetsManifest : Task + { + private const string ContentRoot = "ContentRoot"; + private const string BasePath = "BasePath"; + private const string SourceId = "SourceId"; + + [Required] + public string TargetManifestPath { get; set; } + + [Required] + public ITaskItem[] ContentRootDefinitions { get; set; } + + public override bool Execute() + { + if (!ValidateArguments()) + { + return false; + } + + return ExecuteCore(); + } + + private bool ExecuteCore() + { + var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); + var root = new XElement( + "StaticWebAssets", + new XAttribute("Version", "1.0"), + CreateNodes()); + + document.Add(root); + + var settings = new XmlWriterSettings + { + Encoding = Encoding.UTF8, + CloseOutput = true, + OmitXmlDeclaration = true, + Indent = true, + NewLineOnAttributes = false, + Async = true + }; + + using (var xmlWriter = GetXmlWriter(settings)) + { + document.WriteTo(xmlWriter); + } + + return !Log.HasLoggedErrors; + } + + private IEnumerable CreateNodes() + { + var nodes = new List(); + for (var i = 0; i < ContentRootDefinitions.Length; i++) + { + var contentRootDefinition = ContentRootDefinitions[i]; + var basePath = contentRootDefinition.GetMetadata(BasePath); + var contentRoot = contentRootDefinition.GetMetadata(ContentRoot); + + // basePath is meant to be a prefix for the files under contentRoot. MSbuild + // normalizes '\' according to the OS, but this is going to be part of the url + // so it needs to always be '/'. + var normalizedBasePath = basePath.Replace("\\", "/"); + + // contentRoot can have forward and trailing slashes and sometimes consecutive directory + // separators. To be more flexible we will normalize the content root so that it contains a + // single trailing separator. + var normalizedContentRoot = $"{contentRoot.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)}{Path.DirectorySeparatorChar}"; + + // At this point we already know that there are no elements with different base paths and same content roots + // or viceversa. Here we simply skip additional items that have the same base path and same content root. + if (!nodes.Exists(e => e.Attribute("BasePath").Value.Equals(normalizedBasePath, StringComparison.OrdinalIgnoreCase) && + e.Attribute("Path").Value.Equals(normalizedContentRoot, StringComparison.OrdinalIgnoreCase))) + { + nodes.Add(new XElement("ContentRoot", + new XAttribute("BasePath", normalizedBasePath), + new XAttribute("Path", normalizedContentRoot))); + } + } + + // Its important that we order the nodes here to produce a manifest deterministically. + return nodes.OrderBy(e=>e.Attribute(BasePath).Value); + } + + private XmlWriter GetXmlWriter(XmlWriterSettings settings) + { + var fileStream = new FileStream(TargetManifestPath, FileMode.Create); + return XmlWriter.Create(fileStream, settings); + } + + private bool ValidateArguments() + { + for (var i = 0; i < ContentRootDefinitions.Length; i++) + { + var contentRootDefinition = ContentRootDefinitions[i]; + if (!EnsureRequiredMetadata(contentRootDefinition, BasePath) || + !EnsureRequiredMetadata(contentRootDefinition, ContentRoot) || + !EnsureRequiredMetadata(contentRootDefinition, SourceId)) + { + return false; + } + } + + // We want to validate that there are no different item groups that share either the same base path + // but different content roots or that share the same content root but different base paths. + // We pass in all the static web assets that we discovered to this task without making any distinction for + // duplicates, so here we skip elements for which we are already tracking an element with the same + // content root path and same base path. + + // Case-sensitivity depends on the underlying OS so we are not going to do anything to enforce it here. + // Any two items that match base path and content root in a case-insensitive way won't produce an error. + // Any other two items will produce an error even if there is only a casing difference between either the + // base paths or the content roots. + var basePaths = new Dictionary(StringComparer.OrdinalIgnoreCase); + var contentRootPaths = new Dictionary(StringComparer.OrdinalIgnoreCase); + + for (var i = 0; i < ContentRootDefinitions.Length; i++) + { + var contentRootDefinition = ContentRootDefinitions[i]; + var basePath = contentRootDefinition.GetMetadata(BasePath); + var contentRoot = contentRootDefinition.GetMetadata(ContentRoot); + var sourceId = contentRootDefinition.GetMetadata(SourceId); + + if (basePaths.TryGetValue(basePath, out var existingBasePath)) + { + var existingBasePathContentRoot = existingBasePath.GetMetadata(ContentRoot); + var existingSourceId = existingBasePath.GetMetadata(SourceId); + if (!string.Equals(contentRoot, existingBasePathContentRoot, StringComparison.OrdinalIgnoreCase) && + // We want to check this case to allow for client-side blazor projects to have multiple different content + // root sources exposed under the same base path while still requiring unique base paths/content roots across + // project/package boundaries. + !string.Equals(sourceId, existingSourceId, StringComparison.OrdinalIgnoreCase)) + { + // Case: + // Item2: /_content/Library, project:/project/aspnetContent2 + // Item1: /_content/Library, package:/package/aspnetContent1 + Log.LogError($"Duplicate base paths '{basePath}' for content root paths '{contentRoot}' and '{existingBasePathContentRoot}'. " + + $"('{contentRootDefinition.ItemSpec}', '{existingBasePath.ItemSpec}')"); + return false; + } + + // It was a duplicate, so we skip it. + // Case: + // Item1: /_content/Library, project:/project/aspnetContent + // Item2: /_content/Library, project:/project/aspnetContent + + // It was a separate content root exposed from the same project/package, so we skip it. + // Case: + // Item1: /_content/Library, project:/project/aspnetContent/bin/debug/netstandard2.1/dist + // Item2: /_content/Library, project:/project/wwwroot + } + else + { + if (contentRootPaths.TryGetValue(contentRoot, out var existingContentRoot)) + { + // Case: + // Item1: /_content/Library1, /package/aspnetContent + // Item2: /_content/Library2, /package/aspnetContent + Log.LogError($"Duplicate content root paths '{contentRoot}' for base paths '{basePath}' and '{existingContentRoot.GetMetadata(BasePath)}' " + + $"('{contentRootDefinition.ItemSpec}', '{existingContentRoot.ItemSpec}')"); + return false; + } + } + + if (!basePaths.ContainsKey(basePath)) + { + basePaths.Add(basePath, contentRootDefinition); + } + + if (!contentRootPaths.ContainsKey(contentRoot)) + { + contentRootPaths.Add(contentRoot, contentRootDefinition); + } + } + + return true; + } + + private bool EnsureRequiredMetadata(ITaskItem item, string metadataName) + { + var value = item.GetMetadata(metadataName); + if (string.IsNullOrEmpty(value)) + { + Log.LogError($"Missing required metadata '{metadataName}' for '{item.ItemSpec}'."); + return false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/GenerateStaticWebAsssetsPropsFile.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/GenerateStaticWebAsssetsPropsFile.cs new file mode 100644 index 0000000000..4146eed9fa --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/GenerateStaticWebAsssetsPropsFile.cs @@ -0,0 +1,159 @@ +// 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.Text; +using System.Xml; +using System.Xml.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class GenerateStaticWebAsssetsPropsFile : Task + { + private const string SourceType = "SourceType"; + private const string SourceId = "SourceId"; + private const string ContentRoot = "ContentRoot"; + private const string BasePath = "BasePath"; + private const string RelativePath = "RelativePath"; + + [Required] + public string TargetPropsFilePath { get; set; } + + [Required] + public ITaskItem[] StaticWebAssets { get; set; } + + public override bool Execute() + { + if (!ValidateArguments()) + { + return false; + } + + return ExecuteCore(); + } + + private bool ExecuteCore() + { + if (StaticWebAssets.Length == 0) + { + return !Log.HasLoggedErrors; + } + + var template = StaticWebAssets[0]; + + var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); + var root = new XElement( + "Project", + new XElement("ItemGroup", + new XElement("StaticWebAsset", + new XAttribute("Include", @"$(MSBuildThisFileDirectory)..\staticwebassets\**"), + new XElement(SourceType, "Package"), + new XElement(SourceId, template.GetMetadata(SourceId)), + new XElement(ContentRoot, @"$(MSBuildThisFileDirectory)..\staticwebassets\"), + new XElement(BasePath, template.GetMetadata(BasePath)), + new XElement(RelativePath, "%(RecursiveDir)%(FileName)%(Extension)")))); + + document.Add(root); + + var settings = new XmlWriterSettings + { + Encoding = Encoding.UTF8, + CloseOutput = true, + OmitXmlDeclaration = true, + Indent = true, + NewLineOnAttributes = false, + Async = true + }; + + using (var xmlWriter = GetXmlWriter(settings)) + { + document.WriteTo(xmlWriter); + } + + return !Log.HasLoggedErrors; + } + + private XmlWriter GetXmlWriter(XmlWriterSettings settings) + { + var fileStream = new FileStream(TargetPropsFilePath, FileMode.Create); + return XmlWriter.Create(fileStream, settings); + } + + private bool ValidateArguments() + { + ITaskItem firstAsset = null; + + for (var i = 0; i < StaticWebAssets.Length; i++) + { + var webAsset = StaticWebAssets[i]; + if (!EnsureRequiredMetadata(webAsset, SourceId) || + !EnsureRequiredMetadata(webAsset, SourceType, allowEmpty: true) || + !EnsureRequiredMetadata(webAsset, ContentRoot) || + !EnsureRequiredMetadata(webAsset, BasePath) || + !EnsureRequiredMetadata(webAsset, RelativePath)) + { + return false; + } + + if (firstAsset == null) + { + firstAsset = webAsset; + continue; + } + + if (!ValidateMetadataMatches(firstAsset, webAsset, SourceId) || + !ValidateMetadataMatches(firstAsset, webAsset, SourceType) || + !ValidateMetadataMatches(firstAsset, webAsset, ContentRoot) || + !ValidateMetadataMatches(firstAsset, webAsset, BasePath)) + { + return false; + } + } + + return true; + } + + private bool ValidateMetadataMatches(ITaskItem reference, ITaskItem candidate, string metadata) + { + var referenceMetadata = reference.GetMetadata(metadata); + var candidateMetadata = candidate.GetMetadata(metadata); + if (!string.Equals(referenceMetadata, candidateMetadata, System.StringComparison.Ordinal)) + { + Log.LogError($"Static web assets have different '{metadata}' metadata values '{referenceMetadata}' and '{candidateMetadata}' for '{reference.ItemSpec}' and '{candidate.ItemSpec}'."); + return false; + } + + return true; + } + + private bool EnsureRequiredMetadata(ITaskItem item, string metadataName, bool allowEmpty = false) + { + var value = item.GetMetadata(metadataName); + var isInvalidValue = allowEmpty ? !HasMetadata(item, metadataName) : string.IsNullOrEmpty(value); + + if (isInvalidValue) + { + Log.LogError($"Missing required metadata '{metadataName}' for '{item.ItemSpec}'."); + return false; + } + + return true; + } + + private bool HasMetadata(ITaskItem item, string metadataName) + { + foreach (var name in item.MetadataNames) + { + if (string.Equals(metadataName, (string)name, StringComparison.Ordinal)) + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/Microsoft.NET.Sdk.Razor.csproj b/src/Razor/Microsoft.NET.Sdk.Razor/src/Microsoft.NET.Sdk.Razor.csproj new file mode 100644 index 0000000000..ba32df8e28 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/Microsoft.NET.Sdk.Razor.csproj @@ -0,0 +1,82 @@ + + + Razor is a markup syntax for adding server-side logic to web pages. This package contains MSBuild support for Razor. + $(DefaultNetCoreTargetFramework);net46 + + Microsoft.NET.Sdk.Razor.Tasks + $(MSBuildProjectName).nuspec + true + $(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\ + + + + $(NoWarn);NU5100 + + $(NoWarn);NU5129 + + + + + + + + + + + + + + + Shared\ServerProtocol\%(FileName) + + + Shared\PipeName.cs + + + Shared\MutexName.cs + + + Shared\Client.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(PackageTags.Replace(';',' ')) + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/Microsoft.NET.Sdk.Razor.nuspec b/src/Razor/Microsoft.NET.Sdk.Razor/src/Microsoft.NET.Sdk.Razor.nuspec new file mode 100644 index 0000000000..b76f30e32b --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/Microsoft.NET.Sdk.Razor.nuspec @@ -0,0 +1,19 @@ + + + + $CommonMetadataElements$ + + + + + + + $CommonFileElements$ + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/RazorGenerate.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/RazorGenerate.cs new file mode 100644 index 0000000000..bee0df6816 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/RazorGenerate.cs @@ -0,0 +1,187 @@ +// 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.Text; +using Microsoft.Build.Framework; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class RazorGenerate : DotNetToolTask + { + private static readonly string[] SourceRequiredMetadata = new string[] + { + FullPath, + GeneratedOutput, + TargetPath, + }; + + private const string GeneratedOutput = "GeneratedOutput"; + private const string DocumentKind = "DocumentKind"; + private const string TargetPath = "TargetPath"; + private const string FullPath = "FullPath"; + private const string Identity = "Identity"; + private const string AssemblyName = "AssemblyName"; + private const string AssemblyFilePath = "AssemblyFilePath"; + + public string RootNamespace { get; set; } + + public string CSharpLanguageVersion { get; set; } + + [Required] + public string Version { get; set; } + + [Required] + public ITaskItem[] Configuration { get; set; } + + [Required] + public ITaskItem[] Extensions { get; set; } + + [Required] + public ITaskItem[] Sources { get; set; } + + [Required] + public string ProjectRoot { get; set; } + + [Required] + public string TagHelperManifest { get; set; } + + public bool GenerateDeclaration { get; set; } + + internal override string Command => "generate"; + + protected override bool ValidateParameters() + { + if (!Directory.Exists(ProjectRoot)) + { + Log.LogError("The specified project root directory {0} doesn't exist.", ProjectRoot); + return false; + } + + if (Configuration.Length == 0) + { + Log.LogError("The project {0} must provide a value for {1}.", ProjectRoot, nameof(Configuration)); + return false; + } + + for (var i = 0; i < Sources.Length; i++) + { + if (!EnsureRequiredMetadata(Sources[i], FullPath) || + !EnsureRequiredMetadata(Sources[i], GeneratedOutput) || + !EnsureRequiredMetadata(Sources[i], TargetPath)) + { + Log.LogError("The Razor source item '{0}' is missing a required metadata entry. Required metadata are: '{1}'", Sources[i], SourceRequiredMetadata); + return false; + } + } + + for (var i = 0; i < Extensions.Length; i++) + { + if (!EnsureRequiredMetadata(Extensions[i], Identity) || + !EnsureRequiredMetadata(Extensions[i], AssemblyName) || + !EnsureRequiredMetadata(Extensions[i], AssemblyFilePath)) + { + return false; + } + } + + return base.ValidateParameters(); + } + + protected override string GenerateResponseFileCommands() + { + var builder = new StringBuilder(); + + builder.AppendLine(Command); + + // We might be talking to a downlevel version of the command line tool, which doesn't + // understand certain parameters. Assume 2.1 if we can't parse the version because 2.1 + // 2.2 are the releases that have command line tool delivered by a package. + if (!System.Version.TryParse(Version, out var parsedVersion)) + { + parsedVersion = new System.Version(2, 1); + } + + for (var i = 0; i < Sources.Length; i++) + { + var input = Sources[i]; + builder.AppendLine("-s"); + builder.AppendLine(input.GetMetadata(FullPath)); + + builder.AppendLine("-r"); + builder.AppendLine(input.GetMetadata(TargetPath)); + + builder.AppendLine("-o"); + var outputPath = Path.Combine(ProjectRoot, input.GetMetadata(GeneratedOutput)); + builder.AppendLine(outputPath); + + // Added in 3.0 + if (parsedVersion.Major >= 3) + { + var kind = input.GetMetadata(DocumentKind); + if (!string.IsNullOrEmpty(kind)) + { + builder.AppendLine("-k"); + builder.AppendLine(kind); + } + } + } + + builder.AppendLine("-p"); + builder.AppendLine(ProjectRoot); + + builder.AppendLine("-t"); + builder.AppendLine(TagHelperManifest); + + builder.AppendLine("-v"); + builder.AppendLine(Version); + + builder.AppendLine("-c"); + builder.AppendLine(Configuration[0].GetMetadata(Identity)); + + // Added in 3.0 + if (parsedVersion.Major >= 3) + { + if (!string.IsNullOrEmpty(RootNamespace)) + { + builder.AppendLine("--root-namespace"); + builder.AppendLine(RootNamespace); + } + + if (!string.IsNullOrEmpty(CSharpLanguageVersion)) + { + builder.AppendLine("--csharp-language-version"); + builder.AppendLine(CSharpLanguageVersion); + } + + if (GenerateDeclaration) + { + builder.AppendLine("--generate-declaration"); + } + } + + for (var i = 0; i < Extensions.Length; i++) + { + builder.AppendLine("-n"); + builder.AppendLine(Extensions[i].GetMetadata(Identity)); + + builder.AppendLine("-e"); + builder.AppendLine(Path.GetFullPath(Extensions[i].GetMetadata(AssemblyFilePath))); + } + + return builder.ToString(); + } + + private bool EnsureRequiredMetadata(ITaskItem item, string metadataName) + { + var value = item.GetMetadata(metadataName); + if (string.IsNullOrEmpty(value)) + { + Log.LogError($"Missing required metadata '{metadataName}' for '{item.ItemSpec}."); + return false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/RazorTagHelper.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/RazorTagHelper.cs new file mode 100644 index 0000000000..9d764761b1 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/RazorTagHelper.cs @@ -0,0 +1,133 @@ +// 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.Text; +using Microsoft.Build.Framework; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class RazorTagHelper : DotNetToolTask + { + private const string Identity = "Identity"; + private const string AssemblyName = "AssemblyName"; + private const string AssemblyFilePath = "AssemblyFilePath"; + + [Required] + public string Version { get; set; } + + [Required] + public ITaskItem[] Configuration { get; set; } + + [Required] + public ITaskItem[] Extensions { get; set; } + + [Required] + public string[] Assemblies { get; set; } + + [Output] + [Required] + public string TagHelperManifest { get; set; } + + public string ProjectRoot { get; set; } + + internal override string Command => "discover"; + + protected override bool SkipTaskExecution() + { + if (Assemblies.Length == 0) + { + // If for some reason there are no assemblies, we have nothing to do. Let's just + // skip running the tool. + File.WriteAllText(TagHelperManifest, "{ }"); + return true; + } + + return false; + } + + protected override bool ValidateParameters() + { + if (!Directory.Exists(ProjectRoot)) + { + Log.LogError("The specified project root directory {0} doesn't exist.", ProjectRoot); + return false; + } + + if (Configuration.Length == 0) + { + Log.LogError("The project {0} must provide a value for {1}.", ProjectRoot, nameof(Configuration)); + return false; + } + + for (var i = 0; i < Assemblies.Length; i++) + { + if (!Path.IsPathRooted(Assemblies[i])) + { + Log.LogError("The assembly path {0} is invalid. Assembly paths must be rooted.", Assemblies[i]); + return false; + } + } + + for (var i = 0; i < Extensions.Length; i++) + { + if (!EnsureRequiredMetadata(Extensions[i], Identity) || + !EnsureRequiredMetadata(Extensions[i], AssemblyName) || + !EnsureRequiredMetadata(Extensions[i], AssemblyFilePath)) + { + return false; + } + } + + return base.ValidateParameters(); + } + + protected override string GenerateResponseFileCommands() + { + var builder = new StringBuilder(); + + builder.AppendLine(Command); + + for (var i = 0; i < Assemblies.Length; i++) + { + builder.AppendLine(Assemblies[i]); + } + + builder.AppendLine("-o"); + builder.AppendLine(TagHelperManifest); + + builder.AppendLine("-p"); + builder.AppendLine(ProjectRoot); + + builder.AppendLine("-v"); + builder.AppendLine(Version); + + builder.AppendLine("-c"); + builder.AppendLine(Configuration[0].GetMetadata(Identity)); + + for (var i = 0; i < Extensions.Length; i++) + { + builder.AppendLine("-n"); + builder.AppendLine(Extensions[i].GetMetadata(Identity)); + + builder.AppendLine("-e"); + builder.AppendLine(Path.GetFullPath(Extensions[i].GetMetadata(AssemblyFilePath))); + } + + return builder.ToString(); + } + + private bool EnsureRequiredMetadata(ITaskItem item, string metadataName) + { + var value = item.GetMetadata(metadataName); + if (string.IsNullOrEmpty(value)) + { + Log.LogError($"Missing required metadata '{metadataName}' for '{item.ItemSpec}."); + return false; + } + + return true; + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/ReferenceAssemblyNotFoundException.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/ReferenceAssemblyNotFoundException.cs new file mode 100644 index 0000000000..8ff573eef3 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/ReferenceAssemblyNotFoundException.cs @@ -0,0 +1,17 @@ +// 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.Razor.Tasks +{ + internal class ReferenceAssemblyNotFoundException : Exception + { + public ReferenceAssemblyNotFoundException(string fileName) + { + FileName = fileName; + } + + public string FileName { get; } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/ReferenceResolver.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/ReferenceResolver.cs new file mode 100644 index 0000000000..6b1489cab0 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/ReferenceResolver.cs @@ -0,0 +1,162 @@ +// 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.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + /// + /// Resolves assemblies that reference one of the specified "targetAssemblies" either directly or transitively. + /// + public class ReferenceResolver + { + private readonly HashSet _mvcAssemblies; + private readonly IReadOnlyList _assemblyItems; + private readonly Dictionary _classifications; + + public ReferenceResolver(IReadOnlyList targetAssemblies, IReadOnlyList assemblyItems) + { + _mvcAssemblies = new HashSet(targetAssemblies, StringComparer.Ordinal); + _assemblyItems = assemblyItems; + _classifications = new Dictionary(); + + Lookup = new Dictionary(StringComparer.Ordinal); + foreach (var item in assemblyItems) + { + Lookup[item.AssemblyName] = item; + } + } + + protected Dictionary Lookup { get; } + + public IReadOnlyList ResolveAssemblies() + { + var applicationParts = new List(); + + foreach (var item in _assemblyItems) + { + var classification = Resolve(item); + if (classification == Classification.ReferencesMvc) + { + applicationParts.Add(item.AssemblyName); + } + } + + return applicationParts; + } + + private Classification Resolve(AssemblyItem assemblyItem) + { + if (_classifications.TryGetValue(assemblyItem, out var classification)) + { + return classification; + } + + // Initialize the dictionary with a value to short-circuit recursive references. + classification = Classification.Unknown; + _classifications[assemblyItem] = classification; + + if (assemblyItem.Path == null) + { + // We encountered a dependency that isn't part of this assembly's dependency set. We'll see if it happens to be an MVC assembly + // since that's the only useful determination we can make given the assembly name. + classification = _mvcAssemblies.Contains(assemblyItem.AssemblyName) ? + Classification.IsMvc : + Classification.DoesNotReferenceMvc; + } + else if (assemblyItem.IsFrameworkReference) + { + // We do not allow transitive references to MVC via a framework reference to count. + // e.g. depending on Microsoft.AspNetCore.SomeThingNewThatDependsOnMvc would not result in an assembly being treated as + // referencing MVC. + classification = _mvcAssemblies.Contains(assemblyItem.AssemblyName) ? + Classification.IsMvc : + Classification.DoesNotReferenceMvc; + } + else if (_mvcAssemblies.Contains(assemblyItem.AssemblyName)) + { + classification = Classification.IsMvc; + } + else + { + classification = Classification.DoesNotReferenceMvc; + foreach (var reference in GetReferences(assemblyItem.Path)) + { + var referenceClassification = Resolve(reference); + + if (referenceClassification == Classification.IsMvc || referenceClassification == Classification.ReferencesMvc) + { + classification = Classification.ReferencesMvc; + break; + } + } + } + + Debug.Assert(classification != Classification.Unknown); + _classifications[assemblyItem] = classification; + return classification; + } + + protected virtual IReadOnlyList GetReferences(string file) + { + try + { + if (!File.Exists(file)) + { + throw new ReferenceAssemblyNotFoundException(file); + } + + using var peReader = new PEReader(File.OpenRead(file)); + if (!peReader.HasMetadata) + { + return Array.Empty(); // not a managed assembly + } + + var metadataReader = peReader.GetMetadataReader(); + + var references = new List(); + foreach (var handle in metadataReader.AssemblyReferences) + { + var reference = metadataReader.GetAssemblyReference(handle); + var referenceName = metadataReader.GetString(reference.Name); + + if (!Lookup.TryGetValue(referenceName, out var assemblyItem)) + { + // A dependency references an item that isn't referenced by this project. + // We'll construct an item for so that we can calculate the classification based on it's name. + assemblyItem = new AssemblyItem + { + AssemblyName = referenceName, + }; + + Lookup[referenceName] = assemblyItem; + } + + references.Add(assemblyItem); + } + + return references; + } + catch (BadImageFormatException) + { + // not a PE file, or invalid metadata + } + + return Array.Empty(); // not a managed assembly + } + + protected enum Classification + { + Unknown, + DoesNotReferenceMvc, + ReferencesMvc, + IsMvc, + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props b/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props new file mode 100644 index 0000000000..beb01baa38 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props @@ -0,0 +1,53 @@ + + + + + + + + <_WebProjectSystemGlobsPropsDefined>true + + $(DefaultItemExcludes);**\node_modules\**;node_modules\** + $(DefaultItemExcludes);**\jspm_packages\**;jspm_packages\** + $(DefaultItemExcludes);**\bower_components\**;bower_components\** + $(DefaultWebContentItemExcludes);wwwroot\** + + + + + + + + + + + + + + + + + + + + + + + + <_ContentIncludedByDefault Include="@(Content)" /> + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.props b/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.props new file mode 100644 index 0000000000..9102f6c805 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.props @@ -0,0 +1,25 @@ + + + + + <_RazorSdkImportsMicrosoftNetSdk Condition="'$(UsingMicrosoftNETSdk)' != 'true'">true + + + + + + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.props + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.targets new file mode 100644 index 0000000000..20b70fd9ab --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/Sdk/Sdk.targets @@ -0,0 +1,23 @@ + + + + + + + $(MSBuildThisFileDirectory)..\buildMultiTargeting\Sdk.Razor.CurrentVersion.MultiTargeting.targets + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/StaticWebAssetsGeneratePackagePropsFile.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/StaticWebAssetsGeneratePackagePropsFile.cs new file mode 100644 index 0000000000..bf7c78ab35 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/StaticWebAssetsGeneratePackagePropsFile.cs @@ -0,0 +1,54 @@ +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class StaticWebAssetsGeneratePackagePropsFile : Task + { + [Required] + public string PropsFileImport { get; set; } + + [Required] + public string BuildTargetPath { get; set; } + + public override bool Execute() + { + var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); + var root = new XElement( + "Project", + new XElement("Import", + new XAttribute("Project", PropsFileImport))); + + document.Add(root); + + var settings = new XmlWriterSettings + { + Encoding = Encoding.UTF8, + CloseOutput = true, + OmitXmlDeclaration = true, + Indent = true, + NewLineOnAttributes = false, + Async = true + }; + + using (var xmlWriter = GetXmlWriter(settings)) + { + document.WriteTo(xmlWriter); + } + + return !Log.HasLoggedErrors; + } + + private XmlWriter GetXmlWriter(XmlWriterSettings settings) + { + var fileStream = new FileStream(BuildTargetPath, FileMode.Create); + return XmlWriter.Create(fileStream, settings); + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/ValidateStaticWebAssetsUniquePaths.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/ValidateStaticWebAssetsUniquePaths.cs new file mode 100644 index 0000000000..23ec446549 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/ValidateStaticWebAssetsUniquePaths.cs @@ -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.IO; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class ValidateStaticWebAssetsUniquePaths : Task + { + private const string BasePath = "BasePath"; + private const string RelativePath = "RelativePath"; + private const string TargetPath = "TargetPath"; + + [Required] + public ITaskItem[] StaticWebAssets { get; set; } + + [Required] + public ITaskItem[] WebRootFiles { get; set; } + + public override bool Execute() + { + var assetsByWebRootPaths = new Dictionary(StringComparer.OrdinalIgnoreCase); + for (var i = 0; i < StaticWebAssets.Length; i++) + { + var contentRootDefinition = StaticWebAssets[i]; + if (!EnsureRequiredMetadata(contentRootDefinition, BasePath) || + !EnsureRequiredMetadata(contentRootDefinition, RelativePath)) + { + return false; + } + else + { + var webRootPath = GetWebRootPath( + contentRootDefinition.GetMetadata(BasePath), + contentRootDefinition.GetMetadata(RelativePath)); + + if (assetsByWebRootPaths.TryGetValue(webRootPath, out var existingWebRootPath)) + { + if (!string.Equals(contentRootDefinition.ItemSpec, existingWebRootPath.ItemSpec, StringComparison.OrdinalIgnoreCase)) + { + Log.LogError($"Conflicting assets with the same path '{webRootPath}' for content root paths '{contentRootDefinition.ItemSpec}' and '{existingWebRootPath.ItemSpec}'."); + return false; + } + } + else + { + assetsByWebRootPaths.Add(webRootPath, contentRootDefinition); + } + } + } + + for (var i = 0; i < WebRootFiles.Length; i++) + { + var webRootFile = WebRootFiles[i]; + var relativePath = webRootFile.GetMetadata(TargetPath); + var webRootFileWebRootPath = GetWebRootPath("/", relativePath); + if (assetsByWebRootPaths.TryGetValue(webRootFileWebRootPath, out var existingAsset)) + { + Log.LogError($"The static web asset '{existingAsset.ItemSpec}' has a conflicting web root path '{webRootFileWebRootPath}' with the project file '{webRootFile.ItemSpec}'."); + return false; + } + } + + return true; + } + + // Normalizes /base/relative \base\relative\ base\relative and so on to /base/relative + private string GetWebRootPath(string basePath, string relativePath) => $"/{Path.Combine(basePath, relativePath.TrimStart('.').TrimStart('/')).Replace("\\", "/").Trim('/')}"; + + private bool EnsureRequiredMetadata(ITaskItem item, string metadataName) + { + var value = item.GetMetadata(metadataName); + if (string.IsNullOrEmpty(value)) + { + Log.LogError($"Missing required metadata '{metadataName}' for '{item.ItemSpec}'."); + return false; + } + + return true; + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/_._ b/src/Razor/Microsoft.NET.Sdk.Razor/src/_._ new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/baseline.netcore.json b/src/Razor/Microsoft.NET.Sdk.Razor/src/baseline.netcore.json new file mode 100644 index 0000000000..0443192d45 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/baseline.netcore.json @@ -0,0 +1,762 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Razor.Tasks, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.Build.Utilities.ToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ITask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Cancel", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ICancelableTask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Debug", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Debug", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DebugTool", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DebugTool", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolAssembly", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ToolAssembly", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForceServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForceServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PipeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PipeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolName", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardOutputLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardErrorLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateFullPathToTool", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCommandLineCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetResponseFileSwitch", + "Parameters": [ + { + "Name": "responseFilePath", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteTool", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + } + ], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "LogToolCommand", + "Parameters": [ + { + "Name": "message", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryExecuteOnServer", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + }, + { + "Name": "result", + "Type": "System.Int32", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleTaskExecutionErrors", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorGenerate", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Sources", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Sources", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorTagHelper", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Assemblies", + "Parameters": [], + "ReturnType": "System.String[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Assemblies", + "Parameters": [ + { + "Name": "value", + "Type": "System.String[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipTaskExecution", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.RequestArgument+ArgumentId", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CurrentDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294433" + }, + { + "Kind": "Field", + "Name": "CommandLineArgument", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294434" + }, + { + "Kind": "Field", + "Name": "KeepAlive", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294435" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294436" + }, + { + "Kind": "Field", + "Name": "TempDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294437" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.ServerResponse+ResponseType", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "MismatchedVersion", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Completed", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "2" + }, + { + "Kind": "Field", + "Name": "Rejected", + "Parameters": [], + "GenericParameter": [], + "Literal": "3" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/baseline.netframework.json b/src/Razor/Microsoft.NET.Sdk.Razor/src/baseline.netframework.json new file mode 100644 index 0000000000..4cec036ca8 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/baseline.netframework.json @@ -0,0 +1,762 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Razor.Tasks, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.Build.Utilities.ToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Debug", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Debug", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DebugTool", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DebugTool", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolAssembly", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ToolAssembly", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForceServer", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForceServer", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SuppressCurrentUserOnlyPipeOptions", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PipeName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PipeName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ToolName", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardOutputLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StandardErrorLoggingImportance", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.MessageImportance", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateFullPathToTool", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCommandLineCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetResponseFileSwitch", + "Parameters": [ + { + "Name": "responseFilePath", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Execute", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ITask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExecuteTool", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + } + ], + "ReturnType": "System.Int32", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "LogToolCommand", + "Parameters": [ + { + "Name": "message", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Cancel", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.Build.Framework.ICancelableTask", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TryExecuteOnServer", + "Parameters": [ + { + "Name": "pathToTool", + "Type": "System.String" + }, + { + "Name": "responseFileCommands", + "Type": "System.String" + }, + { + "Name": "commandLineCommands", + "Type": "System.String" + }, + { + "Name": "result", + "Type": "System.Int32", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleTaskExecutionErrors", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorGenerate", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Sources", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Sources", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tasks.RazorTagHelper", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Version", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Version", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Extensions", + "Parameters": [], + "ReturnType": "Microsoft.Build.Framework.ITaskItem[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Extensions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Build.Framework.ITaskItem[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Assemblies", + "Parameters": [], + "ReturnType": "System.String[]", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Assemblies", + "Parameters": [ + { + "Name": "value", + "Type": "System.String[]" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TagHelperManifest", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TagHelperManifest", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProjectRoot", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProjectRoot", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipTaskExecution", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateParameters", + "Parameters": [], + "ReturnType": "System.Boolean", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateResponseFileCommands", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.RequestArgument+ArgumentId", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CurrentDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294433" + }, + { + "Kind": "Field", + "Name": "CommandLineArgument", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294434" + }, + { + "Kind": "Field", + "Name": "KeepAlive", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294435" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294436" + }, + { + "Kind": "Field", + "Name": "TempDirectory", + "Parameters": [], + "GenericParameter": [], + "Literal": "1360294437" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Razor.Tools.ServerResponse+ResponseType", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "MismatchedVersion", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Completed", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + }, + { + "Kind": "Field", + "Name": "Shutdown", + "Parameters": [], + "GenericParameter": [], + "Literal": "2" + }, + { + "Kind": "Field", + "Name": "Rejected", + "Parameters": [], + "GenericParameter": [], + "Literal": "3" + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets new file mode 100644 index 0000000000..5f8081d69c --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets @@ -0,0 +1,183 @@ + + + + + + + + + + + + + <_RazorTagHelperInputCache>$(IntermediateOutputPath)$(TargetName).TagHelpers.input.cache + <_RazorTagHelperOutputCache>$(IntermediateOutputPath)$(TargetName).TagHelpers.output.cache + + + <_RazorGenerateInputsHash> + <_RazorGenerateInputsHashFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorCoreGenerate.cache + + <_RazorToolAssembly Condition="'$(_RazorToolAssembly)'==''">$(RazorSdkDirectoryRoot)tools\netcoreapp3.0\rzc.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_RazorGenerateOutput Include="%(RazorGenerateWithTargetPath.GeneratedOutput)" /> + + + + + + _HashRazorGenerateInputs; + _ResolveRazorGenerateOutputs; + + + + + + + + + + + + + + + + + + $(ResolveRazorCompileInputsDependsOn);_ResolveGeneratedRazorCompileInputs + + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets new file mode 100644 index 0000000000..c512c7ee49 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets @@ -0,0 +1,190 @@ + + + + + + + + $(NoWarn);1701;1702 + + + + + $(NoWarn);2008 + + + + + $(AppConfig) + + + + + false + + + + + + + + + + true + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Component.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Component.targets new file mode 100644 index 0000000000..b208426546 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Component.targets @@ -0,0 +1,291 @@ + + + + + + + + $(RazorComponentGenerateDependsOn); + RazorComponentGenerateCore + + + + + <_RazorGenerateComponentDeclarationDesignTimeDependsOn>ResolveRazorConfiguration;ResolveRazorComponentInputs;AssignRazorComponentTargetPaths;RazorGenerateComponentDeclaration + <_RazorGenerateComponentDesignTimeDependsOn>ResolveRazorComponentInputs;AssignRazorComponentTargetPaths + + + + + <_RazorComponentInputHash> + <_RazorComponentInputCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorComponent.input.cache + + + + + <_RazorComponentDeclarationAssembly Include="$(_RazorComponentDeclarationOutputPath)$(TargetName).dll" /> + + + + + + + + + + + + + + + + + + + + + <_RazorComponentDeclaration Include="@(RazorComponentWithTargetPath->'%(GeneratedDeclaration)')"> + %(Identity) + + <_RazorComponentDefinition Include="%(RazorComponentWithTargetPath.GeneratedOutput)" /> + + + + + + _HashRazorComponentInputs; + _ResolveRazorComponentOutputs; + + + + + + + + <_RazorComponentDeclarationSources Include="@(RazorComponentWithTargetPath)"> + %(RazorComponentWithTargetPath.GeneratedDeclaration) + + + + + + + + <_RazorComponentDeclarationManifest>$(IntermediateOutputPath)$(MSBuildProjectName).RazorComponents.declaration.json + + + + + + + + + + + + + + + + $(NoWarn);1701;1702 + + + + + $(NoWarn);2008 + + + + + $(AppConfig) + + + + + false + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + <_RazorComponentDeclarationAssemblyFullPath>@(_RazorComponentDeclarationAssembly->Metadata('FullPath')) + + + + + + + + + + + + + + RazorGenerateComponentDeclaration; + RazorCompileComponentDeclaration; + RazorGenerateComponentDefinition; + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets new file mode 100644 index 0000000000..9267ba8614 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets @@ -0,0 +1,95 @@ + + + + + + + true + + + + + + + + true + + + true + + + Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor + + + + + <_Parameter1>$(ProvideApplicationPartFactoryAttributeTypeName) + + + + + <_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute"> + <_Parameter1>$(RazorTargetName) + + + + + + + MVC-3.0 + Default + + + + + + + MVC-3.0;$(CustomRazorExtension) + + + + + + Microsoft.AspNetCore.Mvc.Razor.Extensions + $(RazorSdkDirectoryRoot)extensions\mvc-3-0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets new file mode 100644 index 0000000000..4d8e0b5c4d --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets @@ -0,0 +1,117 @@ + + + + + + + $(UpToDateReloadFileTypes);$(RazorUpToDateReloadFileTypes) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + File + + + File + + + Project + + + Project + + + Project + + + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.GenerateAssemblyInfo.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.GenerateAssemblyInfo.targets new file mode 100644 index 0000000000..a32b19a4d9 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.GenerateAssemblyInfo.targets @@ -0,0 +1,197 @@ + + + + + true + + + true + + + $(IntermediateOutputPath)$(MSBuildProjectName).RazorTargetAssemblyInfo.cs + <_RazorTargetAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorTargetAssemblyInfo.cache + + + <_RazorAssemblyInfo>$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfo.cs + <_RazorAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfo.cache + + + + + GetRazorTargetAssemblyAttributes; + _CreateRazorTargetAssemblyInfoInputsCacheFile; + CoreGenerateRazorTargetAssemblyInfo + + + + _ResolveMvcAssemblyAttributes; + $(GenerateRazorTargetAssemblyInfoDependsOn) + + + + + + + + + + + + + + + + + + + + + + + + + + $(FileVersion) + $(InformationalVersion) + $(Description) + $(RazorTargetName) + $(AssemblyVersion) + + + + + <_Parameter1>$(Company) + + + <_Parameter1>$(Configuration) + + + <_Parameter1>$(Copyright) + + + <_Parameter1>$(Product) + + + <_Parameter1>$(NeutralLanguage) + + + + <_Parameter1>$(RazorAssemblyDescription) + + + <_Parameter1>$(RazorAssemblyFileVersion) + + + <_Parameter1>$(RazorAssemblyInformationalVersion) + + + <_Parameter1>$(RazorAssemblyTitle) + + + <_Parameter1>$(RazorAssemblyVersion) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(CoreCompileDependsOn); + _GenerateRazorAssemblyInfo + + + <_GenerateRazorAssemblyInfoDependsOn>RazorGetAssemblyAttributes;PrepareForBuild;_CoreGenerateRazorAssemblyInfo + + + <_GenerateRazorAssemblyInfoDependsOn Condition="'$(_Targeting30OrNewerRazorLangVersion)' == 'true'"> + _ResolveMvcAssemblyAttributes; + $(_GenerateRazorAssemblyInfoDependsOn); + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.MvcApplicationPartsDiscovery.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.MvcApplicationPartsDiscovery.targets new file mode 100644 index 0000000000..bcd4e91e22 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.MvcApplicationPartsDiscovery.targets @@ -0,0 +1,102 @@ + + + + + + + true + + + _DiscoverMvcApplicationParts; + $(CoreCompileDependsOn); + + + <_MvcApplicationPartAttributeGeneratedFile>$(IntermediateOutputPath)$(TargetName).MvcApplicationPartsAssemblyInfo$(DefaultLanguageSourceExtension) + <_MvcApplicationPartCacheFile>$(IntermediateOutputPath)$(TargetName).MvcApplicationPartsAssemblyInfo.cache + + + + + + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Abstractions" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.ApiExplorer" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Core" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Cors" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.DataAnnotations" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Formatters.Json" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Localization" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.Razor" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.RazorPages" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.TagHelpers" /> + <_MvcAssemblyName Include="Microsoft.AspNetCore.Mvc.ViewFeatures" /> + + + + + + + + <_MvcApplicationPartAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute"> + <_Parameter1>%(_ApplicationPartAssemblyNames.Identity) + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets new file mode 100644 index 0000000000..9a66b1b926 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + ResolveStaticWebAssetsInputs; + _CreateStaticWebAssetsInputsCacheFile; + $(GenerateStaticWebAssetsManifestDependsOn) + + + + ResolveCurrentProjectStaticWebAssetsInputs; + $(GetCurrentProjectStaticWebAssetsDependsOn) + + + + $(GetCopyToOutputDirectoryItemsDependsOn); + GenerateStaticWebAssetsManifest; + + + + ResolveCurrentProjectStaticWebAssetsInputs; + ResolveReferencedProjectsStaticWebAssets; + $(ResolveStaticWebAssetsInputsDependsOn) + + + + PrepareProjectReferences; + $(ResolveReferencedProjectsStaticWebAssetsDependsOn) + + + + _CreateStaticWebAssetsCustomPropsCacheFile; + $(GenerateStaticWebAssetsPackTargetsDependsOn) + + + + GenerateStaticWebAssetsPackTargets; + $(TargetsForTfmSpecificContentInPackage) + + + + _RemoveWebRootContentFromPackaging; + $(PackDependsOn) + + + + + + <_StaticWebAssetsIntermediateOutputPath>$(IntermediateOutputPath)staticwebassets\ + + + <_GeneratedStaticWebAssetsInputsCacheFile>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).StaticWebAssets.Manifest.cache + <_GeneratedStaticWebAssetsDevelopmentManifest>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).StaticWebAssets.xml + + + <_GeneratedStaticWebAssetsCustomPropsCacheFile>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).StaticWebAssets.Pack.cache + + + <_GeneratedStaticWebAssetsPropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.$(PackageId).Microsoft.AspNetCore.StaticWebAssets.props + <_GeneratedBuildPropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.build.$(PackageId).props + <_GeneratedBuildMultitargetingPropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.buildMultiTargeting.$(PackageId).props + <_GeneratedBuildTransitivePropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.buildTransitive.$(PackageId).props + + + <_StaticWebAssetsPropsFileImportPath>Microsoft.AspNetCore.StaticWebAssets.props + <_StaticWebAssetsGeneratedBuildPropsFileImportPath>..\build\$(PackageId).props + <_StaticWebAssetsGeneratedBuildMultiTargetingPropsFileImportPath>..\buildMultiTargeting\$(PackageId).props + + + + + + + + + + + + + + + <_ExternalStaticWebAsset + Include="%(StaticWebAsset.Identity)" + Condition="'%(SourceType)' != ''"> + %(StaticWebAsset.BasePath) + %(StaticWebAsset.ContentRoot) + %(StaticWebAsset.SourceId) + + + + + + + + + + + + + + + + + + + + + + <_WebRootFiles Include="@(ContentWithTargetPath)" Condition="$([System.String]::Copy('%(TargetPath)').Replace('\','/').StartsWith('wwwroot/'))" /> + <_ReferencedStaticWebAssets Include="@(StaticWebAsset)" Condition="'%(SourceType)' != ''" /> + + + + + + + + + + + $(TargetName).StaticWebAssets.xml + PreserveNewest + Never + + + + + + + + + + + + + + + + + + + + + + + + + <_StaticWebAssetsProjectReference Include="@(_MSBuildProjectReferenceExistent)" /> + + + + + + + + + + + + + + + + + _content/$(PackageId) + + + + + <_ThisProjectStaticWebAsset + Include="@(Content)" + Condition="$([System.String]::Copy('%(Identity)').Replace('\','/').StartsWith('wwwroot/'))"> + + + $([System.String]::Copy('%(Identity)').Substring(8)) + + + + + + + + $(PackageId) + + $([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)\wwwroot\')) + + $(StaticWebAssetBasePath) + + %(RelativePath) + + + + + + + + + + + + <_ThisProjectStaticWebAssets + Include="@(StaticWebAsset)" + Condition="'%(StaticWebAsset.SourceType)' == ''"> + Project + + + + + + + + + + + + + + + + + + + <_CurrentProjectStaticWebAsset + Include="@(StaticWebAsset)" + Condition="'%(SourceType)' == ''" /> + + + + + + + + + + + + + + + + + + + <_CurrentProjectHasStaticWebAssets Condition="'@(_CurrentProjectStaticWebAsset->Count())' != '0'">true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + build\Microsoft.AspNetCore.StaticWebAssets.props + + + + + build\$(PackageId).props + + + + + buildMultiTargeting\$(PackageId).props + + + + + buildTransitive\$(PackageId).props + + + + + + staticwebassets\%(_CurrentProjectStaticWebAsset.RelativePath) + + + + + + + + + + + + + + + <_ExternalPublishStaticWebAsset + Include="%(StaticWebAsset.FullPath)" + Condition="'%(SourceType)' != ''"> + + PreserveNewest + $([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\%(BasePath)\%(RelativePath)'))')) + + + + + + + true + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props new file mode 100644 index 0000000000..6fad4d5180 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props @@ -0,0 +1,17 @@ + + + + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.props + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.targets + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml new file mode 100644 index 0000000000..668c85bd59 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorComponentWithTargetPath.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorConfiguration.xaml b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorConfiguration.xaml new file mode 100644 index 0000000000..55ae9abb42 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorConfiguration.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorExtension.xaml b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorExtension.xaml new file mode 100644 index 0000000000..49589142ee --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorExtension.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorGeneral.xaml b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorGeneral.xaml new file mode 100644 index 0000000000..9a8785f206 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorGeneral.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorGenerateWithTargetPath.xaml b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorGenerateWithTargetPath.xaml new file mode 100644 index 0000000000..bab10bf249 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Rules/RazorGenerateWithTargetPath.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props new file mode 100644 index 0000000000..b7d17b206b --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -0,0 +1,85 @@ + + + + + + + + true + + + true + + + true + + + false + + + Implicit + + + false + + + .g.cs + + + true + + + false + + + .cs;.razor;.resx;.cshtml + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets new file mode 100644 index 0000000000..0b6cf45554 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -0,0 +1,885 @@ + + + + + true + + + + + + + + + + $(MSBuildThisFileDirectory)..\..\ + $(RazorSdkDirectoryRoot)tasks\ + <_RazorSdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">net5.0 + <_RazorSdkTasksTFM Condition=" '$(_RazorSdkTasksTFM)' == ''">net46 + $(RazorSdkBuildTasksDirectoryRoot)$(_RazorSdkTasksTFM)\Microsoft.NET.Sdk.Razor.Tasks.dll + + + + + <_TargetFrameworkVersionWithoutV>$(TargetFrameworkVersion.TrimStart('vV')) + <_TargetingNETCoreApp30OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">true + + + 3.0 + + + 2.1 + + + <_Targeting30OrNewerRazorLangVersion Condition=" + '$(RazorLangVersion)' == 'Latest' OR + '$(RazorLangVersion)' == 'Experimental' OR + ('$(RazorLangVersion)' != '' AND '$(RazorLangVersion)' >= '3.0')">true + + + $(_Targeting30OrNewerRazorLangVersion) + + + + + + <_IsTargetingRazor2X Condition="'$(IsRazorCompilerReferenced)'=='true'">true + + + + + + ResolveRazorConfiguration; + ResolveRazorGenerateInputs; + AssignRazorGenerateTargetPaths; + ResolveAssemblyReferenceRazorGenerateInputs; + _CheckForMissingRazorCompiler; + _CheckForIncorrectMvcConfiguration; + ResolveTagHelperRazorGenerateInputs + + + + ResolveRazorConfiguration; + ResolveRazorComponentInputs; + _CheckForIncorrectComponentsConfiguration; + AssignRazorComponentTargetPaths; + + + + PrepareForRazorGenerate; + _CheckForMissingRazorCompiler; + RazorCoreGenerate + + + + PrepareForRazorComponentGenerate + + + + RazorGenerate; + ResolveRazorCompileInputs; + GenerateRazorTargetAssemblyInfo + + + + ResolveRazorEmbeddedResources; + _FixupRazorReferencePathForRazorCompile; + + + + PrepareForRazorCompile; + RazorCoreCompile + + + + $(BuiltProjectOutputGroupDependsOn); + _RazorAddBuiltProjectOutputGroupOutput + + + + $(DebugSymbolsProjectOutputGroupDependsOn); + _RazorAddDebugSymbolsProjectOutputGroupOutput + + + + RazorComponentGenerate; + $(CoreCompileDependsOn) + + + + RazorGenerateComponentDeclarationDesignTime; + $(CoreCompileDependsOn) + + + + $(PrepareForBuildDependsOn); + ResolveRazorGenerateInputs + + + + ResolveRazorGenerateInputs; + $(GenerateNuspecDependsOn) + + + + _RazorPrepareForRun; + $(PrepareForRunDependsOn) + + + + _RazorGetCopyToOutputDirectoryItems; + $(GetCopyToOutputDirectoryItemsDependsOn) + + + + + + + true + + + + + true + + + $(MvcRazorCompileOnPublish) + + + true + + + + + + $(IntermediateOutputPath)Razor\ + + <_RazorComponentDeclarationOutputPath Condition="'$(_RazorComponentDeclarationOutputPath)'==''">$(IntermediateOutputPath)RazorDeclaration\ + + + .Views + + + .Razor + + + $(TargetName)$(RazorTargetNameSuffix) + + + false + true + + false + true + + + $(PreserveCompilationReferences) + + + true + + + $([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)')) + + + $(MvcRazorEmbedViewSources) + false + + + $(UseSharedCompilation) + true + + + + + <_RazorDebugSymbolsProduced>false + <_RazorDebugSymbolsProduced Condition="'$(DebugSymbols)'=='true'">true + <_RazorDebugSymbolsProduced Condition="'$(DebugType)'=='none'">false + <_RazorDebugSymbolsProduced Condition="'$(DebugType)'=='pdbonly'">true + <_RazorDebugSymbolsProduced Condition="'$(DebugType)'=='full'">true + <_RazorDebugSymbolsProduced Condition="'$(DebugType)'=='portable'">true + <_RazorDebugSymbolsProduced Condition="'$(DebugType)'=='embedded'">false + + + + + RazorSdk + + + + + PrecompilationTool + + + RazorSdk + + $(RazorCompileToolset) + $(RazorCompileToolset) + + + PrecompilationTool + + + true + + + + + + true + + + + + + + + <_RazorDebugSymbolsIntermediatePath Condition="'$(_RazorDebugSymbolsProduced)'=='true'" Include="$(IntermediateOutputPath)$(RazorTargetName).pdb" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute"> + <_Parameter1>$(RazorLangVersion) + + <_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute"> + <_Parameter1>$(RazorDefaultConfiguration) + + <_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute" Condition="'%(ResolvedRazorExtension.AssemblyName)'!=''"> + <_Parameter1>%(ResolvedRazorExtension.Identity) + <_Parameter2>%(ResolvedRazorExtension.AssemblyName) + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:RazorGenerateComponentDeclarationDesignTime + Never + + + + + + + + + + + $(RazorGenerateIntermediateOutputPath)%(RazorComponentWithTargetPath.TargetPath)$(RazorGenerateOutputFileExtension) + + + + $(_RazorComponentDeclarationOutputPath)%(RazorComponentWithTargetPath.TargetPath)$(RazorGenerateOutputFileExtension) + + + + component + + + + + + + + + + + + $(RazorGenerateIntermediateOutputPath)%(RazorGenerateWithTargetPath.TargetPath)$(RazorGenerateOutputFileExtension) + + + + mvc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /$([System.String]::Copy('%(RazorGenerateWithTargetPath.TargetPath)').Replace('\','/')) + Non-Resx + false + + + + <_RazorCoreCompileResourceInputs + Include="@(RazorEmbeddedResource)" + Condition="'%(RazorEmbeddedResource.WithCulture)'=='false' and '%(RazorEmbeddedResource.Type)'=='Non-Resx' " /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %(Filename)%(Extension) + PreserveNewest + + + %(Filename)%(Extension) + PreserveNewest + + + + + + + + + + + + %(Filename)%(Extension) + PreserveNewest + + + %(Filename)%(Extension) + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @(RazorIntermediateAssembly->'%(Filename)%(Extension)') + + true + + + @(_RazorDebugSymbolsIntermediatePath->'%(Filename)%(Extension)') + + + + + + + + + + + + + $(CopyRefAssembliesToPublishDirectory) + + + + + + + + + + + + + + + + + + + $([MSBuild]::EnsureTrailingSlash('$(OutDir)')) + $([MSBuild]::Escape($([MSBuild]::EnsureTrailingSlash($([System.IO.Path]::GetFullPath('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(RazorOutputPath)'))')))))) + + $(RazorTargetDir)$(RazorTargetName).dll + + + + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Razor\Microsoft.NET.Sdk.Razor.DesignTime.targets + $(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Razor.DesignTime.targets + + + + + + + $(RazorUpToDateReloadFileTypes) + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props b/src/Razor/Microsoft.NET.Sdk.Razor/src/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props new file mode 100644 index 0000000000..3515931928 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/buildMultiTargeting/Microsoft.NET.Sdk.Razor.props @@ -0,0 +1,17 @@ + + + + $(MSBuildThisFileDirectory)..\build\netstandard2.0\Sdk.Razor.CurrentVersion.props + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.MultiTargeting.targets + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/buildMultiTargeting/Sdk.Razor.CurrentVersion.MultiTargeting.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/buildMultiTargeting/Sdk.Razor.CurrentVersion.MultiTargeting.targets new file mode 100644 index 0000000000..a4e070ef57 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/buildMultiTargeting/Sdk.Razor.CurrentVersion.MultiTargeting.targets @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/BuildVariables.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/BuildVariables.cs new file mode 100644 index 0000000000..d213b173c1 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/BuildVariables.cs @@ -0,0 +1,41 @@ +// 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.Razor.Design.IntegrationTests +{ + internal static partial class BuildVariables + { + private static string _msBuildPath = string.Empty; + private static string _MicrosoftNETCoreApp50PackageVersion = string.Empty; + private static string _microsoftNetCompilersToolsetPackageVersion = string.Empty; + + static partial void InitializeVariables(); + + public static string MSBuildPath + { + get + { + InitializeVariables(); + return _msBuildPath; + } + } + + public static string MicrosoftNETCoreApp50PackageVersion + { + get + { + InitializeVariables(); + return _MicrosoftNETCoreApp50PackageVersion; + } + } + + public static string MicrosoftNetCompilersToolsetPackageVersion + { + get + { + InitializeVariables(); + return _microsoftNetCompilersToolsetPackageVersion; + } + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/GenerateAspNetCoreStaticAssetsManifestTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/GenerateAspNetCoreStaticAssetsManifestTest.cs new file mode 100644 index 0000000000..bc89a9b185 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/GenerateAspNetCoreStaticAssetsManifestTest.cs @@ -0,0 +1,355 @@ +// 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.IO; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class GenerateStaticWebAssetsManifestTest + { + [Fact] + public void ReturnsError_WhenBasePathIsMissing() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot", "sample.js"), new Dictionary + { + ["ContentRoot"] = "/" + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'BasePath' for '{Path.Combine("wwwroot", "sample.js")}'.", message); + } + + [Fact] + public void ReturnsError_WhenContentRootIsMissing() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","sample.js"), new Dictionary + { + ["BasePath"] = "MyLibrary" + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'ContentRoot' for '{Path.Combine("wwwroot", "sample.js")}'.", message); + } + + [Fact] + public void ReturnsError_ForDuplicateBasePaths() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","sample.js"), new Dictionary + { + ["BasePath"] = "MyLibrary", + ["ContentRoot"] = Path.Combine("nuget", "MyLibrary"), + ["SourceId"] = "MyLibrary" + }), + CreateItem(Path.Combine("wwwroot", "otherLib.js"), new Dictionary + { + ["BasePath"] = "MyLibrary", + ["ContentRoot"] = Path.Combine("nuget", "MyOtherLibrary"), + ["SourceId"] = "MyOtherLibrary" + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal( + $"Duplicate base paths 'MyLibrary' for content root paths '{Path.Combine("nuget", "MyOtherLibrary")}' and '{Path.Combine("nuget", "MyLibrary")}'. " + + $"('{Path.Combine("wwwroot", "otherLib.js")}', '{Path.Combine("wwwroot", "sample.js")}')", + message); + } + + [Fact] + public void AllowsMultipleContentRootsWithSameBasePath_ForTheSameSourceId() + { + // Arrange + var file = Path.GetTempFileName(); + var expectedDocument = $@" + + +"; + + var buildEngine = new Mock(); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","sample.js"), new Dictionary + { + ["BasePath"] = "Blazor.Client", + ["ContentRoot"] = Path.Combine(".", "nuget","Blazor.Client"), + ["SourceId"] = "Blazor.Client" + }), + CreateItem(Path.Combine("wwwroot", "otherLib.js"), new Dictionary + { + ["BasePath"] = "Blazor.Client", + ["ContentRoot"] = Path.Combine(".", "nuget", "bin","debug","netstandard2.1"), + ["SourceId"] = "Blazor.Client" + }) + }, + TargetManifestPath = file + }; + + try + { + // Act + var result = task.Execute(); + + // Assert + Assert.True(result); + var document = File.ReadAllText(file); + Assert.Equal(expectedDocument, document); + } + finally + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + } + + [Fact] + public void ReturnsError_ForDuplicateContentRoots() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","sample.js"), new Dictionary + { + ["BasePath"] = "MyLibrary", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = Path.Combine(".", "MyLibrary") + }), + CreateItem(Path.Combine("wwwroot", "otherLib.js"), new Dictionary + { + ["BasePath"] = "MyOtherLibrary", + ["SourceId"] = "MyOtherLibrary", + ["ContentRoot"] = Path.Combine(".", "MyLibrary") + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal( + $"Duplicate content root paths '{Path.Combine(".", "MyLibrary")}' for base paths 'MyOtherLibrary' and 'MyLibrary' " + + $"('{Path.Combine("wwwroot", "otherLib.js")}', '{Path.Combine("wwwroot", "sample.js")}')", + message); + } + + [Fact] + public void Generates_EmptyManifest_WhenNoItems_Passed() + { + // Arrange + var file = Path.GetTempFileName(); + var expectedDocument = @""; + + try + { + var buildEngine = new Mock(); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] { }, + TargetManifestPath = file + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.True(result); + var document = File.ReadAllText(file); + Assert.Equal(expectedDocument, document); + } + finally + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + } + + [Fact] + public void Generates_Manifest_WhenContentRootsAvailable() + { + // Arrange + var file = Path.GetTempFileName(); + var expectedDocument = $@" + +"; + + try + { + var buildEngine = new Mock(); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","sample.js"), new Dictionary + { + ["BasePath"] = "MyLibrary", + ["ContentRoot"] = Path.Combine(".", "nuget", "MyLibrary", "razorContent"), + ["SourceId"] = "MyLibrary" + }), + }, + TargetManifestPath = file + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.True(result); + var document = File.ReadAllText(file); + Assert.Equal(expectedDocument, document); + } + finally + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + } + + [Fact] + public void SkipsAdditionalElements_WithSameBasePathAndSameContentRoot() + { + // Arrange + var file = Path.GetTempFileName(); + var expectedDocument = $@" + +"; + + try + { + var buildEngine = new Mock(); + + var task = new GenerateStaticWebAssetsManifest + { + BuildEngine = buildEngine.Object, + ContentRootDefinitions = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","sample.js"), new Dictionary + { + // Base path needs to be normalized to '/' as it goes in the url + ["BasePath"] = "Base\\MyLibrary", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = Path.Combine(".", "nuget", "MyLibrary", "razorContent") + }), + // Comparisons are case insensitive + CreateItem(Path.Combine("wwwroot, site.css"), new Dictionary + { + ["BasePath"] = "Base\\MyLIBRARY", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = Path.Combine(".", "nuget", "MyLIBRARY", "razorContent") + }), + }, + TargetManifestPath = file + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.True(result); + var document = File.ReadAllText(file); + Assert.Equal(expectedDocument, document); + } + finally + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + } + + private static TaskItem CreateItem( + string spec, + IDictionary metadata) + { + var result = new TaskItem(spec); + foreach (var (key, value) in metadata) + { + result.SetMetadata(key, value); + } + + return result; + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/GenerateStaticWebAssetsPropsFileTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/GenerateStaticWebAssetsPropsFileTest.cs new file mode 100644 index 0000000000..af181b23dc --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/GenerateStaticWebAssetsPropsFileTest.cs @@ -0,0 +1,433 @@ +// 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.IO; +using Microsoft.AspNetCore.Razor.Tasks; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Tasks +{ + public class GenerateStaticWebAssetsPropsFileTest + { + [Fact] + public void Fails_WhenStaticWebAsset_DoesNotContainSourceType() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'SourceType' for '{Path.Combine("wwwroot", "js", "sample.js")}'.", message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_DoesNotContainSourceId() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'SourceId' for '{Path.Combine("wwwroot", "js", "sample.js")}'.", message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_DoesNotContainContentRoot() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'ContentRoot' for '{Path.Combine("wwwroot", "js", "sample.js")}'.", message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_DoesNotContainBasePath() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'BasePath' for '{Path.Combine("wwwroot", "js", "sample.js")}'.", message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_DoesNotContainRelativePath() + { + // Arrange + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal($"Missing required metadata 'RelativePath' for '{Path.Combine("wwwroot", "js", "sample.js")}'.", message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_HaveDifferentSourceType() + { + // Arrange + var expectedError = "Static web assets have different 'SourceType' metadata values " + + "'' and 'Package' " + + $"for '{Path.Combine("wwwroot", "js", "sample.js")}' and '{Path.Combine("wwwroot", "css", "site.css")}'."; + + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }), + CreateItem(Path.Combine("wwwroot","css","site.css"), new Dictionary + { + ["SourceType"] = "Package", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("css", "site.css"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal(expectedError, message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_HaveDifferentSourceId() + { + // Arrange + var expectedError = "Static web assets have different 'SourceId' metadata values " + + "'MyLibrary' and 'MyLibrary2' " + + $"for '{Path.Combine("wwwroot", "js", "sample.js")}' and '{Path.Combine("wwwroot", "css", "site.css")}'."; + + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }), + CreateItem(Path.Combine("wwwroot","css","site.css"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary2", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("css", "site.css"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal(expectedError, message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_HaveDifferentContentRoot() + { + // Arrange + var expectedError = "Static web assets have different 'ContentRoot' metadata values " + + @"'$(MSBuildThisFileDirectory)..\staticwebassets' and '..\staticwebassets' " + + $"for '{Path.Combine("wwwroot", "js", "sample.js")}' and '{Path.Combine("wwwroot", "css", "site.css")}'."; + + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }), + CreateItem(Path.Combine("wwwroot","css","site.css"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("css", "site.css"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal(expectedError, message); + } + + [Fact] + public void Fails_WhenStaticWebAsset_HaveDifferentBasePath() + { + // Arrange + var expectedError = "Static web assets have different 'BasePath' metadata values " + + "'_content/mylibrary' and '_content/mylibrary2' " + + $"for '{Path.Combine("wwwroot", "js", "sample.js")}' and '{Path.Combine("wwwroot", "css", "site.css")}'."; + + var errorMessages = new List(); + var buildEngine = new Mock(); + buildEngine.Setup(e => e.LogErrorEvent(It.IsAny())) + .Callback(args => errorMessages.Add(args.Message)); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }), + CreateItem(Path.Combine("wwwroot","css","site.css"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary2", + ["RelativePath"] = Path.Combine("css", "site.css"), + }) + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.False(result); + var message = Assert.Single(errorMessages); + Assert.Equal(expectedError, message); + } + + [Fact] + public void WritesPropsFile_WhenThereIsAtLeastOneStaticAsset() + { + // Arrange + var file = Path.GetTempFileName(); + var expectedDocument = @" + + + Package + MyLibrary + $(MSBuildThisFileDirectory)..\staticwebassets\ + _content/mylibrary + %(RecursiveDir)%(FileName)%(Extension) + + +"; + + try + { + var buildEngine = new Mock(); + + var task = new GenerateStaticWebAsssetsPropsFile + { + BuildEngine = buildEngine.Object, + TargetPropsFilePath = file, + StaticWebAssets = new TaskItem[] + { + CreateItem(Path.Combine("wwwroot","js","sample.js"), new Dictionary + { + ["SourceType"] = "", + ["SourceId"] = "MyLibrary", + ["ContentRoot"] = @"$(MSBuildThisFileDirectory)..\staticwebassets", + ["BasePath"] = "_content/mylibrary", + ["RelativePath"] = Path.Combine("js", "sample.js"), + }), + } + }; + + // Act + var result = task.Execute(); + + // Assert + Assert.True(result); + var document = File.ReadAllText(file); + Assert.Equal(expectedDocument, document); + } + finally + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + } + + private static TaskItem CreateItem( + string spec, + IDictionary metadata) + { + var result = new TaskItem(spec); + foreach (var (key, value) in metadata) + { + result.SetMetadata(key, value); + } + + return result; + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ApplicationPartDiscoveryIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ApplicationPartDiscoveryIntegrationTest.cs new file mode 100644 index 0000000000..32f91bbdd2 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ApplicationPartDiscoveryIntegrationTest.cs @@ -0,0 +1,193 @@ +// 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.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class ApplicationPartDiscoveryIntegrationTest : MSBuildIntegrationTestBase, IClassFixture + { + public ApplicationPartDiscoveryIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public Task Build_ProjectWithDependencyThatReferencesMvc_AddsAttribute_WhenBuildingUsingDotnetMsbuild() + => Build_ProjectWithDependencyThatReferencesMvc_AddsAttribute(MSBuildProcessKind.Dotnet); + + [ConditionalFact(Skip = "net5.0 TFM is not recognized on Desktop MSBuild. A VS update will be needed.")] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public Task Build_ProjectWithDependencyThatReferencesMvc_AddsAttribute_WhenBuildingUsingDesktopMsbuild() + => Build_ProjectWithDependencyThatReferencesMvc_AddsAttribute(MSBuildProcessKind.Desktop); + + private async Task Build_ProjectWithDependencyThatReferencesMvc_AddsAttribute(MSBuildProcessKind msBuildProcessKind) + { + var result = await DotnetMSBuild("Build", msBuildProcessKind: msBuildProcessKind); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "AppWithP2PReference.MvcApplicationPartsAssemblyInfo.cs"); + Assert.FileContains(result, Path.Combine(IntermediateOutputPath, "AppWithP2PReference.MvcApplicationPartsAssemblyInfo.cs"), "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute(\"ClassLibrary\")]"); + Assert.AssemblyHasAttribute(result, Path.Combine(OutputPath, "AppWithP2PReference.dll"), "Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute"); + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public async Task Build_ProjectWithDependencyThatReferencesMvc_DoesNotGenerateAttributeIfFlagIsReset() + { + var result = await DotnetMSBuild("Build /p:GenerateMvcApplicationPartsAssemblyAttributes=false"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, IntermediateOutputPath, "AppWithP2PReference.MvcApplicationPartsAssemblyInfo.cs"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_ProjectWithoutMvcReferencingDependencies_DoesNotGenerateAttribute() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.MvcApplicationPartsAssemblyInfo.cs"); + + // We should produced a cache file for build incrementalism + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.MvcApplicationPartsAssemblyInfo.cache"); + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public async Task BuildIncrementalism_WhenApplicationPartAttributeIsGenerated() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + var generatedAttributeFile = Path.Combine(IntermediateOutputPath, "AppWithP2PReference.MvcApplicationPartsAssemblyInfo.cs"); + var cacheFile = Path.Combine(IntermediateOutputPath, "AppWithP2PReference.MvcApplicationPartsAssemblyInfo.cache"); + var outputFile = Path.Combine(IntermediateOutputPath, "AppWithP2PReference.dll"); + Assert.FileExists(result, generatedAttributeFile); + Assert.FileContains(result, generatedAttributeFile, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute(\"ClassLibrary\")]"); + + var generatedFilethumbPrint = GetThumbPrint(generatedAttributeFile); + var cacheFileThumbPrint = GetThumbPrint(cacheFile); + var outputFileThumbPrint = GetThumbPrint(outputFile); + + await AssertIncrementalBuild(); + await AssertIncrementalBuild(); + + async Task AssertIncrementalBuild() + { + result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, generatedAttributeFile); + Assert.Equal(generatedFilethumbPrint, GetThumbPrint(generatedAttributeFile)); + Assert.Equal(cacheFileThumbPrint, GetThumbPrint(cacheFile)); + Assert.Equal(outputFileThumbPrint, GetThumbPrint(outputFile)); + Assert.AssemblyHasAttribute(result, Path.Combine(OutputPath, "AppWithP2PReference.dll"), "Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute"); + } + } + + // Regression test for https://github.com/dotnet/aspnetcore/issues/11315 + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public async Task BuildIncrementalism_CausingRecompilation_WhenApplicationPartAttributeIsGenerated() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + var generatedAttributeFile = Path.Combine(IntermediateOutputPath, "AppWithP2PReference.MvcApplicationPartsAssemblyInfo.cs"); + Assert.FileExists(result, generatedAttributeFile); + Assert.FileContains(result, generatedAttributeFile, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute(\"ClassLibrary\")]"); + + var thumbPrint = GetThumbPrint(generatedAttributeFile); + + // Touch a file in the main app which should call recompilation, but not the Mvc discovery tasks to re-run. + File.AppendAllText(Path.Combine(Project.DirectoryPath, "Program.cs"), " "); + result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, generatedAttributeFile); + Assert.Equal(thumbPrint, GetThumbPrint(generatedAttributeFile)); + Assert.AssemblyHasAttribute(result, Path.Combine(OutputPath, "AppWithP2PReference.dll"), "Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute"); + } + + [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/13303")] + [InitializeTestProject("SimpleMvcFSharp", language: "F#", additionalProjects: "ClassLibrary")] + public async Task Build_ProjectWithDependencyThatReferencesMvc_AddsAttributeToNonCSharpProjects() + { + AddProjectFileContent( +@" + + + +"); + + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvcFSharp.MvcApplicationPartsAssemblyInfo.fs"); + Assert.FileContains(result, Path.Combine(IntermediateOutputPath, "SimpleMvcFSharp.MvcApplicationPartsAssemblyInfo.fs"), ""); + Assert.AssemblyHasAttribute(result, Path.Combine(OutputPath, "SimpleMvcFSharp.dll"), "Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task BuildIncrementalism_WhenApplicationPartAttributeIsNotGenerated() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + var generatedAttributeFile = Path.Combine(IntermediateOutputPath, "SimpleMvc.MvcApplicationPartsAssemblyInfo.cs"); + var cacheFile = Path.Combine(IntermediateOutputPath, "SimpleMvc.MvcApplicationPartsAssemblyInfo.cache"); + var outputFile = Path.Combine(IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, generatedAttributeFile); + Assert.FileExists(result, cacheFile); + + var cacheFilethumbPrint = GetThumbPrint(cacheFile); + var outputFilethumbPrint = GetThumbPrint(outputFile); + + // Couple rounds of incremental builds. + await AssertIncrementalBuild(); + await AssertIncrementalBuild(); + await AssertIncrementalBuild(); + + async Task AssertIncrementalBuild() + { + result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, generatedAttributeFile); + Assert.FileExists(result, cacheFile); + Assert.Equal(cacheFilethumbPrint, GetThumbPrint(cacheFile)); + Assert.Equal(outputFilethumbPrint, GetThumbPrint(outputFile)); + } + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public async Task Build_ProjectWithMissingAssemblyReference_PrintsWarning() + { + var result = await DotnetMSBuild("Build /p:BuildProjectReferences=false"); + + Assert.BuildFailed(result); + + Assert.BuildWarning(result, "RAZORSDK1007"); + Assert.BuildError(result, "CS0006"); + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs new file mode 100644 index 0000000000..72e8d79e49 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs @@ -0,0 +1,905 @@ +// 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.Diagnostics; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using System.Text; +using System.Text.RegularExpressions; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + internal class Assert : Xunit.Assert + { + // Matches `{filename}: error {code}: {message} [{project}] + // See https://stackoverflow.com/questions/3441452/msbuild-and-ignorestandarderrorwarningformat/5180353#5180353 + private static readonly Regex ErrorRegex = new Regex(@"^(?'location'.+): error (?'errorcode'[A-Z0-9]+): (?'message'.+) \[(?'project'.+)\]$"); + private static readonly Regex WarningRegex = new Regex(@"^(?'location'.+): warning (?'errorcode'[A-Z0-9]+): (?'message'.+) \[(?'project'.+)\]$"); + private static readonly string[] AllowedBuildWarnings = new[] + { + "MSB3491" , // The process cannot access the file. As long as the build succeeds, we're ok. + "NETSDK1071", // "A PackageReference to 'Microsoft.NETCore.App' specified a Version ..." + }; + + public static void BuildPassed(MSBuildResult result, bool allowWarnings = false) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (result.ExitCode != 0) + { + throw new BuildFailedException(result); + } + + var buildWarnings = GetBuildWarnings(result) + .Where(m => !AllowedBuildWarnings.Contains(m.match.Groups["errorcode"].Value)) + .Select(m => m.line); + + if (!allowWarnings && buildWarnings.Any()) + { + throw new BuildWarningsException(result, buildWarnings); + } + } + + public static void BuildError(MSBuildResult result, string errorCode, string location = null) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + // We don't really need to search line by line, I'm doing this so that it's possible/easy to debug. + var lines = result.Output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i]; + var match = ErrorRegex.Match(line); + if (match.Success) + { + if (match.Groups["errorcode"].Value != errorCode) + { + continue; + } + + if (location != null && match.Groups["location"].Value.Trim() != location) + { + continue; + } + + // This is a match + return; + } + } + + throw new BuildErrorMissingException(result, errorCode, location); + } + + public static void BuildWarning(MSBuildResult result, string errorCode, string location = null) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + // We don't really need to search line by line, I'm doing this so that it's possible/easy to debug. + foreach (var (_, match) in GetBuildWarnings(result)) + { + if (match.Groups["errorcode"].Value != errorCode) + { + continue; + } + + if (location != null && match.Groups["location"].Value.Trim() != location) + { + continue; + } + + // This is a match + return; + } + + throw new BuildErrorMissingException(result, errorCode, location); + } + + private static IEnumerable<(string line, Match match)> GetBuildWarnings(MSBuildResult result) + { + var lines = result.Output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i]; + var match = WarningRegex.Match(line); + if (match.Success) + { + yield return (line, match); + } + } + } + + public static void BuildFailed(MSBuildResult result) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + }; + + if (result.ExitCode == 0) + { + throw new BuildPassedException(result); + } + } + + public static void BuildOutputContainsLine(MSBuildResult result, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (match == null) + { + throw new ArgumentNullException(nameof(match)); + } + + // We don't really need to search line by line, I'm doing this so that it's possible/easy to debug. + var lines = result.Output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i].Trim(); + if (line == match) + { + return; + } + } + + throw new BuildOutputMissingException(result, match); + } + + public static void BuildOutputDoesNotContainLine(MSBuildResult result, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (match == null) + { + throw new ArgumentNullException(nameof(match)); + } + + // We don't really need to search line by line, I'm doing this so that it's possible/easy to debug. + var lines = result.Output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i].Trim(); + if (line == match) + { + throw new BuildOutputContainsLineException(result, match); + } + } + } + + public static void FileContains(MSBuildResult result, string filePath, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var text = File.ReadAllText(filePath); + if (text.Contains(match)) + { + return; + } + + throw new FileContentMissingException(result, filePath, File.ReadAllText(filePath), match); + } + + public static void FileDoesNotContain(MSBuildResult result, string filePath, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var text = File.ReadAllText(filePath); + if (text.Contains(match)) + { + throw new FileContentFoundException(result, filePath, File.ReadAllText(filePath), match); + } + } + + public static void FileContentEquals(MSBuildResult result, string filePath, string expected) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var actual = File.ReadAllText(filePath); + if (!actual.Equals(expected, StringComparison.Ordinal)) + { + throw new FileContentNotEqualException(result, filePath, expected, actual); + } + } + + public static void FileContainsLine(MSBuildResult result, string filePath, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var lines = File.ReadAllLines(filePath); + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i].Trim(); + if (line == match) + { + return; + } + } + + throw new FileContentMissingException(result, filePath, File.ReadAllText(filePath), match); + } + + public static void FileDoesNotContainLine(MSBuildResult result, string filePath, string match) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + filePath = Path.Combine(result.Project.DirectoryPath, filePath); + FileExists(result, filePath); + + var lines = File.ReadAllLines(filePath); + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i].Trim(); + if (line == match) + { + throw new FileContentFoundException(result, filePath, File.ReadAllText(filePath), match); + } + } + } + + public static string FileExists(MSBuildResult result, params string[] paths) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + var filePath = Path.Combine(result.Project.DirectoryPath, Path.Combine(paths)); + if (!File.Exists(filePath)) + { + throw new FileMissingException(result, filePath); + } + + return filePath; + } + + public static void FileCountEquals(MSBuildResult result, int expected, string directoryPath, string searchPattern) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (directoryPath == null) + { + throw new ArgumentNullException(nameof(directoryPath)); + } + + if (searchPattern == null) + { + throw new ArgumentNullException(nameof(searchPattern)); + } + + directoryPath = Path.Combine(result.Project.DirectoryPath, directoryPath); + + if (Directory.Exists(directoryPath)) + { + var files = Directory.GetFiles(directoryPath, searchPattern, SearchOption.AllDirectories); + if (files.Length != expected) + { + throw new FileCountException(result, expected, directoryPath, searchPattern, files); + } + } + else if (expected > 0) + { + // directory doesn't exist, that's OK if we expected to find nothing. + throw new FileCountException(result, expected, directoryPath, searchPattern, Array.Empty()); + } + } + + public static void FileDoesNotExist(MSBuildResult result, params string[] paths) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + var filePath = Path.Combine(result.Project.DirectoryPath, Path.Combine(paths)); + if (File.Exists(filePath)) + { + throw new FileFoundException(result, filePath); + } + } + + public static void NuspecContains(MSBuildResult result, string nuspecPath, string expected) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (nuspecPath == null) + { + throw new ArgumentNullException(nameof(nuspecPath)); + } + + if (expected == null) + { + throw new ArgumentNullException(nameof(expected)); + } + + nuspecPath = Path.Combine(result.Project.DirectoryPath, nuspecPath); + FileExists(result, nuspecPath); + + var content = File.ReadAllText(nuspecPath); + if (!content.Contains(expected)) + { + throw new NuspecException(result, nuspecPath, content, expected); + } + } + + public static void NuspecDoesNotContain(MSBuildResult result, string nuspecPath, string expected) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (nuspecPath == null) + { + throw new ArgumentNullException(nameof(nuspecPath)); + } + + if (expected == null) + { + throw new ArgumentNullException(nameof(expected)); + } + + nuspecPath = Path.Combine(result.Project.DirectoryPath, nuspecPath); + FileExists(result, nuspecPath); + + var content = File.ReadAllText(nuspecPath); + if (content.Contains(expected)) + { + throw new NuspecFoundException(result, nuspecPath, content, expected); + } + } + + // This method extracts the nupkg to a fixed directory path. To avoid the extra work of + // cleaning up after each invocation, this method accepts multiple files. + public static void NupkgContains(MSBuildResult result, string nupkgPath, params string[] filePaths) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (nupkgPath == null) + { + throw new ArgumentNullException(nameof(nupkgPath)); + } + + if (filePaths == null) + { + throw new ArgumentNullException(nameof(filePaths)); + } + + nupkgPath = Path.Combine(result.Project.DirectoryPath, nupkgPath); + FileExists(result, nupkgPath); + + var unzipped = Path.Combine(result.Project.DirectoryPath, Path.GetFileNameWithoutExtension(nupkgPath)); + ZipFile.ExtractToDirectory(nupkgPath, unzipped); + + foreach (var filePath in filePaths) + { + if (!File.Exists(Path.Combine(unzipped, filePath))) + { + throw new NupkgFileMissingException(result, nupkgPath, filePath); + } + } + } + + // This method extracts the nupkg to a fixed directory path. To avoid the extra work of + // cleaning up after each invocation, this method accepts multiple files. + public static void NupkgDoesNotContain(MSBuildResult result, string nupkgPath, params string[] filePaths) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (nupkgPath == null) + { + throw new ArgumentNullException(nameof(nupkgPath)); + } + + if (filePaths == null) + { + throw new ArgumentNullException(nameof(filePaths)); + } + + nupkgPath = Path.Combine(result.Project.DirectoryPath, nupkgPath); + FileExists(result, nupkgPath); + + var unzipped = Path.Combine(result.Project.DirectoryPath, Path.GetFileNameWithoutExtension(nupkgPath)); + ZipFile.ExtractToDirectory(nupkgPath, unzipped); + + foreach (var filePath in filePaths) + { + if (File.Exists(Path.Combine(unzipped, filePath))) + { + throw new NupkgFileFoundException(result, nupkgPath, filePath); + } + } + } + + public static void AssemblyContainsType(MSBuildResult result, string assemblyPath, string fullTypeName) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + assemblyPath = Path.Combine(result.Project.DirectoryPath, Path.Combine(assemblyPath)); + + var typeNames = GetDeclaredTypeNames(assemblyPath); + Assert.Contains(fullTypeName, typeNames); + } + + public static void AssemblyDoesNotContainType(MSBuildResult result, string assemblyPath, string fullTypeName) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + assemblyPath = Path.Combine(result.Project.DirectoryPath, Path.Combine(assemblyPath)); + + var typeNames = GetDeclaredTypeNames(assemblyPath); + Assert.DoesNotContain(fullTypeName, typeNames); + } + + private static IEnumerable GetDeclaredTypeNames(string assemblyPath) + { + using (var file = File.OpenRead(assemblyPath)) + { + var peReader = new PEReader(file); + var metadataReader = peReader.GetMetadataReader(); + return metadataReader.TypeDefinitions.Where(t => !t.IsNil).Select(t => + { + var type = metadataReader.GetTypeDefinition(t); + return metadataReader.GetString(type.Namespace) + "." + metadataReader.GetString(type.Name); + }).ToArray(); + } + } + + public static void AssemblyHasAttribute(MSBuildResult result, string assemblyPath, string fullTypeName) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + assemblyPath = Path.Combine(result.Project.DirectoryPath, Path.Combine(assemblyPath)); + + var typeNames = GetAssemblyAttributes(assemblyPath); + Assert.Contains(fullTypeName, typeNames); + } + + private static IEnumerable GetAssemblyAttributes(string assemblyPath) + { + using (var file = File.OpenRead(assemblyPath)) + { + var peReader = new PEReader(file); + var metadataReader = peReader.GetMetadataReader(); + return metadataReader.CustomAttributes.Where(t => !t.IsNil).Select(t => + { + var attribute = metadataReader.GetCustomAttribute(t); + var constructor = metadataReader.GetMemberReference((MemberReferenceHandle)attribute.Constructor); + var type = metadataReader.GetTypeReference((TypeReferenceHandle)constructor.Parent); + + return metadataReader.GetString(type.Namespace) + "." + metadataReader.GetString(type.Name); + }).ToArray(); + } + } + + private abstract class MSBuildXunitException : Xunit.Sdk.XunitException + { + protected MSBuildXunitException(MSBuildResult result) + { + Result = result; + } + + protected abstract string Heading { get; } + + public MSBuildResult Result { get; } + + public override string Message + { + get + { + var message = new StringBuilder(); + message.AppendLine(Heading); + message.Append(Result.FileName); + message.Append(" "); + message.Append(Result.Arguments); + message.AppendLine(); + message.AppendLine(); + message.Append(Result.Output); + message.AppendLine(); + message.Append("Exit Code:"); + message.Append(Result.ExitCode); + return message.ToString(); + } + } + } + + private class BuildErrorMissingException : MSBuildXunitException + { + public BuildErrorMissingException(MSBuildResult result, string errorCode, string location) + : base(result) + { + ErrorCode = errorCode; + Location = location; + } + + public string ErrorCode { get; } + + public string Location { get; } + + protected override string Heading + { + get + { + return + $"Error code '{ErrorCode}' was not found." + Environment.NewLine + + $"Looking for '{Location ?? ".*"}: error {ErrorCode}: .*'"; + } + } + } + + private class BuildFailedException : MSBuildXunitException + { + public BuildFailedException(MSBuildResult result) + : base(result) + { + } + + protected override string Heading => "Build failed."; + } + + private class BuildWarningsException : MSBuildXunitException + { + public BuildWarningsException(MSBuildResult result, IEnumerable warnings) + : base(result) + { + Warnings = warnings.ToList(); + } + + public List Warnings { get; } + + protected override string Heading => "Build contains unexpected warnings: " + string.Join(Environment.NewLine, Warnings); + } + + private class BuildPassedException : MSBuildXunitException + { + public BuildPassedException(MSBuildResult result) + : base(result) + { + } + + protected override string Heading => "Build should have failed, but it passed."; + } + + private class BuildOutputMissingException : MSBuildXunitException + { + public BuildOutputMissingException(MSBuildResult result, string match) + : base(result) + { + Match = match; + } + + public string Match { get; } + + protected override string Heading => $"Build did not contain the line: '{Match}'."; + } + + private class BuildOutputContainsLineException : MSBuildXunitException + { + public BuildOutputContainsLineException(MSBuildResult result, string match) + : base(result) + { + Match = match; + } + + public string Match { get; } + + protected override string Heading => $"Build output contains the line: '{Match}'."; + } + + private class FileContentFoundException : MSBuildXunitException + { + public FileContentFoundException(MSBuildResult result, string filePath, string content, string match) + : base(result) + { + FilePath = filePath; + Content = content; + Match = match; + } + + public string Content { get; } + + public string FilePath { get; } + + public string Match { get; } + + protected override string Heading + { + get + { + var builder = new StringBuilder(); + builder.AppendFormat("File content of '{0}' should not contain line: '{1}'.", FilePath, Match); + builder.AppendLine(); + builder.AppendLine(); + builder.AppendLine(Content); + return builder.ToString(); + } + } + } + + private class FileContentMissingException : MSBuildXunitException + { + public FileContentMissingException(MSBuildResult result, string filePath, string content, string match) + : base(result) + { + FilePath = filePath; + Content = content; + Match = match; + } + + public string Content { get; } + + public string FilePath { get; } + + public string Match { get; } + + protected override string Heading + { + get + { + var builder = new StringBuilder(); + builder.AppendFormat("File content of '{0}' did not contain the line: '{1}'.", FilePath, Match); + builder.AppendLine(); + builder.AppendLine(); + builder.AppendLine(Content); + return builder.ToString(); + } + } + } + + private class FileContentNotEqualException : MSBuildXunitException + { + public FileContentNotEqualException(MSBuildResult result, string filePath, string expected, string actual) + : base(result) + { + FilePath = filePath; + Expected = expected; + Actual = actual; + } + + public string Actual { get; } + + public string FilePath { get; } + + public string Expected { get; } + + protected override string Heading + { + get + { + var builder = new StringBuilder(); + builder.AppendFormat("File content of '{0}' did not match the expected content: '{1}'.", FilePath, Expected); + builder.AppendLine(); + builder.AppendLine(); + builder.AppendLine(Actual); + return builder.ToString(); + } + } + } + + private class FileMissingException : MSBuildXunitException + { + public FileMissingException(MSBuildResult result, string filePath) + : base(result) + { + FilePath = filePath; + } + + public string FilePath { get; } + + protected override string Heading => $"File: '{FilePath}' was not found."; + } + + private class FileCountException : MSBuildXunitException + { + public FileCountException(MSBuildResult result, int expected, string directoryPath, string searchPattern, string[] files) + : base(result) + { + Expected = expected; + DirectoryPath = directoryPath; + SearchPattern = searchPattern; + Files = files; + } + + public string DirectoryPath { get; } + + public int Expected { get; } + + public string[] Files { get; } + + public string SearchPattern { get; } + + protected override string Heading + { + get + { + var heading = new StringBuilder(); + heading.AppendLine($"Expected {Expected} files matching {SearchPattern} in {DirectoryPath}, found {Files.Length}."); + + if (Files.Length > 0) + { + heading.AppendLine("Files:"); + + foreach (var file in Files) + { + heading.Append("\t"); + heading.Append(file); + } + + heading.AppendLine(); + } + + return heading.ToString(); + } + } + } + + private class FileFoundException : MSBuildXunitException + { + public FileFoundException(MSBuildResult result, string filePath) + : base(result) + { + FilePath = filePath; + } + + public string FilePath { get; } + + protected override string Heading => $"File: '{FilePath}' was found, but should not exist."; + } + + private class NuspecException : MSBuildXunitException + { + public NuspecException(MSBuildResult result, string filePath, string content, string expected) + : base(result) + { + FilePath = filePath; + Content = content; + Expected = expected; + } + + public string Content { get; } + + public string Expected { get; } + + public string FilePath { get; } + + protected override string Heading + { + get + { + return + $"nuspec: '{FilePath}' did not contain the expected content." + Environment.NewLine + + Environment.NewLine + + $"expected: {Expected}" + Environment.NewLine + + Environment.NewLine + + $"actual: {Content}"; + } + } + } + + private class NuspecFoundException : MSBuildXunitException + { + public NuspecFoundException(MSBuildResult result, string filePath, string content, string expected) + : base(result) + { + FilePath = filePath; + Content = content; + Expected = expected; + } + + public string Content { get; } + + public string Expected { get; } + + public string FilePath { get; } + + protected override string Heading + { + get + { + return + $"nuspec: '{FilePath}' should not contain the content {Expected}." + + Environment.NewLine + + $"actual content: {Content}"; + } + } + } + + private class NupkgFileMissingException : MSBuildXunitException + { + public NupkgFileMissingException(MSBuildResult result, string nupkgPath, string filePath) + : base(result) + { + NupkgPath = nupkgPath; + FilePath = filePath; + } + + public string FilePath { get; } + + public string NupkgPath { get; } + + protected override string Heading => $"File: '{FilePath}' was not found was not found in {NupkgPath}."; + } + + private class NupkgFileFoundException : MSBuildXunitException + { + public NupkgFileFoundException(MSBuildResult result, string nupkgPath, string filePath) + : base(result) + { + NupkgPath = nupkgPath; + FilePath = filePath; + } + + public string FilePath { get; } + + public string NupkgPath { get; } + + protected override string Heading => $"File: '{FilePath}' was found in {NupkgPath}."; + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs new file mode 100644 index 0000000000..d9a4cfc8e9 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs @@ -0,0 +1,360 @@ +// 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.Runtime.InteropServices; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildIncrementalismTest : MSBuildIntegrationTestBase, IClassFixture + { + public BuildIncrementalismTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Linux, SkipReason = "See https://github.com/aspnet/Razor/issues/2219")] + [InitializeTestProject("SimpleMvc")] + public async Task BuildIncremental_SimpleMvc_PersistsTargetInputFile() + { + // Arrange + var thumbprintLookup = new Dictionary(); + + // Act 1 + var result = await DotnetMSBuild("Build"); + + var directoryPath = Path.Combine(result.Project.DirectoryPath, IntermediateOutputPath); + var filesToIgnore = new[] + { + // These files are generated on every build. + Path.Combine(directoryPath, "SimpleMvc.csproj.CopyComplete"), + Path.Combine(directoryPath, "SimpleMvc.csproj.FileListAbsolute.txt"), + }; + + var files = Directory.GetFiles(directoryPath).Where(p => !filesToIgnore.Contains(p)); + foreach (var file in files) + { + var thumbprint = GetThumbPrint(file); + thumbprintLookup[file] = thumbprint; + } + + // Assert 1 + Assert.BuildPassed(result); + + // Act & Assert 2 + for (var i = 0; i < 2; i++) + { + // We want to make sure nothing changed between multiple incremental builds. + using (var razorGenDirectoryLock = LockDirectory(RazorIntermediateOutputPath)) + { + result = await DotnetMSBuild("Build"); + } + + Assert.BuildPassed(result); + foreach (var file in files) + { + var thumbprint = GetThumbPrint(file); + Assert.Equal(thumbprintLookup[file], thumbprint); + } + } + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorGenerate_RegeneratesTagHelperInputs_IfFileChanges() + { + // Act - 1 + var expectedTagHelperCacheContent = @"""Name"":""SimpleMvc.SimpleTagHelper"""; + var result = await DotnetMSBuild("Build"); + var file = Path.Combine(Project.DirectoryPath, "SimpleTagHelper.cs"); + var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); + var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs"); + + // Assert - 1 + Assert.BuildPassed(result); + Assert.FileContains(result, tagHelperOutputCache, expectedTagHelperCacheContent); + var fileThumbPrint = GetThumbPrint(generatedFile); + + // Act - 2 + // Update the source content and build. We should expect the outputs to be regenerated. + ReplaceContent(string.Empty, file); + result = await DotnetMSBuild("Build"); + + // Assert - 2 + Assert.BuildPassed(result); + Assert.FileDoesNotContain(result, tagHelperOutputCache, @"""Name"":""SimpleMvc.SimpleTagHelper"""); + var newThumbPrint = GetThumbPrint(generatedFile); + Assert.NotEqual(fileThumbPrint, newThumbPrint); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_ErrorInGeneratedCode_ReportsMSBuildError_OnIncrementalBuild() + { + // Introducing a Razor semantic error + ReplaceContent("@{ // Unterminated code block", "Views", "Home", "Index.cshtml"); + + // Regular build + await VerifyError(); + + // Incremental build + await VerifyError(); + + async Task VerifyError() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildFailed(result); + + // This needs to be relative path. Tracked by https://github.com/aspnet/Razor/issues/2187. + var filePath = Path.Combine(Project.DirectoryPath, "Views", "Home", "Index.cshtml"); + var location = filePath + "(1,2)"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Absolute paths on OSX don't work well. + location = null; + } + + Assert.BuildError(result, "RZ1006", location: location); + + // Compilation failed without creating the views assembly + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + + // File with error does not get written to disk. + Assert.FileDoesNotExist(result, IntermediateOutputPath, "Razor", "Views", "Home", "Index.cshtml.g.cs"); + } + } + + [Fact] + [InitializeTestProject("MvcWithComponents")] + public async Task BuildComponents_ErrorInGeneratedCode_ReportsMSBuildError_OnIncrementalBuild() + { + // Introducing a Razor semantic error + ReplaceContent("@{ // Unterminated code block", "Views", "Shared", "NavMenu.razor"); + + // Regular build + await VerifyError(); + + // Incremental build + await VerifyError(); + + async Task VerifyError() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildFailed(result); + + // This needs to be relative path. Tracked by https://github.com/aspnet/Razor/issues/2187. + var filePath = Path.Combine(Project.DirectoryPath, "Views", "Shared", "NavMenu.razor"); + var location = filePath + "(1,2)"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Absolute paths on OSX don't work well. + location = null; + } + + Assert.BuildError(result, "RZ1006", location: location); + + // Compilation failed without creating the views assembly + Assert.FileDoesNotExist(result, IntermediateOutputPath, "MvcWithComponents.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "MvcWithComponents.Views.dll"); + + // File with error does not get written to disk. + Assert.FileDoesNotExist(result, IntermediateOutputPath, "RazorComponents", "Views", "Shared", "NavMenu.razor.g.cs"); + } + } + + [Fact] + [InitializeTestProject("MvcWithComponents")] + public async Task BuildComponents_RegeneratesComponentDefinition_WhenFilesChange() + { + // Act - 1 + var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "MvcWithComponents.TagHelpers.output.cache"); + + var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Shared", "NavMenu.razor.g.cs"); + var generatedDefinitionFile = Path.Combine(RazorComponentIntermediateOutputPath, "Views", "Shared", "NavMenu.razor.g.cs"); + + // Assert - 1 + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + var outputFile = Path.Combine(OutputPath, "MvcWithComponents.dll"); + Assert.FileExists(result, OutputPath, "MvcWithComponents.dll"); + var outputAssemblyThumbprint = GetThumbPrint(outputFile); + + Assert.FileExists(result, generatedDefinitionFile); + var generatedDefinitionThumbprint = GetThumbPrint(generatedDefinitionFile); + Assert.FileExists(result, generatedFile); + var generatedFileThumbprint = GetThumbPrint(generatedFile); + + Assert.FileExists(result, tagHelperOutputCache); + Assert.FileContains( + result, + tagHelperOutputCache, + @"""Name"":""MvcWithComponents.Views.Shared.NavMenu"""); + + var definitionThumbprint = GetThumbPrint(tagHelperOutputCache); + + // Act - 2 + ReplaceContent("Different things", "Views", "Shared", "NavMenu.razor"); + result = await DotnetMSBuild("Build"); + + // Assert - 2 + Assert.FileExists(result, OutputPath, "MvcWithComponents.dll"); + Assert.NotEqual(outputAssemblyThumbprint, GetThumbPrint(outputFile)); + + Assert.FileExists(result, generatedDefinitionFile); + Assert.NotEqual(generatedDefinitionThumbprint, GetThumbPrint(generatedDefinitionFile)); + Assert.FileExists(result, generatedFile); + Assert.NotEqual(generatedFileThumbprint, GetThumbPrint(generatedFile)); + + Assert.FileExists(result, tagHelperOutputCache); + Assert.FileContains( + result, + tagHelperOutputCache, + @"""Name"":""MvcWithComponents.Views.Shared.NavMenu"""); + + // TODO: + Assert.Equal(definitionThumbprint, GetThumbPrint(tagHelperOutputCache)); + } + + [Fact] + [InitializeTestProject("MvcWithComponents")] + public async Task BuildComponents_DoesNotModifyFiles_IfFilesDoNotChange() + { + // Act - 1 + var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "MvcWithComponents.TagHelpers.output.cache"); + + var file = Path.Combine(Project.DirectoryPath, "Views", "Shared", "NavMenu.razor.g.cs"); + var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Shared", "NavMenu.razor.g.cs"); + var generatedDefinitionFile = Path.Combine(RazorComponentIntermediateOutputPath, "Views", "Shared", "NavMenu.razor.g.cs"); + + // Assert - 1 + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + var outputFile = Path.Combine(OutputPath, "MvcWithComponents.dll"); + Assert.FileExists(result, OutputPath, "MvcWithComponents.dll"); + var outputAssemblyThumbprint = GetThumbPrint(outputFile); + + Assert.FileExists(result, generatedDefinitionFile); + var generatedDefinitionThumbprint = GetThumbPrint(generatedDefinitionFile); + Assert.FileExists(result, generatedFile); + var generatedFileThumbprint = GetThumbPrint(generatedFile); + + Assert.FileExists(result, tagHelperOutputCache); + Assert.FileContains( + result, + tagHelperOutputCache, + @"""Name"":""MvcWithComponents.Views.Shared.NavMenu"""); + + var definitionThumbprint = GetThumbPrint(tagHelperOutputCache); + + // Act - 2 + result = await DotnetMSBuild("Build"); + + // Assert - 2 + Assert.FileExists(result, OutputPath, "MvcWithComponents.dll"); + Assert.Equal(outputAssemblyThumbprint, GetThumbPrint(outputFile)); + + Assert.FileExists(result, generatedDefinitionFile); + Assert.Equal(generatedDefinitionThumbprint, GetThumbPrint(generatedDefinitionFile)); + Assert.FileExists(result, generatedFile); + Assert.Equal(generatedFileThumbprint, GetThumbPrint(generatedFile)); + + Assert.FileExists(result, tagHelperOutputCache); + Assert.FileContains( + result, + tagHelperOutputCache, + @"""Name"":""MvcWithComponents.Views.Shared.NavMenu"""); + + Assert.Equal(definitionThumbprint, GetThumbPrint(tagHelperOutputCache)); + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public async Task IncrementalBuild_WithP2P_WorksWhenBuildProjectReferencesIsDisabled() + { + // Simulates building the same way VS does by setting BuildProjectReferences=false. + // With this flag, the only target called is GetCopyToOutputDirectoryItems on the referenced project. + // We need to ensure that we continue providing Razor binaries and symbols as files to be copied over. + var result = await DotnetMSBuild(target: default); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.pdb"); + + result = await DotnetMSBuild(target: "Clean", "/p:BuildProjectReferences=false"); + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.dll"); + Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.dll"); + Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.pdb"); + + // dotnet msbuild /p:BuildProjectReferences=false + result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.pdb"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_TouchesUpToDateMarkerFile() + { + var classLibraryDll = Path.Combine(IntermediateOutputPath, "ClassLibrary.dll"); + var classLibraryViewsDll = Path.Combine(IntermediateOutputPath, "ClassLibrary.Views.dll"); + var markerFile = Path.Combine(IntermediateOutputPath, "ClassLibrary.csproj.CopyComplete"); + + var result = await DotnetMSBuild("Build"); + Assert.BuildPassed(result); + + Assert.FileExists(result, classLibraryDll); + Assert.FileExists(result, classLibraryViewsDll); + Assert.FileExists(result, markerFile); + + // Gather thumbprints before incremental build. + var classLibraryThumbPrint = GetThumbPrint(classLibraryDll); + var classLibraryViewsThumbPrint = GetThumbPrint(classLibraryViewsDll); + var markerFileThumbPrint = GetThumbPrint(markerFile); + + result = await DotnetMSBuild("Build"); + Assert.BuildPassed(result); + + // Verify thumbprint file is unchanged between true incremental builds + Assert.Equal(classLibraryThumbPrint, GetThumbPrint(classLibraryDll)); + Assert.Equal(classLibraryViewsThumbPrint, GetThumbPrint(classLibraryViewsDll)); + // In practice, this should remain unchanged. However, since our tests reference + // binaries from other projects, this file gets updated by Microsoft.Common.targets + Assert.NotEqual(markerFileThumbPrint, GetThumbPrint(markerFile)); + + // Change a cshtml file and verify ClassLibrary.Views.dll and marker file are updated + File.AppendAllText(Path.Combine(Project.DirectoryPath, "Views", "_ViewImports.cshtml"), Environment.NewLine); + + result = await DotnetMSBuild("Build"); + Assert.BuildPassed(result); + + Assert.Equal(classLibraryThumbPrint, GetThumbPrint(classLibraryDll)); + Assert.NotEqual(classLibraryViewsThumbPrint, GetThumbPrint(classLibraryViewsDll)); + Assert.NotEqual(markerFileThumbPrint, GetThumbPrint(markerFile)); + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs new file mode 100644 index 0000000000..598f21c93b --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs @@ -0,0 +1,741 @@ +// 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.Linq; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Testing; +using Microsoft.Extensions.DependencyModel; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildIntegrationTest : MSBuildIntegrationTestBase, IClassFixture + { + public BuildIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public Task Build_SimpleMvc_UsingDotnetMSBuildAndWithoutBuildServer_CanBuildSuccessfully() + => Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind.Dotnet); + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject("SimpleMvc")] + public Task Build_SimpleMvc_UsingDesktopMSBuildAndWithoutBuildServer_CanBuildSuccessfully() + => Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind.Desktop); + + // This test is identical to the ones in BuildServerIntegrationTest except this one explicitly disables the Razor build server. + private async Task Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) + { + var result = await DotnetMSBuild("Build", + "/p:UseRazorBuildServer=false", + suppressBuildServer: true, + msBuildProcessKind: msBuildProcessKind); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc.pdb"); + Assert.FileExists(result, OutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc.Views.pdb"); + + if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // GetFullPath on OSX doesn't work well in travis. We end up computing a different path than will + // end up in the MSBuild logs. + Assert.BuildOutputContainsLine(result, $"SimpleMvc -> {Path.Combine(Path.GetFullPath(Project.DirectoryPath), OutputPath, "SimpleMvc.Views.dll")}"); + } + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_SimpleMvc_NoopsWithNoFiles() + { + Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); + + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_SimpleMvc_NoopsWithRazorCompileOnBuild_False() + { + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_ErrorInGeneratedCode_ReportsMSBuildError() + { + // Introducing a C# semantic error + ReplaceContent("@{ var foo = \"\".Substring(\"bleh\"); }", "Views", "Home", "Index.cshtml"); + + var result = await DotnetMSBuild("Build"); + + Assert.BuildFailed(result); + + // Verifying that the error correctly gets mapped to the original source + Assert.BuildError(result, "CS1503", location: Path.Combine("Views", "Home", "Index.cshtml") + "(1,27)"); + + // Compilation failed without creating the views assembly + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + } + + [Fact] + [InitializeTestProject("SimplePages")] + public async Task Build_Works_WhenFilesAtDifferentPathsHaveSameNamespaceHierarchy() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimplePages.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimplePages.Views.dll"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_RazorOutputPath_SetToNonDefault() + { + var customOutputPath = Path.Combine("bin", Configuration, TargetFramework, "Razor"); + var result = await DotnetMSBuild("Build", $"/p:RazorOutputPath={customOutputPath}"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, customOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, customOutputPath, "SimpleMvc.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_MvcRazorOutputPath_SetToNonDefault() + { + var customOutputPath = Path.Combine("bin", Configuration, TargetFramework, "Razor"); + var result = await DotnetMSBuild("Build", $"/p:MvcRazorOutputPath={customOutputPath}"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, customOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, customOutputPath, "SimpleMvc.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyBuildOutputToOutputDirectory_IsUnset() + { + var result = await DotnetMSBuild("Build", "/p:CopyBuildOutputToOutputDirectory=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyOutputSymbolsToOutputDirectory_IsUnset() + { + var result = await DotnetMSBuild("Build", "/p:CopyOutputSymbolsToOutputDirectory=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, OutputPath, "SimpleMvc.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_Works_WhenSymbolsAreNotGenerated() + { + var result = await DotnetMSBuild("Build", "/p:DebugType=none"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, OutputPath, "SimpleMvc.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] + public async Task Build_WithP2P_CopiesRazorAssembly() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.pdb"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.pdb"); + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.pdb"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimplePages", additionalProjects: "LinkedDir")] + public async Task Build_SetsUpEmbeddedResourcesWithLogicalName() + { + // Arrange + var additionalProjectContent = @" + + + +"; + AddProjectFileContent(additionalProjectContent); + Directory.CreateDirectory(Path.Combine(Project.DirectoryPath, "..", "LinkedDir")); + + var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorEmbeddedResources /p:EmbedRazorGenerateSources=true"); + + Assert.BuildPassed(result); + + Assert.BuildOutputContainsLine(result, $@"CompileResource: {Path.Combine("Pages", "Index.cshtml")} /Pages/Index.cshtml"); + Assert.BuildOutputContainsLine(result, $@"CompileResource: {Path.Combine("Areas", "Products", "Pages", "_ViewStart.cshtml")} /Areas/Products/Pages/_ViewStart.cshtml"); + Assert.BuildOutputContainsLine(result, $@"CompileResource: {Path.Combine("..", "LinkedDir", "LinkedFile.cshtml")} /LinkedFileOut/LinkedFile.cshtml"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithViews_ProducesDepsFileWithCompilationContext_ButNoReferences() + { + var customDefine = "RazorSdkTest"; + var result = await DotnetMSBuild("Build", $"/p:DefineConstants={customDefine}"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "SimpleMvc.deps.json"); + var depsFilePath = Path.Combine(Project.DirectoryPath, OutputPath, "SimpleMvc.deps.json"); + var dependencyContext = ReadDependencyContext(depsFilePath); + + // Pick a couple of libraries and ensure they have some compile references + var packageReference = dependencyContext.CompileLibraries.First(l => l.Name == "System.Diagnostics.DiagnosticSource"); + Assert.NotEmpty(packageReference.Assemblies); + + var projectReference = dependencyContext.CompileLibraries.First(l => l.Name == "SimpleMvc"); + Assert.NotEmpty(projectReference.Assemblies); + + Assert.Contains(customDefine, dependencyContext.CompilationOptions.Defines); + + // Verify no refs folder is produced + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithPreserveCompilationReferencesEnabled_ProducesRefsDirectory() + { + // This simulates the behavior of 3.0 with RuntimeCompilation enabled + AddProjectFileContent(@" + + true + "); + + var result = await DotnetMSBuild("Build"); + + // Verify no refs folder is produced + Assert.FileExists(result, OutputPath, "refs", "mscorlib.dll"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_CodeGensAssemblyInfoUsingValuesFromProject() + { + var razorAssemblyInfoPath = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfoPath); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyCopyrightAttribute(\"© Microsoft\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyProductAttribute(\"Razor Test\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyCompanyAttribute(\"Microsoft\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyTitleAttribute(\"ClassLibrary.Views\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyVersionAttribute(\"1.0.0.0\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyFileVersionAttribute(\"1.0.0.0\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyInformationalVersionAttribute(\"1.0.0\")]"); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyDescriptionAttribute(\"ClassLibrary Description\")]"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_UsesRazorSpecificAssemblyProperties() + { + var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs"); + var buildArguments = "/p:RazorAssemblyFileVersion=2.0.0.100 /p:RazorAssemblyInformationalVersion=2.0.0-preview " + + "/p:RazorAssemblyTitle=MyRazorViews /p:RazorAssemblyVersion=2.0.0 " + + "/p:RazorAssemblyDescription=MyRazorDescription"; + var result = await DotnetMSBuild("Build", buildArguments); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorTargetAssemblyInfo); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyDescriptionAttribute(\"MyRazorDescription\")]"); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyTitleAttribute(\"MyRazorViews\")]"); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyVersionAttribute(\"2.0.0\")]"); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyFileVersionAttribute(\"2.0.0.100\")]"); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyInformationalVersionAttribute(\"2.0.0-preview\")]"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_DoesNotGenerateAssemblyInfo_IfGenerateRazorTargetAssemblyInfo_IsSetToFalse() + { + var result = await DotnetMSBuild("Build", "/p:GenerateRazorTargetAssemblyInfo=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_AddsApplicationPartAttributes() + { + var razorAssemblyInfoPath = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfoPath); + Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]"); + + Assert.FileExists(result, razorTargetAssemblyInfo); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyTitleAttribute(\"SimpleMvc.Views\")]"); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\""); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_AddsApplicationPartAttributes_WhenEnableDefaultRazorTargetAssemblyInfoAttributes_IsFalse() + { + var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:EnableDefaultRazorTargetAssemblyInfoAttributes=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"); + Assert.FileExists(result, razorTargetAssemblyInfo); + Assert.FileDoesNotContain(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyTitleAttribute"); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\""); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_UsesSpecifiedApplicationPartFactoryTypeName() + { + var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:ProvideApplicationPartFactoryAttributeTypeName=CustomFactory"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorTargetAssemblyInfo); + Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"CustomFactory\""); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_DoesNotGenerateProvideApplicationPartFactoryAttribute_IfGenerateProvideApplicationPartFactoryAttributeIsUnset() + { + var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateProvideApplicationPartFactoryAttribute=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorTargetAssemblyInfo); + Assert.FileDoesNotContain(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_DoesNotAddRelatedAssemblyPart_IfViewCompilationIsDisabled() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false /p:RazorCompileOnPublish=false"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, razorAssemblyInfo); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_AddsRelatedAssemblyPart_IfCompileOnPublishIsAllowed() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]"); + + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_AddsRelatedAssemblyPart_IfGenerateAssemblyInfoIsFalse() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateAssemblyInfo=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithGenerateRazorHostingAssemblyInfoFalse_DoesNotGenerateHostingAttributes() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorHostingAssemblyInfo=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute"); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute"); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute"); + Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_DoesNotGenerateHostingAttributes_InClassLibraryProjects() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs"); + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute"); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute"); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_GeneratesHostingAttributes_WhenGenerateRazorHostingAssemblyInfoIsSet() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorHostingAssemblyInfo=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute"); + Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute"); + } + + [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/13303")] + [InitializeTestProject("SimpleMvcFSharp", language: "F#")] + public async Task Build_SimpleMvcFSharp_NoopsWithoutFailing() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "SimpleMvcFSharp.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvcFSharp.pdb"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvcFSharp.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvcFSharp.pdb"); + + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.pdb"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvcFSharp.RazorAssemblyInfo.cs"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvcFSharp.RazorAssemblyInfo.fs"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithGenerateRazorAssemblyInfo_False_DoesNotGenerateAssemblyInfo() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorAssemblyInfo=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileDoesNotExist(result, razorAssemblyInfo); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithGenerateRazorTargetAssemblyInfo_False_DoesNotGenerateAssemblyInfo() + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs"); + var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorTargetAssemblyInfo=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileDoesNotExist(result, razorTargetAssemblyInfo); + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: new[] { "ClassLibrary", "ClassLibrary2" })] + public async Task Build_WithP2P_WorksWhenBuildProjectReferencesIsDisabled() + { + // Simulates building the same way VS does by setting BuildProjectReferences=false. + // With this flag, P2P references aren't resolved during GetCopyToOutputDirectoryItems. This test ensures that + // no Razor work is done in such a scenario and the build succeeds. + var additionalProjectContent = @" + + + +"; + AddProjectFileContent(additionalProjectContent); + + var result = await DotnetMSBuild(target: default); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary2.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary2.Views.dll"); + + // Force a rebuild of ClassLibrary2 by changing a file + var class2Path = Path.Combine(Project.SolutionPath, "ClassLibrary2", "Class2.cs"); + File.AppendAllText(class2Path, Environment.NewLine + "// Some changes"); + + // dotnet msbuild /p:BuildProjectReferences=false + result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false"); + + Assert.BuildPassed(result); + } + + [Fact] + [InitializeTestProject("AppWithP2PReference", additionalProjects: new[] { "ClassLibrary", "ClassLibraryMvc21" })] + public async Task Build_WithP2P_Referencing21Project_Works() + { + // Verifies building with different versions of Razor.Tasks works. Loosely modeled after the repro + // scenario listed in https://github.com/Microsoft/msbuild/issues/3572 + var additionalProjectContent = @" + + + +"; + AddProjectFileContent(additionalProjectContent); + + var result = await DotnetMSBuild(target: default); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll"); + Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + Assert.FileExists(result, OutputPath, "ClassLibraryMvc21.dll"); + Assert.FileExists(result, OutputPath, "ClassLibraryMvc21.Views.dll"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithStartupObjectSpecified_Works() + { + var result = await DotnetMSBuild("Build", $"/p:StartupObject=SimpleMvc.Program"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithDeterministicFlagSet_OutputsDeterministicViewsAssembly() + { + // Build 1 + var result = await DotnetMSBuild("Build", $"/p:Deterministic=true"); + + Assert.BuildPassed(result); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + var filePath = Path.Combine(result.Project.DirectoryPath, IntermediateOutputPath, "SimpleMvc.Views.dll"); + var firstAssemblyBytes = File.ReadAllBytes(filePath); + + // Build 2 + result = await DotnetMSBuild("Rebuild", $"/p:Deterministic=true"); + + Assert.BuildPassed(result); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + var secondAssemblyBytes = File.ReadAllBytes(filePath); + + Assert.Equal(firstAssemblyBytes, secondAssemblyBytes); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithoutServer_ErrorDuringBuild_DisplaysErrorInMsBuildOutput() + { + var result = await DotnetMSBuild( + "Build", + "/p:UseRazorBuildServer=false /p:RazorLangVersion=5.0", + suppressBuildServer: true); + + Assert.BuildFailed(result); + Assert.BuildOutputContainsLine( + result, + $"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}."); + + // Compilation failed without creating the views assembly + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + } + + [Fact(Skip = "Default C# version is 7.3 for netcoreapp3.1 and later https://github.com/dotnet/aspnetcore/issues/13930")] + [InitializeTestProject("SimpleMvc")] + public async Task Build_ImplicitCSharp8_NullableEnforcement_WarningsDuringBuild_NoBuildServer() + { + var result = await DotnetMSBuild( + "Build", + // Remove /p:LangVersion=Default once we've picked up a compiler that supports .NET 5.0. + // Tracked by https://github.com/dotnet/aspnetcore/issues/13304 + "/p:Nullable=enable /p:LangVersion=Default", + suppressBuildServer: true); + var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs"); + + Assert.BuildPassed(result, allowWarnings: true); + Assert.BuildWarning(result, "CS8618"); + Assert.FileContainsLine(result, indexFilePath, "#nullable restore"); + Assert.FileContainsLine(result, indexFilePath, "#nullable disable"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_ExplicitCSharp73_NullableEnforcement_Disabled_NoNullableFeature_NoBuildServer() + { + var result = await DotnetMSBuild( + "Build", + "/p:LangVersion=7.3", + suppressBuildServer: true); + var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs"); + + Assert.BuildPassed(result, allowWarnings: false); + Assert.FileDoesNotContainLine(result, indexFilePath, "#nullable restore"); + Assert.FileDoesNotContainLine(result, indexFilePath, "#nullable disable"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_ExplicitCSharp8_NullableEnforcement_WarningsDuringBuild_BuildServer() + { + var result = await DotnetMSBuild( + "Build", + "/p:LangVersion=8.0 /p:Nullable=enable"); + var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs"); + + Assert.BuildPassed(result, allowWarnings: true); + Assert.BuildWarning(result, "CS8618"); + Assert.FileContainsLine(result, indexFilePath, "#nullable restore"); + Assert.FileContainsLine(result, indexFilePath, "#nullable disable"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_CSharp8_NullableEnforcement_WarningsDuringBuild_NoBuildServer() + { + var result = await DotnetMSBuild( + "Build", + "/p:LangVersion=8.0 /p:Nullable=enable", + suppressBuildServer: true); + var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs"); + + Assert.BuildPassed(result, allowWarnings: true); + Assert.BuildWarning(result, "CS8618"); + Assert.FileContainsLine(result, indexFilePath, "#nullable restore"); + Assert.FileContainsLine(result, indexFilePath, "#nullable disable"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_Mvc_WithoutAddRazorSupportForMvc() + { + var result = await DotnetMSBuild( + "Build", + "/p:AddRazorSupportForMvc=false", + suppressBuildServer: true); + + Assert.BuildWarning(result, "RAZORSDK1004"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Build_WithNoResolvedRazorConfiguration() + { +AddProjectFileContent(@" + + Custom12.3 +"); + + var result = await DotnetMSBuild("Build"); + + Assert.BuildWarning(result, "RAZORSDK1000"); + } + + private static DependencyContext ReadDependencyContext(string depsFilePath) + { + var reader = new DependencyContextJsonReader(); + using (var stream = File.OpenRead(depsFilePath)) + { + return reader.Read(stream); + } + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest11.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest11.cs new file mode 100644 index 0000000000..eb15dbb44a --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest11.cs @@ -0,0 +1,58 @@ +// 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.Threading.Tasks; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildIntegrationTest11 : MSBuildIntegrationTestBase, IClassFixture + { + public BuildIntegrationTest11(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + + [Fact] + [InitializeTestProject("SimpleMvc11")] + public async Task RazorSdk_DoesNotAddCoreRazorConfigurationTo11Projects() + { + var result = await DotnetMSBuild("_IntrospectProjectCapabilityItems"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "ProjectCapability: DotNetCoreRazor"); + Assert.BuildOutputDoesNotContainLine(result, "ProjectCapability: DotNetCoreRazorConfiguration"); + } + + [Fact] + [InitializeTestProject("SimpleMvc11")] + public async Task RazorSdk_DoesNotBuildViewsForNetCoreApp11Projects() + { + MSBuildIntegrationTestBase.TargetFramework = "netcoreapp1.1"; + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result, allowWarnings: true); + Assert.FileExists(result, OutputPath, "SimpleMvc11.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc11.pdb"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc11.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc11.Views.pdb"); + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + + [InitializeTestProject("SimpleMvc11NetFx")] + public async Task RazorSdk_DoesNotBuildViewsForNetFx11Projects() + { + MSBuildIntegrationTestBase.TargetFramework = "net461"; + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "SimpleMvc11NetFx.exe"); + Assert.FileExists(result, OutputPath, "SimpleMvc11NetFx.pdb"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc11NetFx.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc11NetFx.Views.pdb"); + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs new file mode 100644 index 0000000000..9b317f0bd0 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs @@ -0,0 +1,42 @@ +// 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.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildIntegrationTest21 : BuildIntegrationTestLegacy + { + public BuildIntegrationTest21(LegacyBuildServerTestFixture buildServer) + : base(buildServer) + { + } + + public override string TestProjectName => "SimpleMvc21"; + public override string TargetFramework => "netcoreapp2.1"; + + [Fact] + public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent() + { + using (var project = CreateTestProject()) + { + AddProjectFileContent(@" + + + MVC-2.1;$(CustomRazorExtension) + +"); + + // Build + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, "SimpleMvc21.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc21.pdb"); + Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb"); + } + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22.cs new file mode 100644 index 0000000000..d857955351 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22.cs @@ -0,0 +1,16 @@ +// 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.Razor.Design.IntegrationTests +{ + public class BuildIntegrationTest22 : BuildIntegrationTestLegacy + { + public BuildIntegrationTest22(LegacyBuildServerTestFixture buildServer) + : base(buildServer) + { + } + + public override string TestProjectName => "SimpleMvc22"; + public override string TargetFramework => "netcoreapp2.2"; + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22NetFx.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22NetFx.cs new file mode 100644 index 0000000000..d2ec513242 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22NetFx.cs @@ -0,0 +1,78 @@ +// 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.Threading.Tasks; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildIntegrationTest22NetFx : + MSBuildIntegrationTestBase, + IClassFixture + { + private const string TestProjectName = "SimpleMvc22NetFx"; + + public BuildIntegrationTest22NetFx(LegacyBuildServerTestFixture buildServer) + : base(buildServer) + { + } + + public string OutputFileName => $"{TestProjectName}.exe"; + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject(TestProjectName)] + public async Task BuildingProject_CopyToOutputDirectoryFiles() + { + TargetFramework = "net461"; + + // Build + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + // No cshtml files should be in the build output directory + Assert.FileCountEquals(result, 0, Path.Combine(OutputPath, "Views"), "*.cshtml"); + + // refs are required for runtime compilation in desktop targeting projects. + Assert.FileCountEquals(result, 97, Path.Combine(OutputPath, "refs"), "*.dll"); + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject(TestProjectName)] + public async Task PublishingProject_CopyToPublishDirectoryItems() + { + TargetFramework = "net461"; + + // Build + var result = await DotnetMSBuild("Publish"); + + Assert.BuildPassed(result); + + // refs shouldn't be produced by default + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll"); + + // Views shouldn't be produced by default + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "Views"), "*.cshtml"); + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject(TestProjectName)] + public async Task Publish_IncludesRefAssemblies_WhenCopyRefAssembliesToPublishDirectoryIsSet() + { + TargetFramework = "net461"; + + // Build + var result = await DotnetMSBuild("Publish", "/p:CopyRefAssembliesToPublishDirectory=true"); + + Assert.BuildPassed(result); + + // refs should be present if CopyRefAssembliesToPublishDirectory is set. + Assert.FileExists(result, PublishOutputPath, "refs", "System.Threading.Tasks.Extensions.dll"); + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTestLegacy.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTestLegacy.cs new file mode 100644 index 0000000000..f72de92966 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTestLegacy.cs @@ -0,0 +1,194 @@ +// 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.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public abstract class BuildIntegrationTestLegacy : + MSBuildIntegrationTestBase, + IClassFixture + { + public abstract string TestProjectName { get; } + public abstract new string TargetFramework { get; } + public virtual string OutputFileName => $"{TestProjectName}.dll"; + + public BuildIntegrationTestLegacy(LegacyBuildServerTestFixture buildServer) + : base(buildServer) + { + } + + protected IDisposable CreateTestProject() + { + Project = ProjectDirectory.Create(TestProjectName, TestProjectName, string.Empty, Array.Empty(), "C#"); + MSBuildIntegrationTestBase.TargetFramework = TargetFramework; + + return new Disposable(); + } + + [Fact] + public virtual async Task Building_Project() + { + using (CreateTestProject()) + { + // Build + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + Assert.FileExists(result, OutputPath, OutputFileName); + Assert.FileExists(result, OutputPath, $"{TestProjectName}.pdb"); + Assert.FileExists(result, OutputPath, $"{TestProjectName}.Views.dll"); + Assert.FileExists(result, OutputPath, $"{TestProjectName}.Views.pdb"); + + // Verify RazorTagHelper works + Assert.FileExists(result, IntermediateOutputPath, $"{TestProjectName}.TagHelpers.input.cache"); + Assert.FileExists(result, IntermediateOutputPath, $"{TestProjectName}.TagHelpers.output.cache"); + Assert.FileContains( + result, + Path.Combine(IntermediateOutputPath, $"{TestProjectName}.TagHelpers.output.cache"), + @"""Name"":""SimpleMvc.SimpleTagHelper"""); + + } + } + + [Fact] + public virtual async Task BuildingProject_CopyToOutputDirectoryFiles() + { + using (CreateTestProject()) + { + // Build + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + // No cshtml files should be in the build output directory + Assert.FileCountEquals(result, 0, Path.Combine(OutputPath, "Views"), "*.cshtml"); + + // For .NET Core projects, no ref assemblies should be present in the output directory. + Assert.FileCountEquals(result, 0, Path.Combine(OutputPath, "refs"), "*.dll"); + } + } + + [Fact] + public virtual async Task Publish_Project() + { + using (CreateTestProject()) + { + var result = await DotnetMSBuild("Publish"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, PublishOutputPath, OutputFileName); + Assert.FileExists(result, PublishOutputPath, $"{TestProjectName}.pdb"); + Assert.FileExists(result, PublishOutputPath, $"{TestProjectName}.Views.dll"); + Assert.FileExists(result, PublishOutputPath, $"{TestProjectName}.Views.pdb"); + + // By default refs and .cshtml files will not be copied on publish + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll"); + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "Views"), "*.cshtml"); + } + } + + [Fact] + public virtual async Task Publish_NoopsWithMvcRazorCompileOnPublish_False() + { + using (CreateTestProject()) + { + var result = await DotnetMSBuild("Publish", "/p:MvcRazorCompileOnPublish=false"); + + Assert.BuildPassed(result); + + // Everything we do should noop - including building the app. + Assert.FileExists(result, PublishOutputPath, OutputFileName); + Assert.FileExists(result, PublishOutputPath, $"{TestProjectName}.pdb"); + Assert.FileDoesNotExist(result, PublishOutputPath, $"{TestProjectName}.Views.dll"); + Assert.FileDoesNotExist(result, PublishOutputPath, $"{TestProjectName}.Views.pdb"); + } + } + + [Fact] // This will use the old precompilation tool, RazorSDK shouldn't get involved. + public virtual async Task Build_WithMvcRazorCompileOnPublish_Noops() + { + using (CreateTestProject()) + { + var result = await DotnetMSBuild("Build", "/p:MvcRazorCompileOnPublish=true"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, OutputFileName); + Assert.FileExists(result, IntermediateOutputPath, OutputFileName); + Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.Views.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.Views.pdb"); + } + } + + [Fact] + public virtual async Task Build_DoesNotAddRelatedAssemblyPart_IfToolSetIsNotRazorSdk() + { + using (CreateTestProject()) + { + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, $"{TestProjectName}.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:RazorCompileToolSet=MvcPrecompilation"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, razorAssemblyInfo); + Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.RazorTargetAssemblyInfo.cs"); + } + } + + [Fact] + public virtual async Task Build_DoesNotPrintsWarnings_IfProjectFileContainsRazorFiles() + { + using (CreateTestProject()) + { + File.WriteAllText(Path.Combine(Project.DirectoryPath, "Index.razor"), "Hello world"); + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + Assert.DoesNotContain("RAZORSDK1005", result.Output); + } + } + + [Fact] + public async Task PublishingProject_CopyToPublishDirectoryItems() + { + using (CreateTestProject()) + { + // Build + var result = await DotnetMSBuild("Publish"); + + Assert.BuildPassed(result); + + // refs shouldn't be produced by default + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll"); + + // Views shouldn't be produced by default + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "Views"), "*.cshtml"); + } + } + + [Fact] + public virtual async Task Publish_IncludesRefAssemblies_WhenCopyRefAssembliesToPublishDirectoryIsSet() + { + using (CreateTestProject()) + { + var result = await DotnetMSBuild("Publish", "/p:CopyRefAssembliesToPublishDirectory=true"); + + Assert.BuildPassed(result); + Assert.FileExists(result, PublishOutputPath, "refs", "System.Threading.Tasks.Extensions.dll"); + } + } + + private class Disposable : IDisposable + { + public void Dispose() + { + Project.Dispose(); + Project = null; + } + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs new file mode 100644 index 0000000000..c28c02c0d3 --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs @@ -0,0 +1,272 @@ +// 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.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildIntrospectionTest : MSBuildIntegrationTestBase, IClassFixture + { + public BuildIntrospectionTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_AddsProjectCapabilities() + { + var result = await DotnetMSBuild("_IntrospectProjectCapabilityItems"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "ProjectCapability: DotNetCoreRazor"); + Assert.BuildOutputContainsLine(result, "ProjectCapability: DotNetCoreRazorConfiguration"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_AddsCshtmlFilesToUpToDateCheckInput() + { + var result = await DotnetMSBuild("_IntrospectUpToDateCheck"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "Home", "Index.cshtml")}"); + Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "_ViewStart.cshtml")}"); + Assert.BuildOutputContainsLine(result, $"UpToDateCheckBuilt: {Path.Combine(IntermediateOutputPath, "SimpleMvc.Views.dll")}"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_AddsGeneratedRazorFilesAndAssemblyInfoToRazorCompile() + { + var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorCompileItems"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "Razor", "Views", "Home", "Index.cshtml.g.cs")}"); + Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs")}"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_UsesUseSharedCompilationToSetDefaultValueOfUseRazorBuildServer() + { + var result = await DotnetMSBuild("Build", "/t:_IntrospectUseRazorBuildServer /p:UseSharedCompilation=false"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "UseRazorBuildServer: false"); + } + + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task GetCopyToOutputDirectoryItems_WhenNoFileIsPresent_ReturnsEmptySequence() + { + var result = await DotnetMSBuild(target: default); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + + result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false"); + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.dll"); + Assert.BuildOutputContainsLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.pdb"); + + // Remove all views from the class library + Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); + + // dotnet msbuild /p:BuildProjectReferences=false + result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false"); + + Assert.BuildOutputDoesNotContainLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.dll"); + Assert.BuildOutputDoesNotContainLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_ResolvesRazorLangVersionTo30ForNetCoreApp30Projects() + { + var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: 3.0"); + Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: MVC-3.0"); + } + + [Fact] + [InitializeTestProject("ComponentLibrary")] + public async Task RazorSdk_ResolvesRazorLangVersionFromValueSpecified() + { + var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: 3.0"); + Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: Default"); + } + + [Fact] + [InitializeTestProject("ComponentLibrary")] + public async Task RazorSdk_ResolvesRazorLangVersionTo21WhenUnspecified() + { + // This is equivalent to not specifying a value for RazorLangVersion + AddProjectFileContent(""); + + var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); + + Assert.BuildPassed(result, allowWarnings: true); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: 2.1"); + // BuildOutputContainsLine matches entire lines, so it's fine to Assert the following. + Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration:"); + } + + [Fact] + [InitializeTestProject("ComponentLibrary")] + public async Task RazorSdk_WithRazorLangVersionLatest() + { + var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration /p:RazorLangVersion=Latest"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: Latest"); + Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: Default"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_ResolvesRazorConfigurationToMvc30() + { + var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: 3.0"); + Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: MVC-3.0"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task UpToDateReloadFileTypes_Default() + { + var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;.cshtml"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task UpToDateReloadFileTypes_WithRuntimeCompilation() + { + AddProjectFileContent( +@" + + $(RazorUpToDateReloadFileTypes.Replace('.cshtml', '')) +"); + + var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task UpToDateReloadFileTypes_WithwWorkAroundRemoved() + { + var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes", "/p:_RazorUpToDateReloadFileTypesAllowWorkaround=false"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;.cshtml"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task UpToDateReloadFileTypes_WithRuntimeCompilationAndWorkaroundRemoved() + { + AddProjectFileContent( +@" + + $(RazorUpToDateReloadFileTypes.Replace('.cshtml', '')) +"); + + var result = await DotnetMSBuild("_IntrospectUpToDateReloadFileTypes", "/p:_RazorUpToDateReloadFileTypesAllowWorkaround=false"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "UpToDateReloadFileTypes: ;.cs;.razor;.resx;"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task IntrospectJsonContentFiles() + { + var result = await DotnetMSBuild("_IntrospectContentItems"); + + Assert.BuildPassed(result); + var launchSettingsPath = Path.Combine("Properties", "launchSettings.json"); + Assert.BuildOutputContainsLine(result, $"Content: {launchSettingsPath} CopyToOutputDirectory=PreserveNewest CopyToPublishDirectory=Never ExcludeFromSingleFile=true"); + Assert.BuildOutputContainsLine(result, "Content: appsettings.json CopyToOutputDirectory=PreserveNewest CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true"); + Assert.BuildOutputContainsLine(result, "Content: appsettings.Development.json CopyToOutputDirectory=PreserveNewest CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task IntrospectJsonContentFiles_WithExcludeConfigFilesFromBuildOutputSet() + { + // Verifies that the fix for https://github.com/dotnet/aspnetcore/issues/14017 works. + var result = await DotnetMSBuild("_IntrospectContentItems", "/p:ExcludeConfigFilesFromBuildOutput=true"); + + Assert.BuildPassed(result); + var launchSettingsPath = Path.Combine("Properties", "launchSettings.json"); + Assert.BuildOutputContainsLine(result, $"Content: {launchSettingsPath} CopyToOutputDirectory= CopyToPublishDirectory=Never ExcludeFromSingleFile=true"); + Assert.BuildOutputContainsLine(result, "Content: appsettings.json CopyToOutputDirectory= CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true"); + Assert.BuildOutputContainsLine(result, "Content: appsettings.Development.json CopyToOutputDirectory= CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task IntrospectRazorTasksDllPath() + { + // Regression test for https://github.com/dotnet/aspnetcore/issues/17308 + var solutionRoot = GetType().Assembly.GetCustomAttributes() + .First(a => a.Key == "Testing.RepoRoot") + .Value; + + var tfm = +#if NETCOREAPP + "net5.0"; +#else +#error Target framework needs to be updated. +#endif + + var expected = Path.Combine(solutionRoot, "artifacts", "bin", "Microsoft.NET.Sdk.Razor", Configuration, "sdk-output", "tasks", tfm, "Microsoft.NET.Sdk.Razor.Tasks.dll"); + + // Verifies the fix for https://github.com/dotnet/aspnetcore/issues/17308 + var result = await DotnetMSBuild("_IntrospectRazorTasks"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}"); + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [InitializeTestProject("SimpleMvc")] + public async Task IntrospectRazorTasksDllPath_DesktopMsBuild() + { + var solutionRoot = GetType().Assembly.GetCustomAttributes() + .First(a => a.Key == "Testing.RepoRoot") + .Value; + + var tfm = "net46"; + var expected = Path.Combine(solutionRoot, "artifacts", "bin", "Microsoft.NET.Sdk.Razor", Configuration, "sdk-output", "tasks", tfm, "Microsoft.NET.Sdk.Razor.Tasks.dll"); + + // Verifies the fix for https://github.com/dotnet/aspnetcore/issues/17308 + var result = await DotnetMSBuild("_IntrospectRazorTasks", msBuildProcessKind: MSBuildProcessKind.Desktop); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}"); + } + } +} diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildPerformanceTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildPerformanceTest.cs new file mode 100644 index 0000000000..08d2bef5ae --- /dev/null +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildPerformanceTest.cs @@ -0,0 +1,109 @@ +// 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 System.Text.RegularExpressions; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class BuildPerformanceTest : MSBuildIntegrationTestBase, IClassFixture + { + public BuildPerformanceTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task BuildMvcApp() + { + var result = await DotnetMSBuild(target: default, args: "/clp:PerformanceSummary"); + + Assert.BuildPassed(result); + var summary = ParseTaskPerformanceSummary(result.Output); + + Assert.Equal(1, summary.First(f => f.Name == "RazorGenerate").Calls); + Assert.Equal(1, summary.First(f => f.Name == "RazorTagHelper").Calls); + + // Incremental builds + for (var i = 0; i < 2; i++) + { + result = await DotnetMSBuild(target: default, args: "/clp:PerformanceSummary"); + + Assert.BuildPassed(result); + summary = ParseTaskPerformanceSummary(result.Output); + + Assert.DoesNotContain(summary, item => item.Name == "RazorGenerate"); + Assert.DoesNotContain(summary, item => item.Name == "RazorTagHelper"); + } + } + + [Fact] + [InitializeTestProject("MvcWithComponents")] + public async Task BuildMvcAppWithComponents() + { + var result = await DotnetMSBuild(target: default, args: "/clp:PerformanceSummary"); + + Assert.BuildPassed(result); + var summary = ParseTaskPerformanceSummary(result.Output); + + // One for declaration build, one for the "real" code gen + Assert.Equal(2, summary.First(f => f.Name == "RazorGenerate").Calls); + Assert.Equal(1, summary.First(f => f.Name == "RazorTagHelper").Calls); + + // Incremental builds + for (var i = 0; i < 2; i++) + { + result = await DotnetMSBuild(target: default, args: "/clp:PerformanceSummary"); + + Assert.BuildPassed(result); + summary = ParseTaskPerformanceSummary(result.Output); + + Assert.DoesNotContain(summary, item => item.Name == "RazorGenerate"); + Assert.DoesNotContain(summary, item => item.Name == "RazorTagHelper"); + } + } + + private List ParseTaskPerformanceSummary(string output) + { + const string Header = "Task Performance Summary:"; + var lines = output.Split(Environment.NewLine); + var taskSection = Array.LastIndexOf(lines, Header); + Assert.True(taskSection != -1, $"Could not find line ${Header} in {output}"); + + var entries = new List(); + // 6 ms FindAppConfigFile 4 calls + var matcher = new Regex(@"\s+(?